pub struct DnsResolver { /* private fields */ }Expand description
DNS resolver with caching and multiple nameserver support
Implementations§
Source§impl DnsResolver
impl DnsResolver
Sourcepub fn add_nameserver(&mut self, addr: Ipv4Address)
pub fn add_nameserver(&mut self, addr: Ipv4Address)
Add a nameserver address
Sourcepub fn add_host(&mut self, name: &str, addr: Ipv4Address)
pub fn add_host(&mut self, name: &str, addr: Ipv4Address)
Add a static host entry
Sourcepub fn parse_resolv_conf(&mut self, content: &str)
pub fn parse_resolv_conf(&mut self, content: &str)
Parse resolv.conf content to extract nameserver lines
Sourcepub fn parse_hosts(&mut self, content: &str)
pub fn parse_hosts(&mut self, content: &str)
Parse hosts file content
Sourcepub fn lookup_hosts(&self, name: &str) -> Option<Ipv4Address>
pub fn lookup_hosts(&self, name: &str) -> Option<Ipv4Address>
Look up a name in the static hosts table
Sourcepub fn resolve(
&mut self,
name: &str,
rtype: DnsRecordType,
) -> Result<Vec<DnsRecord>, DnsError>
pub fn resolve( &mut self, name: &str, rtype: DnsRecordType, ) -> Result<Vec<DnsRecord>, DnsError>
Resolve a domain name to DNS records.
Check order: hosts file -> cache -> network query
Sourcepub fn cache_records(&mut self, records: &[DnsRecord])
pub fn cache_records(&mut self, records: &[DnsRecord])
Insert records into the cache (for use when response is received)
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
Get cache statistics
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the DNS cache