Encapsulates a resolver 'hosts' file, such as /etc/hosts. More...
#include <DwmDnsEtcHosts.hh>
Public Member Functions | |
| EtcHosts (const std::string &hostsFile="/etc/hosts") | |
| Construct from a path to the hosts file. More... | |
| bool | Get (const std::string &name, uint16_t rrtype, std::vector< ResourceRecord > &results) |
Gets DNS resource records of type rrtype for the given host name. More... | |
| void | Add (const std::string &ipAddr, const std::string &name) |
Adds an entry for the given IP address ipAddr named name. More... | |
Encapsulates a resolver 'hosts' file, such as /etc/hosts.
| Dwm::Dns::EtcHosts::EtcHosts | ( | const std::string & | hostsFile = "/etc/hosts" | ) |
Construct from a path to the hosts file.
This will parse the entries from the given hostsFile and populate the encapsulated maps.
| void Dwm::Dns::EtcHosts::Add | ( | const std::string & | ipAddr, |
| const std::string & | name | ||
| ) |
Adds an entry for the given IP address ipAddr named name.
This is only used by the parser and not normally called from application code. Note that we never attempt to write to the hosts file, so an entry added vias this method is never saved to the hosts file.
| bool Dwm::Dns::EtcHosts::Get | ( | const std::string & | name, |
| uint16_t | rrtype, | ||
| std::vector< ResourceRecord > & | results | ||
| ) |
Gets DNS resource records of type rrtype for the given host name.
Places the resource records in results and returns true on success. Returns false on failure.