Resolves hostnames into IP addresses using a custom poller. More...
#include <resolver.hpp>
Public Member Functions | |
TResolver (TPoller &poller, EDNSType defaultType=EDNSType::A) | |
Constructs a TResolver using the default resolv configuration. | |
TResolver (const TResolvConf &conf, TPoller &poller, EDNSType defaultType=EDNSType::A) | |
Constructs a TResolver with a specified DNS configuration. | |
TResolver (TAddress dnsAddr, TPoller &poller, EDNSType defaultType=EDNSType::A) | |
Constructs a TResolver using a specific DNS address. | |
TFuture< std::vector< TAddress > > | Resolve (const std::string &hostname, EDNSType type=EDNSType::DEFAULT) |
Resolves a hostname to a list of addresses. | |
Resolves hostnames into IP addresses using a custom poller.
The TResolver class provides DNS resolution functionality by sending DNS queries to a nameserver. It supports different DNS record types as specified by EDNSType. Internally, it uses a polling mechanism (provided by the template parameter) for asynchronous operations.
TPoller | The type of the poller used to manage asynchronous operations. |
NNet::TResolver< TPoller >::TResolver | ( | TPoller & | poller, |
EDNSType | defaultType = EDNSType::A ) |
Constructs a TResolver using the default resolv configuration.
The resolver uses DNS nameservers from the default configuration file or as determined by the system.
poller | Reference to a poller used for asynchronous operations. |
defaultType | The default DNS record type to use if none is specified in a request. |
NNet::TResolver< TPoller >::TResolver | ( | const TResolvConf & | conf, |
TPoller & | poller, | ||
EDNSType | defaultType = EDNSType::A ) |
Constructs a TResolver with a specified DNS configuration.
This constructor initializes the resolver with nameservers from a given TResolvConf object.
conf | A TResolvConf object containing DNS configuration. |
poller | Reference to a poller for asynchronous operations. |
defaultType | The default DNS record type to use for resolution. |
NNet::TResolver< TPoller >::TResolver | ( | TAddress | dnsAddr, |
TPoller & | poller, | ||
EDNSType | defaultType = EDNSType::A ) |
Constructs a TResolver using a specific DNS address.
This variant allows specifying a single DNS nameserver for resolution.
dnsAddr | The address of the DNS server. |
poller | Reference to a poller used for asynchronous operations. |
defaultType | The default DNS record type for resolution. |
TFuture< std::vector< TAddress > > NNet::TResolver< TPoller >::Resolve | ( | const std::string & | hostname, |
EDNSType | type = EDNSType::DEFAULT ) |
Resolves a hostname to a list of addresses.
Sends a DNS query for the specified hostname. If the request type is set to EDNSType::DEFAULT, the default DNS record type (specified in the constructor) is used.
hostname | The name to be resolved. |
type | The DNS record type to query. If EDNSType::DEFAULT is specified, the default type provided to the constructor is used. |