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 aff4120
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
14 changes: 2 additions & 12 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions src/blocking/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
4 changes: 4 additions & 0 deletions src/dns/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit aff4120

Please sign in to comment.