0.34.6_repo_cleanup
This commit is contained in:
1 parent
ce1a90397c
commit
133d2f0f91
273 files changed
+5969
-6926
No files matched your search
@@ -1,6 +1,3 @@
|
||||
//! Per-backend connection pools and connect-time DNS validation.
|
||||
//! No HTTP caller can supply a destination. DNS answers are validated once and
|
||||
//! passed directly to HttpConnector; there is no second unvalidated lookup.
|
||||
use crate::config::{ip_policy, Backend};
|
||||
use anyhow::{ensure, Context, Result};
|
||||
use http::Uri;
|
||||
@@ -152,8 +149,6 @@ impl AddressPolicy {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GuardedResolver {
|
||||
policy: AddressPolicy,
|
||||
/// When TLS uses a separate verified server name, resolve/connect only the
|
||||
/// hostname from the configured backend URL, never the SNI hostname.
|
||||
connect_host: Option<String>,
|
||||
}
|
||||
impl Service<Name> for GuardedResolver {
|
||||
@@ -178,8 +173,6 @@ impl Service<Name> for GuardedResolver {
|
||||
io::Error::new(io::ErrorKind::WouldBlock, "DNS worker limit reached")
|
||||
})?;
|
||||
let lookup = tokio::task::spawn_blocking(move || {
|
||||
// The permit lives inside the worker even if the caller times out.
|
||||
// An OS resolver stuck in getaddrinfo cannot create an unbounded worker queue.
|
||||
let _permit = permit;
|
||||
policy.validate_answers((hostname.as_str(), 0).to_socket_addrs()?)
|
||||
});
|
||||
@@ -197,8 +190,6 @@ pub struct TimedConnector {
|
||||
inner: InnerConnector,
|
||||
policy: AddressPolicy,
|
||||
timeout: Duration,
|
||||
/// The configured backend/TLS identity, never the forwarded HTTP Host.
|
||||
/// The resolver separately pins DNS to the configured backend URL.
|
||||
destination: Uri,
|
||||
}
|
||||
impl Service<Uri> for TimedConnector {
|
||||
@@ -210,8 +201,6 @@ impl Service<Uri> for TimedConnector {
|
||||
self.inner.poll_ready(cx).map_err(Into::into)
|
||||
}
|
||||
fn call(&mut self, _request_uri: Uri) -> Self::Future {
|
||||
// A preserved HTTP/2 :authority can be a public vhost name. Never
|
||||
// resolve or dial it: all sockets must target the configured origin.
|
||||
let uri = self.destination.clone();
|
||||
if let Some(ip) = uri.host().and_then(|host| {
|
||||
host.trim_start_matches('[')
|
||||
@@ -259,15 +248,6 @@ fn roots(backend: &Backend) -> Result<RootCertStore> {
|
||||
Ok(roots)
|
||||
}
|
||||
|
||||
/// Explicit backend-only escape hatch. `tls_verify=false` means that the backend
|
||||
/// certificate is not authenticated at all: chain/name checks and certificate
|
||||
/// signature parsing are skipped. TLS transport encryption and the normal
|
||||
/// address/DNS/loop policy remain in force.
|
||||
///
|
||||
/// Do not delegate CertificateVerify to WebPkiServerVerifier here. webpki parses
|
||||
/// the presented X.509 certificate even after `verify_server_cert()` accepted it,
|
||||
/// which rejects legacy X.509 v1 appliance certificates with
|
||||
/// `UnsupportedCertVersion`. That made `tls_verify=false` only a partial bypass.
|
||||
#[derive(Debug)]
|
||||
struct BackendCertificateVerificationDisabled {
|
||||
supported_schemes: Vec<SignatureScheme>,
|
||||
@@ -303,8 +283,6 @@ impl ServerCertVerifier for BackendCertificateVerificationDisabled {
|
||||
self.supported_schemes.clone()
|
||||
}
|
||||
}
|
||||
/// A bounded raw TCP liveness check, using the same configured-origin address
|
||||
/// policy as normal requests. Every DNS answer is checked before any connection.
|
||||
pub async fn tcp_probe(origin: &str, policy: &AddressPolicy) -> Result<()> {
|
||||
let url = url::Url::parse(origin)?;
|
||||
let host = url
|
||||
@@ -340,13 +318,9 @@ pub async fn tcp_probe(origin: &str, policy: &AddressPolicy) -> Result<()> {
|
||||
#[cfg(test)]
|
||||
include!("upstream/tests.rs");
|
||||
|
||||
/// Enumerate local interfaces for wildcard-listener loop protection. If unavailable,
|
||||
/// the fallback checks whether a candidate address is actually bindable on this host.
|
||||
#[cfg(unix)]
|
||||
fn local_addresses() -> Option<Vec<IpAddr>> {
|
||||
let mut first: *mut libc::ifaddrs = std::ptr::null_mut();
|
||||
// SAFETY: getifaddrs owns the returned linked list until freeifaddrs; family
|
||||
// is inspected before casting each non-null sockaddr to its matching type.
|
||||
unsafe {
|
||||
if libc::getifaddrs(&mut first) != 0 {
|
||||
return None;
|
||||
@@ -381,9 +355,6 @@ fn local_addresses() -> Option<Vec<IpAddr>> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Fallback used when interface enumeration is unavailable. Binding an ephemeral
|
||||
/// UDP socket to an address succeeds only when the OS considers that address local
|
||||
/// (without non-local/freebind socket options, which Rust does not enable here).
|
||||
fn locally_bindable(ip: IpAddr) -> bool {
|
||||
std::net::UdpSocket::bind(SocketAddr::new(ip, 0)).is_ok()
|
||||
}
|
||||
Reference in new issue
Block a user