Skip to content

Commit db471c7

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

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();
@@ -988,19 +987,9 @@ impl ConnectingTcp<'_> {
988987
}
989988
}
990989

991-
/// Respect explicit ports in the URI, if none, either
992-
/// keep non `0` ports resolved from a custom dns resolver,
993-
/// or use the default port for the scheme.
994-
fn set_port(addr: &mut SocketAddr, host_port: u16, explicit: bool) {
995-
if explicit || addr.port() == 0 {
996-
addr.set_port(host_port)
997-
};
998-
}
999-
1000990
#[cfg(test)]
1001991
mod tests {
1002992
use std::io;
1003-
use std::net::SocketAddr;
1004993

1005994
use ::http::Uri;
1006995

@@ -1009,8 +998,6 @@ mod tests {
1009998
use super::super::sealed::{Connect, ConnectSvc};
1010999
use super::{Config, ConnectError, HttpConnector};
10111000

1012-
use super::set_port;
1013-
10141001
async fn connect<C>(
10151002
connector: C,
10161003
dst: Uri,
@@ -1429,22 +1416,4 @@ mod tests {
14291416
panic!("test failed");
14301417
}
14311418
}
1432-
1433-
#[test]
1434-
fn test_set_port() {
1435-
// Respect explicit ports no matter what the resolved port is.
1436-
let mut addr = SocketAddr::from(([0, 0, 0, 0], 6881));
1437-
set_port(&mut addr, 42, true);
1438-
assert_eq!(addr.port(), 42);
1439-
1440-
// Ignore default host port, and use the socket port instead.
1441-
let mut addr = SocketAddr::from(([0, 0, 0, 0], 6881));
1442-
set_port(&mut addr, 443, false);
1443-
assert_eq!(addr.port(), 6881);
1444-
1445-
// Use the default port if the resolved port is `0`.
1446-
let mut addr = SocketAddr::from(([0, 0, 0, 0], 0));
1447-
set_port(&mut addr, 443, false);
1448-
assert_eq!(addr.port(), 443);
1449-
}
14501419
}

0 commit comments

Comments
 (0)