|
join 1.0
lightweight network framework library
|
basic DNS resolver over datagram socket. More...
#include <resolver.hpp>


Classes | |
| struct | PendingRequest |
| pending synchronous request. More... | |
Public Types | |
| using | Socket = typename Protocol::Socket |
| using | Endpoint = typename Protocol::Endpoint |
| using | State = typename Socket::State |
| using | DnsNotify = std::function<void (const DnsPacket&)> |
| notification callback definition. | |
Public Member Functions | |
| BasicDatagramResolver (const std::string &server={}, uint16_t port=Protocol::defaultPort, Reactor *reactor=nullptr) | |
| construct the resolver instance. | |
| BasicDatagramResolver (const BasicDatagramResolver &other)=delete | |
| copy constructor. | |
| BasicDatagramResolver & | operator= (const BasicDatagramResolver &other)=delete |
| copy assignment operator. | |
| BasicDatagramResolver (BasicDatagramResolver &&other)=delete | |
| move constructor. | |
| BasicDatagramResolver & | operator= (BasicDatagramResolver &&other)=delete |
| move assignment operator. | |
| virtual | ~BasicDatagramResolver () noexcept=default |
| destroy instance. | |
| virtual int | connect (const Endpoint &endpoint) override |
| make a connection to the given endpoint. | |
| virtual int | disconnect () override |
| shutdown the connection. | |
| IpAddressList | resolveAllAddress (const std::string &host, int family, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host name and return all IP addresses found. | |
| IpAddressList | resolveAllAddress (const std::string &host, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host name and return all IP addresses found. | |
| IpAddress | resolveAddress (const std::string &host, int family, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host name using address family. | |
| IpAddress | resolveAddress (const std::string &host, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host name. | |
| AliasList | resolveAllName (const IpAddress &address, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve all host address. | |
| std::string | resolveName (const IpAddress &address, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host address. | |
| ServerList | resolveAllNameServer (const std::string &host, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve all host name server. | |
| std::string | resolveNameServer (const std::string &host, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host name server. | |
| std::string | resolveAuthority (const std::string &host, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host start of authority name server. | |
| ExchangerList | resolveAllMailExchanger (const std::string &host, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve all host mail exchanger. | |
| std::string | resolveMailExchanger (const std::string &host, std::chrono::milliseconds timeout=std::chrono::seconds(5)) |
| resolve host mail exchanger. | |
Static Public Member Functions | |
| static IpAddressList | lookupAllAddress (const std::string &host, int family) |
| resolve host name using system name servers and return all IP addresses found. | |
| static IpAddressList | lookupAllAddress (const std::string &host) |
| resolve host name using system name servers and return all IP addresses found. | |
| static IpAddress | lookupAddress (const std::string &host, int family) |
| resolve host name using system name servers. | |
| static IpAddress | lookupAddress (const std::string &host) |
| resolve host name using system name servers. | |
| static AliasList | lookupAllName (const IpAddress &address) |
| resolve all host address. | |
| static std::string | lookupName (const IpAddress &address) |
| resolve host address. | |
| static ServerList | lookupAllNameServer (const std::string &host) |
| resolve all host name server. | |
| static std::string | lookupNameServer (const std::string &host) |
| resolve host name server. | |
| static std::string | lookupAuthority (const std::string &host) |
| resolve host start of authority name server. | |
| static ExchangerList | lookupAllMailExchanger (const std::string &host) |
| resolve all host mail exchanger. | |
| static std::string | lookupMailExchanger (const std::string &host) |
| resolve host mail exchanger. | |
| static IpAddressList | nameServers () noexcept |
| get IP address of the currently configured name servers. | |
| static uint16_t | resolveService (const std::string &service) noexcept |
| resolve service name. | |
Public Attributes | |
| DnsNotify | _onSuccess |
| callback called when a lookup sequence succeed. | |
| DnsNotify | _onFailure |
| callback called when a lookup sequence failed. | |
Protected Member Functions | |
| bool | needReconnection () noexcept |
| check if client must reconnect. | |
| virtual int | reconnect (const Endpoint &endpoint, std::chrono::milliseconds timeout) |
| reconnect to the remote DNS server. | |
| int | query (DnsPacket &packet, std::chrono::milliseconds timeout) |
| serialize and send a DNS query, waiting for a response. | |
| void | onReceive (int fd) override final |
| method called when data are ready to be read on handle. | |
| void | onClose (int fd) override final |
| method called when handle is closed. | |
| void | notify (const DnsNotify &func, const DnsPacket &packet) const noexcept |
| safe way to notify DNS events. | |
Protected Attributes | |
| DnsMessage | _message |
| DNS message codec. | |
| std::string | _server |
| remote DNS server. | |
| uint16_t | _port |
| remote DNS server port. | |
| Reactor * | _reactor |
| event loop reactor. | |
| std::unique_ptr< char[]> | _buffer |
| reception buffer. | |
| std::unordered_map< uint16_t, std::unique_ptr< PendingRequest > > | _pending |
| synchronous requests indexed by sequence number. | |
| Mutex | _syncMutex |
| protection mutex. | |
Static Protected Attributes | |
| static constexpr size_t | _headerSize = 12 |
| DNS message header size. | |
basic DNS resolver over datagram socket.
| using join::BasicDatagramResolver< Protocol >::DnsNotify = std::function<void (const DnsPacket&)> |
notification callback definition.
| using join::BasicDatagramResolver< Protocol >::Endpoint = typename Protocol::Endpoint |
| using join::BasicDatagramResolver< Protocol >::Socket = typename Protocol::Socket |
| using join::BasicDatagramResolver< Protocol >::State = typename Socket::State |
|
inlineexplicit |
construct the resolver instance.
| server | remote DNS server hostname or IP address. |
| port | remote DNS server port. |
| reactor | reactor instance. |
|
delete |
copy constructor.
| other | other object to copy. |
|
delete |
move constructor.
| other | other object to move. |
|
virtualdefaultnoexcept |
destroy instance.
|
inlineoverridevirtual |
make a connection to the given endpoint.
| endpoint | endpoint to connect to. |
Reimplemented in join::BasicTlsResolver< Protocol >.
|
inlineoverridevirtual |
shutdown the connection.
|
inlinestatic |
resolve host name using system name servers.
| host | host name to resolve. |
|
inlinestatic |
resolve host name using system name servers.
| host | host name to resolve. |
| family | address family. |
|
inlinestatic |
resolve host name using system name servers and return all IP addresses found.
| host | host name to resolve. |
|
inlinestatic |
resolve host name using system name servers and return all IP addresses found.
| host | host name to resolve. |
| family | address family. |
|
inlinestatic |
resolve all host mail exchanger.
| host | host name to resolve. |
|
inlinestatic |
resolve all host address.
| address | host address to resolve. |
|
inlinestatic |
resolve all host name server.
| host | host name to resolve. |
|
inlinestatic |
resolve host start of authority name server.
| host | host name to resolve. |
|
inlinestatic |
resolve host mail exchanger.
| host | host name to resolve. |
|
inlinestatic |
resolve host address.
| address | host address to resolve. |
|
inlinestatic |
resolve host name server.
| host | host name to resolve. |
|
inlinestaticnoexcept |
get IP address of the currently configured name servers.
|
inlineprotectednoexcept |
check if client must reconnect.
|
inlineprotectednoexcept |
safe way to notify DNS events.
| func | function to call. |
| packet | DNS packet. |
|
inlinefinaloverrideprotected |
method called when handle is closed.
| fd | file descriptor. |
|
inlinefinaloverrideprotected |
method called when data are ready to be read on handle.
| fd | file descriptor. |
|
delete |
move assignment operator.
| other | other object to move. |
|
delete |
copy assignment operator.
| other | other object to copy. |
|
inlineprotected |
serialize and send a DNS query, waiting for a response.
| packet | DNS packet to send, filled with the response on success. |
| timeout | query timeout. |
|
inlineprotectedvirtual |
reconnect to the remote DNS server.
| endpoint | endpoint to connect to. |
| timeout | timeout in milliseconds. |
|
inline |
resolve host name using address family.
| host | host name to resolve. |
| family | address family. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve host name.
| host | host name to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve host name and return all IP addresses found.
| host | host name to resolve. |
| family | address family. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve host name and return all IP addresses found.
| host | host name to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve all host mail exchanger.
| host | host name to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve all host address.
| address | host address to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve all host name server.
| host | host name to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve host start of authority name server.
| host | host name to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve host mail exchanger.
| host | host name to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve host address.
| address | host address to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inline |
resolve host name server.
| host | host name to resolve. |
| timeout | timeout in milliseconds (default: 5000). |
|
inlinestaticnoexcept |
resolve service name.
| service | service name to resolve (ex. "http", "ftp", "ssh" etc...). |
|
protected |
reception buffer.
|
staticconstexprprotected |
DNS message header size.
|
protected |
DNS message codec.
| DnsNotify join::BasicDatagramResolver< Protocol >::_onFailure |
callback called when a lookup sequence failed.
| DnsNotify join::BasicDatagramResolver< Protocol >::_onSuccess |
callback called when a lookup sequence succeed.
|
protected |
synchronous requests indexed by sequence number.
|
protected |
remote DNS server port.
|
protected |
event loop reactor.
|
protected |
remote DNS server.
|
protected |
protection mutex.