diff --git a/src/main.rs b/src/main.rs index e22e457..cd4405b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,10 @@ struct Args { #[arg(short, long, env, default_value = "x-target-host")] target_host_port_header: String, - /// Name of optional header that contains path to add to the request + /// Name of optional header that contains path to add to the request. + /// + /// If this value is defined, all clients packets are inspected in research for path to + /// manipulate #[arg(short, long, env)] path_prefix_header: Option, } @@ -125,6 +128,14 @@ async fn main() -> Result<(), Box> { break; } + // In case of connection reuse, we need to reanalyze data + if ARGS.path_prefix_header.is_some() && + let Ok(Some(res))= process_headers(&buf_client[..count]) + && let Err(e) = upstream.write_all(&res.buff).await { + log::error!("[{conn_id}] Failed to write to upstream! {e}"); + break; + } + if let Err(e)=upstream.write_all(&buf_client[..count]).await { log::error!("[{conn_id}] Failed to write to upstream! {e}"); break;