DwmDns-0.1.0
Dwm::Dns::Resolver Class Reference

Simple DNS resolver class. More...

#include <DwmDnsResolver.hh>

Public Member Functions

 Resolver (const std::string &filename="/etc/resolv.conf", const std::string &order="files,dns")
 Construct with the given resolver configuration file and the preferred order of resolver sources (ala /etc/nssswitch.conf). More...
 
bool GetHostByName (const std::string &name, std::vector< in6_addr > &in6Addrs, std::vector< in_addr > &inAddrs)
 Fetches the IPv6 and IPv4 addresses for the given host name. More...
 
bool GetHostByAddr (const in6_addr &addr, std::vector< std::string > &names)
 Fetches the host names for the given IPv6 address addr. More...
 
bool GetHostByAddr (const in_addr &addr, std::vector< std::string > &names)
 Fetches the host names for the given IPv4 address addr. More...
 
bool Get (const std::string &name, uint16_t rrtype, std::vector< ResourceRecord > &results, bool doEDNS=false, bool doDNSSEC=false, bool tcpFallback=true)
 Fetches resource records of type rrtype for the given domain name name. More...
 
template<typename RRT >
bool Get (const std::string &name, std::vector< ResourceRecord > &results, bool doEDNS=false, bool doDNSSEC=false, bool tcpFallback=true)
 Fetches resource records whose data type is RRT for the given domain name name. More...
 
template<typename RRT >
bool Get (const std::string &name, std::vector< RRT > &results, bool doEDNS=false, bool doDNSSEC=false, bool tcpFallback=true)
 Gets resource record data of type RRT for the given domain name name. More...
 
const std::vector< NameServer > & NameServers () const
 Returns a const reference to the contained nameservers.
 
std::vector< NameServer > & NameServers ()
 Returns a mutable reference to the contained nameservers.
 

Detailed Description

Simple DNS resolver class.

Constructor & Destructor Documentation

◆ Resolver()

Dwm::Dns::Resolver::Resolver ( const std::string &  filename = "/etc/resolv.conf",
const std::string &  order = "files,dns" 
)

Construct with the given resolver configuration file and the preferred order of resolver sources (ala /etc/nssswitch.conf).

Member Function Documentation

◆ Get() [1/3]

bool Dwm::Dns::Resolver::Get ( const std::string &  name,
uint16_t  rrtype,
std::vector< ResourceRecord > &  results,
bool  doEDNS = false,
bool  doDNSSEC = false,
bool  tcpFallback = true 
)

Fetches resource records of type rrtype for the given domain name name.

Stores the records that were found in results and returns true on success. Returns false if no records were found. If doEDNS is true, we will include an OPT resource record in our query messages to the DNS server and use a packet size of 4K (4096 bytes) for UDP. If doDNSSEC is true, we will also ask the server to do DNSSEC processing. If tcpFallback is true, we will use TCP for our query if UDP fails.

◆ Get() [2/3]

template<typename RRT >
bool Dwm::Dns::Resolver::Get ( const std::string &  name,
std::vector< ResourceRecord > &  results,
bool  doEDNS = false,
bool  doDNSSEC = false,
bool  tcpFallback = true 
)
inline

Fetches resource records whose data type is RRT for the given domain name name.

Stores the records that were found in results and returns true on success. Returns false if no records were found. If doEDNS is true, we will include an OPT resource record in our query messages to the DNS server and use a packet size of 4K (4096 bytes) for UDP. If doDNSSEC is true, we will also ask the server to do DNSSEC processing. If tcpFallback is true, we will use TCP for our query if UDP fails.

◆ Get() [3/3]

template<typename RRT >
bool Dwm::Dns::Resolver::Get ( const std::string &  name,
std::vector< RRT > &  results,
bool  doEDNS = false,
bool  doDNSSEC = false,
bool  tcpFallback = true 
)
inline

Gets resource record data of type RRT for the given domain name name.

Stores the results in results and returns true on success. Returns false if no records were found. If doEDNS is true, we will include an OPT resource record in our query messages to the DNS server and use a packet size of 4K (4096 bytes) for UDP. If doDNSSEC is true, we will also ask the server to do DNSSEC processing. If tcpFallback is true, we will use TCP for our query if UDP fails.

◆ GetHostByAddr() [1/2]

bool Dwm::Dns::Resolver::GetHostByAddr ( const in6_addr &  addr,
std::vector< std::string > &  names 
)

Fetches the host names for the given IPv6 address addr.

Stores the results in names and returns true on success. Returns false if no host names were found.

◆ GetHostByAddr() [2/2]

bool Dwm::Dns::Resolver::GetHostByAddr ( const in_addr &  addr,
std::vector< std::string > &  names 
)

Fetches the host names for the given IPv4 address addr.

Stores the results in names and returns true on success. Returns false if no host names were found.

◆ GetHostByName()

bool Dwm::Dns::Resolver::GetHostByName ( const std::string &  name,
std::vector< in6_addr > &  in6Addrs,
std::vector< in_addr > &  inAddrs 
)

Fetches the IPv6 and IPv4 addresses for the given host name.

Stores the results in in6Addrs and inAddrs. Returns true if any addresses were found, false if none were found.


The documentation for this class was generated from the following file: