fix(proxy): url decode password of http proxy
This commit is contained in:
parent
b55ddd5947
commit
91d1215d5b
4 changed files with 13 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -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",
|
||||
]
|
||||
|
||||
|
|
|
@ -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"] }
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue