diff --git a/rpxy-bin/Cargo.toml b/rpxy-bin/Cargo.toml index dfff39f..fe48b48 100644 --- a/rpxy-bin/Cargo.toml +++ b/rpxy-bin/Cargo.toml @@ -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"] diff --git a/rpxy-lib/src/message_handler/handler_main.rs b/rpxy-lib/src/message_handler/handler_main.rs index 1b3663e..d4fd53c 100644 --- a/rpxy-lib/src/message_handler/handler_main.rs +++ b/rpxy-lib/src/message_handler/handler_main.rs @@ -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, - #[cfg(not(feature = "sticky-cookie"))] - pub(super) context_lb: Option<()>, + pub(super) context_lb: Option, } #[derive(Clone, Builder)] diff --git a/rpxy-lib/src/message_handler/utils_headers.rs b/rpxy-lib/src/message_handler/utils_headers.rs index 354fa6e..fe351d9 100644 --- a/rpxy-lib/src/message_handler/utils_headers.rs +++ b/rpxy-lib/src/message_handler/utils_headers.rs @@ -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> { - 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();