refactor
This commit is contained in:
parent
f98432fc69
commit
a52f74c434
3 changed files with 20 additions and 11 deletions
|
|
@ -13,8 +13,22 @@ publish.workspace = true
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[features]
|
||||
default = ["http3-quinn", "cache", "rustls-backend", "sticky-cookie", "acme", "post-quantum"]
|
||||
# default = ["http3-s2n", "cache", "rustls-backend", "sticky-cookie", "acme", "post-quantum"]
|
||||
default = [
|
||||
"http3-quinn",
|
||||
"cache",
|
||||
"rustls-backend",
|
||||
"sticky-cookie",
|
||||
"acme",
|
||||
"post-quantum",
|
||||
]
|
||||
# default = [
|
||||
# "http3-s2n",
|
||||
# "cache",
|
||||
# "rustls-backend",
|
||||
# "sticky-cookie",
|
||||
# "acme",
|
||||
# "post-quantum",
|
||||
# ]
|
||||
http3-quinn = ["rpxy-lib/http3-quinn"]
|
||||
http3-s2n = ["rpxy-lib/http3-s2n"]
|
||||
native-tls-backend = ["rpxy-lib/native-tls-backend"]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use super::{
|
|||
utils_request::InspectParseHost,
|
||||
};
|
||||
use crate::{
|
||||
backend::BackendAppManager,
|
||||
backend::{BackendAppManager, LoadBalanceContext},
|
||||
error::*,
|
||||
forwarder::{ForwardRequest, Forwarder},
|
||||
globals::Globals,
|
||||
|
|
@ -24,10 +24,7 @@ use tokio::io::copy_bidirectional;
|
|||
#[derive(Debug)]
|
||||
/// Context object to handle sticky cookies at HTTP message handler
|
||||
pub(super) struct HandlerContext {
|
||||
#[cfg(feature = "sticky-cookie")]
|
||||
pub(super) context_lb: Option<crate::backend::LoadBalanceContext>,
|
||||
#[cfg(not(feature = "sticky-cookie"))]
|
||||
pub(super) context_lb: Option<()>,
|
||||
pub(super) context_lb: Option<LoadBalanceContext>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Builder)]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
backend::{UpstreamCandidates, UpstreamOption},
|
||||
log::*,
|
||||
};
|
||||
use anyhow::{Result, anyhow, ensure};
|
||||
use anyhow::{Result, anyhow};
|
||||
use bytes::BufMut;
|
||||
use http::{HeaderMap, HeaderName, HeaderValue, Uri, header};
|
||||
use std::{borrow::Cow, net::SocketAddr};
|
||||
|
|
@ -22,8 +22,6 @@ pub(super) fn takeout_sticky_cookie_lb_context(
|
|||
headers: &mut HeaderMap,
|
||||
expected_cookie_name: &str,
|
||||
) -> Result<Option<LoadBalanceContext>> {
|
||||
use anyhow::ensure;
|
||||
|
||||
let mut headers_clone = headers.clone();
|
||||
|
||||
match headers_clone.entry(header::COOKIE) {
|
||||
|
|
@ -37,7 +35,7 @@ pub(super) fn takeout_sticky_cookie_lb_context(
|
|||
if sticky_cookies.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
ensure!(sticky_cookies.len() == 1, "Invalid cookie: Multiple sticky cookie values");
|
||||
anyhow::ensure!(sticky_cookies.len() == 1, "Invalid cookie: Multiple sticky cookie values");
|
||||
|
||||
let cookies_passed_to_upstream = without_sticky_cookies.join("; ");
|
||||
let cookie_passed_to_lb = sticky_cookies.first().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue