This commit is contained in:
Mateusz Gruszczyński committed 2026-10-05 19:05:55 +02:00
1 parent ddc5c6593f
commit b9d137eee1
63 files changed
+1232 -445

No files matched your search

+48
View File
@@ -93,6 +93,54 @@ impl Snapshot {
}
None
}
/// Resolve a persistent protocol-error record to a configured vhost using
/// the same exact/wildcard precedence and listener binding rules as normal routing.
/// Client-provided Host/SNI values are never used as file names directly.
pub fn resolve_logging_vhost(
&self,
local: SocketAddr,
tls: bool,
routed_vhost: Option<&str>,
authority: Option<&str>,
host: Option<&str>,
sni: Option<&str>,
) -> Option<ResolvedLogVhost> {
if let Some(routed) = routed_vhost.filter(|value| !value.is_empty()) {
if self.frontends.values().flatten().any(|frontend| {
frontend.id == routed
&& frontend
.bindings
.iter()
.any(|binding| binding.matches(local, tls))
}) {
return Some(ResolvedLogVhost {
vhost: routed.to_owned(),
matched_by: "router",
});
}
}
for (candidate, matched_by) in [
(authority, "authority"),
(host, "host"),
(sni, "sni"),
] {
let Some(candidate) = candidate else {
continue;
};
let Ok(normalized) = request_host(candidate) else {
continue;
};
if let Some(frontend) = self.frontend(&normalized, local, tls) {
return Some(ResolvedLogVhost {
vhost: frontend.id.clone(),
matched_by,
});
}
}
None
}
/// Select a redirect host/rule using the accepted socket, TLS state and normalized path.
/// Exact hostnames win over the longest matching wildcard, matching vhost behavior.
pub fn redirect_on(