add resolve to blocking client (#1384)

This commit is contained in:
niuhuan
2021-11-19 08:33:29 +08:00
committed by GitHub
parent 0ef1a2ea78
commit 161d731892

View File

@@ -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<F>(mut self, func: F) -> ClientBuilder