v0.34.0_10

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-18 09:24:03 +02:00
1 parent 8c4cbc583f
commit dd2502dd11
13 files changed
+389 -113

No files matched your search

+19 -21
View File
@@ -27,20 +27,11 @@ async fn forward_request(
.copied()
.unwrap_or_default()
.tls;
let Ok(original_host) = effective_host(&request, tls) else {
return error(
StatusCode::BAD_REQUEST,
"RustProxy: invalid or conflicting request authority\n",
);
};
let Ok(host) = original_host
.to_str()
.ok()
.and_then(|v| request_host(v).ok())
.ok_or(())
else {
return error(StatusCode::BAD_REQUEST, "RustProxy: invalid hostname\n");
};
let (selected_context, original_host, host, decoded_path, host_already_validated) =
match take_routing_identity(&mut request, tls) {
Ok(identity) => identity,
Err(response) => return response,
};
let handshake = if request.method() == Method::CONNECT {
let protocol = match request.version() {
Version::HTTP_2 => websocket::h2_protocol(&request),
@@ -106,13 +97,17 @@ async fn forward_request(
// forwarding operation, even after the request URI/headers are rewritten.
// Encoded/slash-folded paths still allocate via the strict decoder.
let routing_uri = request.uri().clone();
let Ok(path) = crate::acl::routing_path_view(routing_uri.path()) else {
return error(
StatusCode::BAD_REQUEST,
"RustProxy: ambiguous request path\n",
);
let path = if let Some(path) = decoded_path.as_deref() {
std::borrow::Cow::Borrowed(path)
} else {
let Ok(path) = crate::acl::routing_path_view(routing_uri.path()) else {
return error(
StatusCode::BAD_REQUEST,
"RustProxy: ambiguous request path\n",
);
};
path
};
let selected_context = request.extensions().get::<SelectedRouteContext>().cloned();
let frontend = if let Some(selection) = &selected_context {
selection.frontend.as_ref()
} else {
@@ -193,7 +188,7 @@ async fn forward_request(
}
}
}
let mut context = match snapshot.forwarding.context_with_original_url(
let mut context = match snapshot.forwarding.context_with_peer(
request.headers(),
peer.0,
local.0,
@@ -201,6 +196,9 @@ async fn forward_request(
&original_host,
request.uri(),
frontend.is_some_and(|frontend| frontend.tinyauth.is_some()),
request.extensions().get::<Arc<crate::forwarding::PeerFormatting>>()
.map(Arc::as_ref),
host_already_validated,
) {
Ok(context) => context,
Err(_) => {