Skip to content

Commit c4fd9b4

Browse files
x86pupjevolk
authored andcommitted
Revert "feat(client): use non-zero ports resolved by dns resolvers (hyperium#148)"
This reverts commit 2639193.
1 parent 71360e4 commit c4fd9b4

File tree

1 file changed

+1
-32
lines changed

1 file changed

+1
-32
lines changed

src/client/legacy/connect/http.rs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,7 @@ where
546546
.map_err(ConnectError::dns)?;
547547
let addrs = addrs
548548
.map(|mut addr| {
549-
set_port(&mut addr, port, dst.port().is_some());
550-
549+
addr.set_port(port);
551550
addr
552551
})
553552
.collect();
@@ -1004,19 +1003,9 @@ impl ConnectingTcp<'_> {
10041003
}
10051004
}
10061005

1007-
/// Respect explicit ports in the URI, if none, either
1008-
/// keep non `0` ports resolved from a custom dns resolver,
1009-
/// or use the default port for the scheme.
1010-
fn set_port(addr: &mut SocketAddr, host_port: u16, explicit: bool) {
1011-
if explicit || addr.port() == 0 {
1012-
addr.set_port(host_port)
1013-
};
1014-
}
1015-
10161006
#[cfg(test)]
10171007
mod tests {
10181008
use std::io;
1019-
use std::net::SocketAddr;
10201009

10211010
use ::http::Uri;
10221011

@@ -1025,8 +1014,6 @@ mod tests {
10251014
use super::super::sealed::{Connect, ConnectSvc};
10261015
use super::{Config, ConnectError, HttpConnector};
10271016

1028-
use super::set_port;
1029-
10301017
async fn connect<C>(
10311018
connector: C,
10321019
dst: Uri,
@@ -1447,22 +1434,4 @@ mod tests {
14471434
panic!("test failed");
14481435
}
14491436
}
1450-
1451-
#[test]
1452-
fn test_set_port() {
1453-
// Respect explicit ports no matter what the resolved port is.
1454-
let mut addr = SocketAddr::from(([0, 0, 0, 0], 6881));
1455-
set_port(&mut addr, 42, true);
1456-
assert_eq!(addr.port(), 42);
1457-
1458-
// Ignore default host port, and use the socket port instead.
1459-
let mut addr = SocketAddr::from(([0, 0, 0, 0], 6881));
1460-
set_port(&mut addr, 443, false);
1461-
assert_eq!(addr.port(), 6881);
1462-
1463-
// Use the default port if the resolved port is `0`.
1464-
let mut addr = SocketAddr::from(([0, 0, 0, 0], 0));
1465-
set_port(&mut addr, 443, false);
1466-
assert_eq!(addr.port(), 443);
1467-
}
14681437
}

0 commit comments

Comments
 (0)