v0.26.1
This commit is contained in:
1 parent
ddc5c6593f
commit
b9d137eee1
63 files changed
+1232
-445
No files matched your search
+59
-12
@@ -88,6 +88,61 @@ pub struct Transport {
|
||||
pub tls: bool,
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn log_protocol_error_with_identity(
|
||||
state: Option<&Arc<App>>,
|
||||
kind: &'static str,
|
||||
detail: impl std::fmt::Display,
|
||||
peer: SocketAddr,
|
||||
local: SocketAddr,
|
||||
transport: &'static str,
|
||||
http_version: &'static str,
|
||||
status: u16,
|
||||
authority: Option<String>,
|
||||
host: Option<String>,
|
||||
tls_sni: Option<String>,
|
||||
) {
|
||||
if let Some(state) = state {
|
||||
let resolved = state.config.load().resolve_logging_vhost(
|
||||
local,
|
||||
matches!(transport, "tls" | "quic"),
|
||||
None,
|
||||
authority.as_deref(),
|
||||
host.as_deref(),
|
||||
tls_sni.as_deref(),
|
||||
);
|
||||
let (vhost, matched_by) = resolved
|
||||
.map(|resolved| (Some(resolved.vhost), resolved.matched_by))
|
||||
.unwrap_or((None, "none"));
|
||||
state.logs.push_protocol_error_attributed(
|
||||
kind,
|
||||
detail,
|
||||
peer,
|
||||
local,
|
||||
transport,
|
||||
http_version,
|
||||
status,
|
||||
tls_sni,
|
||||
authority.or(host),
|
||||
vhost,
|
||||
matched_by,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn request_log_identity<B>(request: &Request<B>) -> (Option<String>, Option<String>) {
|
||||
let authority = request
|
||||
.uri()
|
||||
.authority()
|
||||
.map(|value| value.as_str().to_owned());
|
||||
let host = request
|
||||
.headers()
|
||||
.get(http::header::HOST)
|
||||
.and_then(|value| value.to_str().ok())
|
||||
.map(str::to_owned);
|
||||
(authority, host)
|
||||
}
|
||||
|
||||
fn log_protocol_error(
|
||||
state: Option<&Arc<App>>,
|
||||
kind: &'static str,
|
||||
@@ -99,18 +154,10 @@ fn log_protocol_error(
|
||||
status: u16,
|
||||
tls_sni: Option<String>,
|
||||
) {
|
||||
if let Some(state) = state {
|
||||
state.logs.push_protocol_error(
|
||||
kind,
|
||||
detail,
|
||||
peer,
|
||||
local,
|
||||
transport,
|
||||
http_version,
|
||||
status,
|
||||
tls_sni,
|
||||
);
|
||||
}
|
||||
log_protocol_error_with_identity(
|
||||
state, kind, detail, peer, local, transport, http_version, status, None, None,
|
||||
tls_sni,
|
||||
);
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub struct ServerShutdown(pub CancellationToken);
|
||||
|
||||
Reference in new issue
Block a user