pub struct DohResolver { /* private fields */ }Expand description
A DNS-over-HTTPS resolver with configurable DNS servers.
This resolver can work in two modes:
- Direct: Uses regular TCP/TLS for DNS queries (before WireGuard is up)
- Tunnel: Routes DNS queries through the WireGuard tunnel
§Example
use wireguard_netstack::{DohResolver, DohServerConfig};
// Use default Cloudflare DNS
let resolver = DohResolver::new_direct();
// Use custom DNS server
let resolver = DohResolver::new_direct_with_config(DohServerConfig::google());Implementations§
Source§impl DohResolver
impl DohResolver
Sourcepub fn new_tunneled(netstack: Arc<NetStack>) -> Self
pub fn new_tunneled(netstack: Arc<NetStack>) -> Self
Create a new DoH resolver that uses the WireGuard tunnel with default Cloudflare DNS.
Sourcepub fn new_tunneled_with_config(
netstack: Arc<NetStack>,
config: DohServerConfig,
) -> Self
pub fn new_tunneled_with_config( netstack: Arc<NetStack>, config: DohServerConfig, ) -> Self
Create a new DoH resolver that uses the WireGuard tunnel with custom DNS config.
Sourcepub fn new_direct() -> Self
pub fn new_direct() -> Self
Create a new DoH resolver that uses direct TCP connections with default Cloudflare DNS. Use this before the WireGuard tunnel is established.
Sourcepub fn new_direct_with_config(config: DohServerConfig) -> Self
pub fn new_direct_with_config(config: DohServerConfig) -> Self
Create a new DoH resolver that uses direct TCP connections with custom DNS config. Use this before the WireGuard tunnel is established.
Sourcepub fn server_config(&self) -> &DohServerConfig
pub fn server_config(&self) -> &DohServerConfig
Get the current server configuration.
Sourcepub async fn resolve(&self, hostname: &str) -> Result<Vec<Ipv4Addr>>
pub async fn resolve(&self, hostname: &str) -> Result<Vec<Ipv4Addr>>
Resolve a hostname to IPv4 addresses using DNS-over-HTTPS.
Sourcepub async fn resolve_addr(
&self,
hostname: &str,
port: u16,
) -> Result<SocketAddr>
pub async fn resolve_addr( &self, hostname: &str, port: u16, ) -> Result<SocketAddr>
Resolve a hostname to a single socket address.
Auto Trait Implementations§
impl !Freeze for DohResolver
impl !RefUnwindSafe for DohResolver
impl Send for DohResolver
impl Sync for DohResolver
impl Unpin for DohResolver
impl UnsafeUnpin for DohResolver
impl !UnwindSafe for DohResolver
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
Mutably borrows from an owned value. Read more
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>
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 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>
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