Monero
Loading...
Searching...
No Matches
tools::DNSResolver Class Reference

Provides high-level access to DNS resolution. More...

#include <dns_utils.h>

Collaboration diagram for tools::DNSResolver:

Public Member Functions

 ~DNSResolver ()
 takes care of freeing C pointers and such
std::vector< std::string > get_ipv4 (const std::string &url, bool &dnssec_available, bool &dnssec_valid)
 gets ipv4 addresses from DNS query of a URL
std::vector< std::string > get_ipv6 (const std::string &url, bool &dnssec_available, bool &dnssec_valid)
 gets ipv6 addresses from DNS query
std::vector< std::string > get_txt_record (const std::string &url, bool &dnssec_available, bool &dnssec_valid)
 gets all TXT records from a DNS query for the supplied URL; if no TXT record present returns an empty vector.
std::vector< std::string > get_tlsa_tcp_record (boost::string_ref url, boost::string_ref port, bool &dnssec_available, bool &dnssec_valid)
 gets all TLSA TCP records from a DNS query for the supplied URL; if no TLSA record present returns an empty vector.
std::string get_dns_format_from_oa_address (const std::string &oa_addr)
 Gets a DNS address from OpenAlias format.

Static Public Member Functions

static DNSResolverinstance ()
 Gets the singleton instance of DNSResolver.
static DNSResolver create ()
 Gets a new instance of DNSResolver.

Private Member Functions

 DNSResolver ()
 Constructs an instance of DNSResolver.
std::vector< std::string > get_record (const std::string &url, int record_type, boost::optional< std::string >(*reader)(const char *, size_t), bool &dnssec_available, bool &dnssec_valid)
 gets all records of a given type from a DNS query for the supplied URL; if no such record is present returns an empty vector.

Private Attributes

DNSResolverDatam_data

Detailed Description

Provides high-level access to DNS resolution.

This class is designed to provide a high-level abstraction to DNS resolution functionality, including access to TXT records and such. It will also handle DNSSEC validation of the results.

Constructor & Destructor Documentation

◆ DNSResolver()

tools::DNSResolver::DNSResolver ( )
private

Constructs an instance of DNSResolver.

Constructs a class instance and does setup stuff for the backend resolver.

◆ ~DNSResolver()

tools::DNSResolver::~DNSResolver ( )

takes care of freeing C pointers and such

Member Function Documentation

◆ create()

DNSResolver tools::DNSResolver::create ( )
static

Gets a new instance of DNSResolver.

Returns
returns a pointer to the new object

◆ get_dns_format_from_oa_address()

std::string tools::DNSResolver::get_dns_format_from_oa_address ( const std::string & oa_addr)

Gets a DNS address from OpenAlias format.

If the address looks good, but contains one @ symbol, replace that with a . e.g. donat.nosp@m.e@ge.nosp@m.tmone.nosp@m.ro.o.nosp@m.rg becomes donate.getmonero.org

Parameters
oa_addrOpenAlias address
Returns
dns_addr DNS address

◆ get_ipv4()

std::vector< std::string > tools::DNSResolver::get_ipv4 ( const std::string & url,
bool & dnssec_available,
bool & dnssec_valid )

gets ipv4 addresses from DNS query of a URL

returns a vector of all IPv4 "A" records for given URL. If no "A" records found, returns an empty vector.

Parameters
urlA string containing a URL to query for
dnssec_available
Returns
vector of strings containing ipv4 addresses

◆ get_ipv6()

std::vector< std::string > tools::DNSResolver::get_ipv6 ( const std::string & url,
bool & dnssec_available,
bool & dnssec_valid )

gets ipv6 addresses from DNS query

returns a vector of all IPv6 "A" records for given URL. If no "A" records found, returns an empty vector.

Parameters
urlA string containing a URL to query for
Returns
vector of strings containing ipv6 addresses

◆ get_record()

std::vector< std::string > tools::DNSResolver::get_record ( const std::string & url,
int record_type,
boost::optional< std::string >(* reader )(const char *, size_t),
bool & dnssec_available,
bool & dnssec_valid )
private

gets all records of a given type from a DNS query for the supplied URL; if no such record is present returns an empty vector.

Parameters
urlA string containing a URL to query for
record_typethe record type to retrieve (DNS_TYPE_A, etc)
readera function that converts a record data to a string
Returns
A vector of strings containing the requested record; or an empty vector

◆ get_tlsa_tcp_record()

std::vector< std::string > tools::DNSResolver::get_tlsa_tcp_record ( boost::string_ref url,
boost::string_ref port,
bool & dnssec_available,
bool & dnssec_valid )

gets all TLSA TCP records from a DNS query for the supplied URL; if no TLSA record present returns an empty vector.

Parameters
urlA string containing a URL to query for
portThe service port number (as string) to query
Returns
A vector of strings containing all TLSA records; or an empty vector

◆ get_txt_record()

std::vector< std::string > tools::DNSResolver::get_txt_record ( const std::string & url,
bool & dnssec_available,
bool & dnssec_valid )

gets all TXT records from a DNS query for the supplied URL; if no TXT record present returns an empty vector.

Parameters
urlA string containing a URL to query for
Returns
A vector of strings containing a TXT record; or an empty vector

◆ instance()

DNSResolver & tools::DNSResolver::instance ( )
static

Gets the singleton instance of DNSResolver.

Returns
returns a pointer to the singleton

Member Data Documentation

◆ m_data

DNSResolverData* tools::DNSResolver::m_data
private

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