fix(proxy): url decode password of http proxy

This commit is contained in:
Σrebe - Romain GERARD 2023-11-09 17:18:38 +01:00
parent b55ddd5947
commit 91d1215d5b
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4
4 changed files with 13 additions and 1 deletions

7
Cargo.lock generated
View file

@ -1468,6 +1468,12 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "utf-8"
version = "0.7.6"
@ -1640,6 +1646,7 @@ dependencies = [
"tracing",
"tracing-subscriber",
"url",
"urlencoding",
"uuid",
]

View file

@ -23,6 +23,7 @@ jsonwebtoken = { version = "9.1.0", default-features = false }
rustls-pemfile = { version = "1.0.3", features = [] }
bytes = { version = "1.5.0", features = [] }
parking_lot = "0.12.1"
urlencoding = "2.1.3"
rustls-native-certs = { version = "0.6.3", features = [] }
tokio = { version = "1.33.0", features = ["full"] }

View file

@ -112,6 +112,8 @@ pub async fn connect_with_http_proxy(
info!("Connected to http proxy {}:{}", proxy_host, proxy_port);
let authorization = if let Some((user, password)) = proxy.password().map(|p| (proxy.username(), p)) {
let password =
urlencoding::decode(password).with_context(|| format!("Cannot urldecode proxy password: {}", password))?;
let creds = base64::engine::general_purpose::STANDARD.encode(format!("{}:{}", user, password));
format!("Proxy-Authorization: Basic {}\r\n", creds)
} else {

View file

@ -102,7 +102,9 @@ where
// Forward local tx to websocket tx
let ping_frequency = client_cfg.websocket_ping_frequency;
tokio::spawn(super::io::propagate_read(local_rx, ws_tx, close_tx, Some(ping_frequency)).instrument(Span::current()));
tokio::spawn(
super::io::propagate_read(local_rx, ws_tx, close_tx, Some(ping_frequency)).instrument(Span::current()),
);
// Forward websocket rx to local rx
let _ = super::io::propagate_write(local_tx, ws_rx, close_rx).await;