Improve debug logging (#781)

This commit is contained in:
Sean McArthur
2020-01-13 12:24:38 -08:00
committed by GitHub
parent 1478313756
commit 14908ad3f0
4 changed files with 40 additions and 8 deletions

View File

@@ -55,7 +55,7 @@ pub struct Proxy {
/// A particular scheme used for proxying requests.
///
/// For example, HTTP vs SOCKS5
#[derive(Clone, Debug)]
#[derive(Clone)]
pub enum ProxyScheme {
Http {
auth: Option<HeaderValue>,
@@ -434,6 +434,38 @@ impl ProxyScheme {
}
}
impl fmt::Debug for ProxyScheme {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ProxyScheme::Http {
auth: _auth,
host,
} => {
write!(f, "http://{}", host)
},
ProxyScheme::Https {
auth: _auth,
host,
} => {
write!(f, "https://{}", host)
},
#[cfg(feature = "socks")]
ProxyScheme::Socks5 {
addr,
auth: _auth,
remote_dns,
} => {
let h = if *remote_dns {
"h"
} else {
""
};
write!(f, "socks5{}://{}", h, addr)
}
}
}
}
type SystemProxyMap = HashMap<String, ProxyScheme>;
#[derive(Clone, Debug)]