join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicTlsResolver< Protocol > Class Template Reference

basic DNS resolver over TLS socket (DNS over TLS). More...

#include <resolver.hpp>

Inheritance diagram for join::BasicTlsResolver< Protocol >:
Collaboration diagram for join::BasicTlsResolver< Protocol >:

Public Types

using Socket = typename Protocol::Socket
 
using UnderlyingSocket = typename Socket::UnderlyingSocket
 
using Endpoint = typename Protocol::Endpoint
 
- Public Types inherited from join::BasicDatagramResolver< Protocol >
using Socket = typename Protocol::Socket
 
using Endpoint = typename Protocol::Endpoint
 
using DnsNotify = std::function<void (const DnsPacket&)>
 notification callback definition.
 

Public Member Functions

 BasicTlsResolver (TlsContext ctx, const std::string &server={}, uint16_t port=Protocol::defaultPort, Reactor &reactor=ReactorThread::reactor())
 construct the DoT resolver instance.
 
 BasicTlsResolver (const BasicTlsResolver &other)=delete
 copy constructor.
 
BasicTlsResolveroperator= (const BasicTlsResolver &other)=delete
 copy assignment operator.
 
 BasicTlsResolver (BasicTlsResolver &&other)=delete
 move constructor.
 
BasicTlsResolveroperator= (BasicTlsResolver &&other)=delete
 move assignment operator.
 
virtual ~BasicTlsResolver () noexcept
 destroy instance.
 
- Public Member Functions inherited from join::BasicDatagramResolver< Protocol >
 BasicDatagramResolver (const std::string &server={}, uint16_t port=Protocol::defaultPort, Reactor &reactor=ReactorThread::reactor())
 
 BasicDatagramResolver (Socket &&socket, const std::string &server={}, uint16_t port=Protocol::defaultPort, Reactor &reactor=ReactorThread::reactor())
 construct the resolver instance.
 
 BasicDatagramResolver (const BasicDatagramResolver &other)=delete
 copy constructor.
 
BasicDatagramResolveroperator= (const BasicDatagramResolver &other)=delete
 copy assignment operator.
 
 BasicDatagramResolver (BasicDatagramResolver &&other)=delete
 move constructor.
 
BasicDatagramResolveroperator= (BasicDatagramResolver &&other)=delete
 move assignment operator.
 
virtual ~BasicDatagramResolver () noexcept
 destroy instance.
 
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.
 
- Public Member Functions inherited from join::EventHandler
 EventHandler ()=default
 create instance.
 
 EventHandler (const EventHandler &other)=default
 copy constructor.
 
EventHandleroperator= (const EventHandler &other)=default
 copy assignment operator.
 
 EventHandler (EventHandler &&other)=default
 move constructor.
 
EventHandleroperator= (EventHandler &&other)=default
 move assignment operator.
 
virtual ~EventHandler ()=default
 destroy instance.
 

Static Public Member Functions

static IpAddressList lookupAllAddress (const std::string &host, int family)=delete
 resolve host name using system name servers and return all IP addresses found.
 
static IpAddressList lookupAllAddress (const std::string &host)=delete
 resolve host name using system name servers and return all IP addresses found.
 
static IpAddress lookupAddress (const std::string &host, int family)=delete
 resolve host name using system name servers.
 
static IpAddress lookupAddress (const std::string &host)=delete
 resolve host name using system name servers.
 
static AliasList lookupAllName (const IpAddress &address)=delete
 resolve all host address.
 
static std::string lookupName (const IpAddress &address)=delete
 resolve host address.
 
static ServerList lookupAllNameServer (const std::string &host)=delete
 resolve all host name server.
 
static std::string lookupNameServer (const std::string &host)=delete
 resolve host name server.
 
static std::string lookupAuthority (const std::string &host)=delete
 resolve host start of authority name server.
 
static ExchangerList lookupAllMailExchanger (const std::string &host)=delete
 resolve all host mail exchanger.
 
static std::string lookupMailExchanger (const std::string &host)=delete
 resolve host mail exchanger.
 
- Static Public Member Functions inherited from join::BasicDatagramResolver< Protocol >
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.
 

Additional Inherited Members

- Public Attributes inherited from join::BasicDatagramResolver< Protocol >
DnsNotify onSuccess
 callback called when a lookup sequence succeed.
 
DnsNotify onFailure
 callback called when a lookup sequence failed.
 
