From aff41209bb206793d066baf5edf138cb67f941d0 Mon Sep 17 00:00:00 2001 From: nazeh Date: Thu, 7 Nov 2024 12:55:59 +0300 Subject: [PATCH] docs: document using non-zero ports in resolved addresses --- src/async_impl/client.rs | 14 ++------------ src/blocking/client.rs | 14 ++------------ src/dns/resolve.rs | 4 ++++ 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 1735a1bb1..b931ea2f4 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -1858,24 +1858,14 @@ impl ClientBuilder { /// Override DNS resolution for specific domains to a particular IP address. /// - /// Warning - /// - /// Since the DNS protocol has no notion of ports, if you wish to send - /// traffic to a particular port you must include this port in the URL - /// itself, any port in the overridden addr will be ignored and traffic sent - /// to the conventional port for the given scheme (e.g. 80 for http). + /// Set the port to `0` to use the port specified in the URL or the conventional port for the given scheme (e.g. 80 for http). pub fn resolve(self, domain: &str, addr: SocketAddr) -> ClientBuilder { self.resolve_to_addrs(domain, &[addr]) } /// Override DNS resolution for specific domains to particular IP addresses. /// - /// Warning - /// - /// Since the DNS protocol has no notion of ports, if you wish to send - /// traffic to a particular port you must include this port in the URL - /// itself, any port in the overridden addresses will be ignored and traffic sent - /// to the conventional port for the given scheme (e.g. 80 for http). + /// Set the port to `0` to use the port specified in the URL or the conventional port for the given scheme (e.g. 80 for http). pub fn resolve_to_addrs(mut self, domain: &str, addrs: &[SocketAddr]) -> ClientBuilder { self.config .dns_overrides diff --git a/src/blocking/client.rs b/src/blocking/client.rs index a8c5319b4..539a0b837 100644 --- a/src/blocking/client.rs +++ b/src/blocking/client.rs @@ -945,24 +945,14 @@ impl ClientBuilder { /// Override DNS resolution for specific domains to a particular IP address. /// - /// Warning - /// - /// Since the DNS protocol has no notion of ports, if you wish to send - /// traffic to a particular port you must include this port in the URL - /// itself, any port in the overridden addr will be ignored and traffic sent - /// to the conventional port for the given scheme (e.g. 80 for http). + /// Set the port to `0` to use the port specified in the URL or the conventional port for the given scheme (e.g. 80 for http). pub fn resolve(self, domain: &str, addr: SocketAddr) -> ClientBuilder { self.resolve_to_addrs(domain, &[addr]) } /// Override DNS resolution for specific domains to particular IP addresses. /// - /// Warning - /// - /// Since the DNS protocol has no notion of ports, if you wish to send - /// traffic to a particular port you must include this port in the URL - /// itself, any port in the overridden addresses will be ignored and traffic sent - /// to the conventional port for the given scheme (e.g. 80 for http). + /// Set the port to `0` to use the port specified in the URL or the conventional port for the given scheme (e.g. 80 for http). pub fn resolve_to_addrs(self, domain: &str, addrs: &[SocketAddr]) -> ClientBuilder { self.with_inner(|inner| inner.resolve_to_addrs(domain, addrs)) } diff --git a/src/dns/resolve.rs b/src/dns/resolve.rs index fe34ecdde..f37845497 100644 --- a/src/dns/resolve.rs +++ b/src/dns/resolve.rs @@ -27,6 +27,10 @@ pub trait Resolve: Send + Sync { /// * It does not need a mutable reference to `self`. /// * Since trait objects cannot make use of associated types, it requires /// wrapping the returned `Future` and its contained `Iterator` with `Box`. + /// + /// Ports in the resolved `SocketAddr` will be used, unless they are set to `0` in which case + /// the port specified in the URL or the conventional port for the given scheme (e.g. 80 for http) + /// will be used instead. fn resolve(&self, name: Name) -> Resolving; }