From 161d731892b978916ec8647002d43f0dfe40e8ea Mon Sep 17 00:00:00 2001 From: niuhuan Date: Fri, 19 Nov 2021 08:33:29 +0800 Subject: [PATCH] add resolve to blocking client (#1384) --- src/blocking/client.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/blocking/client.rs b/src/blocking/client.rs index f512725..d3548e1 100644 --- a/src/blocking/client.rs +++ b/src/blocking/client.rs @@ -4,6 +4,7 @@ use std::convert::TryInto; use std::fmt; use std::future::Future; use std::net::IpAddr; +use std::net::SocketAddr; use std::sync::Arc; use std::thread; use std::time::Duration; @@ -742,6 +743,18 @@ impl ClientBuilder { self.with_inner(|inner| inner.https_only(enabled)) } + /// 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 addr will be ignored and traffic sent + /// to the conventional port for the given scheme (e.g. 80 for http). + pub fn resolve(self, domain: &str, addr: SocketAddr) -> ClientBuilder { + self.with_inner(|inner| inner.resolve(domain, addr)) + } + // private fn with_inner(mut self, func: F) -> ClientBuilder