- Protected Member Functions inherited from join::BasicDatagramResolver< Protocol >
int reconnect (const Endpoint &endpoint, std::chrono::milliseconds timeout=std::chrono::seconds(5))
 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 onReadable (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 Member Functions inherited from join::EventHandler
virtual void onEvent (int fd, uint32_t revents)
 method called when events are reported on handle.
 
virtual void onWriteable (int fd)
 method called when data are ready to be written on handle.
 
virtual void onError (int fd)
 method called when an error occurred on handle.
 
- Protected Attributes inherited from join::BasicDatagramResolver< Protocol >
DnsMessage _message
 DNS message codec.
 
Socket _socket
 underlying socket.
 
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 inherited from join::BasicDatagramResolver< Protocol >
static constexpr size_t _headerSize = 12
 DNS message header size.
 

Detailed Description

template<class Protocol>
class join::BasicTlsResolver< Protocol >

basic DNS resolver over TLS socket (DNS over TLS).

Member Typedef Documentation

◆ Endpoint

template<class Protocol >
using join::BasicTlsResolver< Protocol >::Endpoint = typename Protocol::Endpoint

◆ Socket

template<class Protocol >
using join::BasicTlsResolver< Protocol >::Socket = typename Protocol::Socket

◆ UnderlyingSocket

template<class Protocol >
using join::BasicTlsResolver< Protocol >::UnderlyingSocket = typename Socket::UnderlyingSocket

Constructor & Destructor Documentation

◆ BasicTlsResolver() [1/3]

template<class Protocol >
join::BasicTlsResolver< Protocol >::BasicTlsResolver ( TlsContext ctx,
const std::string & server = {},
uint16_t port = Protocol::defaultPort,
Reactor & reactor = ReactorThread::reactor () )
inlineexplicit

construct the DoT resolver instance.

Parameters
serverremote DNS server address.
portremote DNS server port.
reactorreactor instance.

◆ BasicTlsResolver() [2/3]

template<class Protocol >
join::BasicTlsResolver< Protocol >::BasicTlsResolver ( const BasicTlsResolver< Protocol > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ BasicTlsResolver() [3/3]

template<class Protocol >
join::BasicTlsResolver< Protocol >::BasicTlsResolver ( BasicTlsResolver< Protocol > && other)
delete

move constructor.

Parameters
otherother object to move.

◆ ~BasicTlsResolver()

template<class Protocol >
virtual join::BasicTlsResolver< Protocol >::~BasicTlsResolver ( )
inlinevirtualnoexcept

destroy instance.

Member Function Documentation

◆ lookupAddress() [1/2]

template<class Protocol >
static IpAddress join::BasicTlsResolver< Protocol >::lookupAddress ( const std::string & host)
staticdelete

resolve host name using system name servers.

Parameters
hosthost name to resolve.
Returns
the first resolved IP address found, wildcard address on error.

◆ lookupAddress() [2/2]

template<class Protocol >
static IpAddress join::BasicTlsResolver< Protocol >::lookupAddress ( const std::string & host,
int family )
staticdelete

resolve host name using system name servers.

Parameters
hosthost name to resolve.
familyaddress family.
Returns
the first resolved IP address found, wildcard address on error.

◆ lookupAllAddress() [1/2]

template<class Protocol >
static IpAddressList join::BasicTlsResolver< Protocol >::lookupAllAddress ( const std::string & host)
staticdelete

resolve host name using system name servers and return all IP addresses found.

Parameters
hosthost name to resolve.
Returns
the resolved IP address list, empty on error.

◆ lookupAllAddress() [2/2]

template<class Protocol >
static IpAddressList join::BasicTlsResolver< Protocol >::lookupAllAddress ( const std::string & host,
int family )
staticdelete

resolve host name using system name servers and return all IP addresses found.

Parameters
hosthost name to resolve.
familyaddress family.
Returns
the resolved IP address list, empty on error.

◆ lookupAllMailExchanger()

template<class Protocol >
static ExchangerList join::BasicTlsResolver< Protocol >::lookupAllMailExchanger ( const std::string & host)
staticdelete

resolve all host mail exchanger.

Parameters
hosthost name to resolve.
Returns
the resolved mail exchanger list.

◆ lookupAllName()

template<class Protocol >
static AliasList join::BasicTlsResolver< Protocol >::lookupAllName ( const IpAddress & address)
staticdelete

resolve all host address.

Parameters
addresshost address to resolve.
Returns
the resolved alias list.

◆ lookupAllNameServer()

template<class Protocol >
static ServerList join::BasicTlsResolver< Protocol >::lookupAllNameServer ( const std::string & host)
staticdelete

resolve all host name server.

Parameters
hosthost name to resolve.
Returns
the resolved name server list.

◆ lookupAuthority()

template<class Protocol >
static std::string join::BasicTlsResolver< Protocol >::lookupAuthority ( const std::string & host)
staticdelete

resolve host start of authority name server.

Parameters
hosthost name to resolve.
Returns
the start of authority name server.

◆ lookupMailExchanger()

template<class Protocol >
static std::string join::BasicTlsResolver< Protocol >::lookupMailExchanger ( const std::string & host)
staticdelete

resolve host mail exchanger.

Parameters
hosthost name to resolve.
Returns
the first resolved mail exchanger.

◆ lookupName()

template<class Protocol >
static std::string join::BasicTlsResolver< Protocol >::lookupName ( const IpAddress & address)
staticdelete

resolve host address.

Parameters
addresshost address to resolve.
Returns
the first resolved alias.

◆ lookupNameServer()

template<class Protocol >
static std::string join::BasicTlsResolver< Protocol >::lookupNameServer ( const std::string & host)
staticdelete

resolve host name server.

Parameters
hosthost name to resolve.
Returns
the first resolved name server.

◆ operator=() [1/2]

template<class Protocol >
BasicTlsResolver & join::BasicTlsResolver< Protocol >::operator= ( BasicTlsResolver< Protocol > && other)
delete

move assignment operator.

Parameters
otherother object to move.
Returns
a reference to the current object.

◆ operator=() [2/2]

template<class Protocol >
BasicTlsResolver & join::BasicTlsResolver< Protocol >::operator= ( const BasicTlsResolver< Protocol > & other)
delete

copy assignment operator.

Parameters
otherother object to copy.
Returns
a reference to the current object.

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