pub struct Client { /* private fields */ }Expand description
A DoH client
It will use the configured DoH server to send all resolve queries to.
§Example
let client = dnsoverhttps::Client::from_url("https://1.1.1.1/dns-query").unwrap();
let addr = client.resolve_host("example.com");Implementations§
Source§impl Client
impl Client
Sourcepub fn from_url(url: &str) -> Result<Client, Error>
pub fn from_url(url: &str) -> Result<Client, Error>
Create a new DoH client using the given query URL.
The URL’s host will be resolved using the system’s resolver.
The host will be queried using a POST request using the application/dns-message content-type for the body.
Sourcepub fn from_url_with_hostname(url: &str, host: String) -> Result<Client, Error>
pub fn from_url_with_hostname(url: &str, host: String) -> Result<Client, Error>
Create a new DoH client using the given query URL and host.
This should be used to bootstrap DoH resolving without the system’s resolver. The URL can
contain the host’s IP and the hostname is used in the HTTP request.
The host will be queried using a POST request using the application/dns-message content-type for the body.
§Caution
This will disable hostname verification of the TLS server certificate. The certificate is still checked for validity.
Sourcepub fn resolve_host(&self, host: &str) -> Result<Vec<IpAddr>, Error>
pub fn resolve_host(&self, host: &str) -> Result<Vec<IpAddr>, Error>
Resolve the host specified by host as a list of IpAddr.
This method queries the configured server over HTTPS for both IPv4 and IPv6 addresses.
If the host cannot be found, the list will be empty. If any errors are encountered during the resolving, the error is returned.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more