Skip to content

Commit 5f5c53d

Browse files
compilation, clippy
1 parent 4a09d5d commit 5f5c53d

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ error-backtrace = []
8787
# Enable SOCKS5 proxy support.
8888
socks5-proxy = ["dep:fast-socks5"]
8989

90-
9190
[dependencies]
9291
base64 = "0.22"
9392
bitflags = "2"

src/client/options.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,9 +1782,13 @@ impl ConnectionString {
17821782
srv_service_name: _,
17831783
wait_queue_timeout,
17841784
tls_insecure,
1785+
#[cfg(feature = "socks5-proxy")]
17851786
proxy_host,
1787+
#[cfg(feature = "socks5-proxy")]
17861788
proxy_port,
1789+
#[cfg(feature = "socks5-proxy")]
17871790
proxy_username,
1791+
#[cfg(feature = "socks5-proxy")]
17881792
proxy_password,
17891793
#[cfg(test)]
17901794
original_uri: _,
@@ -2087,20 +2091,23 @@ impl ConnectionString {
20872091
opts.push_str(&format!("&srvMaxHosts={srv_max_hosts}"));
20882092
}
20892093

2090-
if let Some(proxy_host) = proxy_host {
2091-
opts.push_str(&format!("&proxyHost={proxy_host}"));
2092-
}
2094+
#[cfg(feature = "socks5-proxy")]
2095+
{
2096+
if let Some(proxy_host) = proxy_host {
2097+
opts.push_str(&format!("&proxyHost={proxy_host}"));
2098+
}
20932099

2094-
if let Some(proxy_port) = proxy_port {
2095-
opts.push_str(&format!("&proxyPort={proxy_port}"));
2096-
}
2100+
if let Some(proxy_port) = proxy_port {
2101+
opts.push_str(&format!("&proxyPort={proxy_port}"));
2102+
}
20972103

2098-
if let Some(proxy_username) = proxy_username {
2099-
opts.push_str(&format!("&proxyUsername={proxy_username}"));
2100-
}
2104+
if let Some(proxy_username) = proxy_username {
2105+
opts.push_str(&format!("&proxyUsername={proxy_username}"));
2106+
}
21012107

2102-
if let Some(proxy_password) = proxy_password {
2103-
opts.push_str(&format!("&proxyPassword={proxy_password}"));
2108+
if let Some(proxy_password) = proxy_password {
2109+
opts.push_str(&format!("&proxyPassword={proxy_password}"));
2110+
}
21042111
}
21052112

21062113
if !opts.is_empty() {

src/cmap/establish.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ use crate::{
2222
},
2323
error::{Error as MongoError, ErrorKind, Result},
2424
hello::HelloReply,
25-
runtime::{
26-
stream::{Proxy, DEFAULT_CONNECT_TIMEOUT},
27-
AsyncStream,
28-
TlsConfig,
29-
},
25+
runtime::{stream::DEFAULT_CONNECT_TIMEOUT, AsyncStream, TlsConfig},
3026
sdam::{topology::TopologySpec, HandshakePhase},
3127
};
3228

29+
#[cfg(feature = "socks5-proxy")]
30+
use crate::runtime::stream::Proxy;
31+
3332
/// Contains the logic to establish a connection, including handshaking, authenticating, and
3433
/// potentially more.
3534
#[derive(Clone)]

src/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,9 @@ impl Error {
577577
| ErrorKind::Authentication { .. }
578578
| ErrorKind::Custom(_)
579579
| ErrorKind::Shutdown
580-
| ErrorKind::GridFs(_)
581-
| ErrorKind::ProxyConnect { .. } => {}
580+
| ErrorKind::GridFs(_) => {}
581+
#[cfg(feature = "socks5-proxy")]
582+
ErrorKind::ProxyConnect { .. } => {}
582583
#[cfg(feature = "in-use-encryption")]
583584
ErrorKind::Encryption(_) => {}
584585
#[cfg(feature = "bson-3")]

src/runtime/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl AsyncStream {
127127
ServerAddress::Tcp { host, port } => {
128128
#[cfg(feature = "socks5-proxy")]
129129
if let Some(proxy) = proxy {
130-
let inner = proxy.connect(host.clone(), port.clone()).await?;
130+
let inner = proxy.connect(host.clone(), *port).await?;
131131
return match tls_cfg {
132132
Some(cfg) => {
133133
Ok(AsyncStream::Socks5Tls(tls_connect(host, inner, cfg).await?))

0 commit comments

Comments
 (0)