seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.69k stars 1.09k forks source link

Feature request: Display auth in ProxyScheme #1754

Open ignassew opened 1 year ago

ignassew commented 1 year ago

Currently ProxyScheme Debug implementation ignores auth, only showing the protocol, host, and port. This is sometimes not enough: for example when you use the same host but multiple different user:password combinations.

My problem was that I was naively splitting proxy list by \n, while files from windows contained \r\n. This made the password have the \r thus invalidating it. If I saw the auth through debug it would have been way easier to debug. This is what Debug should be for.

The Debug implementation for ProxyScheme seems to avoid auth intentionally. Is it for security purposes? If not, then I would be happy to make a PR changing it.

If it is made like this for security, is there any way that could satisfy my need somehow? (auth is behind a private value)

Debug implementation for ProxyScheme for reference:

src/proxy.rs:688

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)
            }
        }
    }
}
seanmonstar commented 1 year ago

It does purposefully not include the auth. Usually, that is secret info that you don't want accidentally logged. I don't currently think it should be changed.