Files
RustProxy/src/http3/identity.rs
T

30 lines
970 B
Rust

fn client_cancelled_code(code: Code) -> bool {
code == Code::H3_REQUEST_CANCELLED || code == Code::H3_NO_ERROR
}
fn client_cancelled_request(error: &h3::error::StreamError) -> bool {
matches!(
error,
h3::error::StreamError::RemoteTerminate { code, .. } if client_cancelled_code(*code)
)
}
fn request_identity<B>(request: &http::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 connection_sni(connection: &quinn::Connection) -> Option<String> {
connection
.handshake_data()?
.downcast::<quinn::crypto::rustls::HandshakeData>()
.ok()?
.server_name
.and_then(|name| crate::config::request_host(&name).ok())
}