Struct Client

Source
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

Source

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.

Source

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.

Source

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§

Source§

impl Default for Client

Source§

fn default() -> Client

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Err = <U as TryFrom<T>>::Err

Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Err>

Source§

impl<T> ErasedDestructor for T
where T: 'static,