pub struct DnsFilter { /* private fields */ }Expand description
DNS leak protection filter.
Intercepts DNS queries, checks the blocklist and cache, and decides whether to forward through the tunnel or block.
Implementations§
Source§impl DnsFilter
impl DnsFilter
Sourcepub fn is_dns_packet(data: &[u8]) -> bool
pub fn is_dns_packet(data: &[u8]) -> bool
Returns true if a raw UDP payload looks like a DNS packet.
Checks minimum length and QR/opcode field sanity.
Sourcepub fn decide(&mut self, domain: &str, query_type: &DnsQueryType) -> DnsAction
pub fn decide(&mut self, domain: &str, query_type: &DnsQueryType) -> DnsAction
Decide what to do with a DNS query for the given domain.
Checks in order: cache → blocklist → split DNS → forward.
Sourcepub fn cache_response(&mut self, domain: &str, addr: IpAddr)
pub fn cache_response(&mut self, domain: &str, addr: IpAddr)
Cache a DNS response for a domain.
Sourcepub fn is_blocked(&self, domain: &str) -> bool
pub fn is_blocked(&self, domain: &str) -> bool
Returns true if the domain is in the blocklist.
Supports wildcard suffix matching: blocking “ads.com” also blocks “sub.ads.com”.
Sourcepub fn is_split_dns(&self, domain: &str) -> bool
pub fn is_split_dns(&self, domain: &str) -> bool
Returns true if the domain should use split DNS (bypass tunnel).
Sourcepub fn block_domain(&mut self, domain: &str)
pub fn block_domain(&mut self, domain: &str)
Add a domain to the blocklist at runtime.
Sourcepub fn add_split_domain(&mut self, domain: &str)
pub fn add_split_domain(&mut self, domain: &str)
Add a split DNS domain at runtime.
Sourcepub fn primary_upstream(&self) -> Option<&str>
pub fn primary_upstream(&self) -> Option<&str>
Get the first upstream DNS server address.
Sourcepub fn evict_expired(&mut self)
pub fn evict_expired(&mut self)
Remove expired entries from the cache.
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the entire DNS cache.
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
Returns the number of entries currently in the cache.
Sourcepub fn total_intercepted(&self) -> u64
pub fn total_intercepted(&self) -> u64
Returns total queries intercepted.
Sourcepub fn total_blocked(&self) -> u64
pub fn total_blocked(&self) -> u64
Returns total queries blocked.
Sourcepub fn total_cache_hits(&self) -> u64
pub fn total_cache_hits(&self) -> u64
Returns total cache hits.
Sourcepub fn total_forwarded(&self) -> u64
pub fn total_forwarded(&self) -> u64
Returns total queries forwarded through tunnel.