Skip to content

Commit

Permalink
docs: document using non-zero ports in resolved addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Nov 7, 2024
1 parent 6e21413 commit 618db2a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
16 changes: 4 additions & 12 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1858,24 +1858,16 @@ 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 conventional port for the given scheme (e.g. 80 for http).
/// Ports in the URL itself will always be used instead of the port in the overridden addr.
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 conventional port for the given scheme (e.g. 80 for http).
/// Ports in the URL itself will always be used instead of the port in the overridden addr.
pub fn resolve_to_addrs(mut self, domain: &str, addrs: &[SocketAddr]) -> ClientBuilder {
self.config
.dns_overrides
Expand Down
16 changes: 4 additions & 12 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,24 +945,16 @@ 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 conventional port for the given scheme (e.g. 80 for http).
/// Ports in the URL itself will always be used instead of the port in the overridden addr.
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 conventional port for the given scheme (e.g. 80 for http).
/// Ports in the URL itself will always be used instead of the port in the overridden addr.
pub fn resolve_to_addrs(self, domain: &str, addrs: &[SocketAddr]) -> ClientBuilder {
self.with_inner(|inner| inner.resolve_to_addrs(domain, addrs))
}
Expand Down
3 changes: 3 additions & 0 deletions src/dns/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ 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`.
///
/// Explicitly specified port in the URL will override any port in the resolved `SocketAddr`s.
/// Otherwise, port `0` will be replaced by the conventional port for the given scheme (e.g. 80 for http).
fn resolve(&self, name: Name) -> Resolving;
}

Expand Down

0 comments on commit 618db2a

Please sign in to comment.