CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dns::Resolver Class Referenceabstract

#include <dns.h>

Inheritance diagram for dns::Resolver:
Collaboration diagram for dns::Resolver:

Public Member Functions

 Resolver (const bool ipv4_only, const unsigned retries, const unsigned timeout_ms)
 
virtual ~Resolver ()
 
virtual bool SetResolvers (const std::vector< std::string > &resolvers)=0
 
virtual bool SetSearchDomains (const std::vector< std::string > &domains)=0
 
virtual void SetSystemResolvers ()=0
 
virtual void SetSystemSearchDomains ()=0
 
Host Resolve (const std::string &name)
 
void ResolveMany (const std::vector< std::string > &names, std::vector< Host > *hosts)
 
const std::vector< std::string > & domains () const
 
bool ipv4_only () const
 
const std::vector< std::string > & resolvers () const
 
unsigned retries () const
 
unsigned timeout_ms () const
 
void set_throttle (const unsigned throttle)
 
unsigned throttle () const
 
void set_min_ttl (unsigned seconds)
 
unsigned min_ttl () const
 
void set_max_ttl (unsigned seconds)
 
unsigned max_ttl () const
 

Static Public Attributes

static const unsigned kDefaultMinTtl = 60
 
static const unsigned kDefaultMaxTtl = 84600
 

Protected Member Functions

virtual void DoResolve (const std::vector< std::string > &names, const std::vector< bool > &skip, std::vector< std::vector< std::string > > *ipv4_addresses, std::vector< std::vector< std::string > > *ipv6_addresses, std::vector< Failures > *failures, std::vector< unsigned > *ttls, std::vector< std::string > *fqdns)=0
 
bool IsIpv4Address (const std::string &address)
 
bool IsIpv6Address (const std::string &address)
 

Protected Attributes

std::vector< std::string > domains_
 
bool ipv4_only_
 
std::vector< std::string > resolvers_
 
unsigned retries_
 
unsigned timeout_ms_
 
unsigned throttle_
 
unsigned min_ttl_
 
unsigned max_ttl_
 
Prng prng_
 

Additional Inherited Members

- Private Member Functions inherited from SingleCopy
 SingleCopy ()
 

Detailed Description

Abstract interface of a name resolver. Returns a Host object upon successful name resolution. Also provides a vector interface to resolve multiple names in parallel. Can be configured with DNS servers, with a timeout, and whether to use IPv4 only or not.

Definition at line 172 of file dns.h.

Constructor & Destructor Documentation

dns::Resolver::Resolver ( const bool  ipv4_only,
const unsigned  retries,
const unsigned  timeout_ms 
)

Definition at line 339 of file dns.cc.

Here is the call graph for this function:

virtual dns::Resolver::~Resolver ( )
inlinevirtual

Definition at line 187 of file dns.h.

Member Function Documentation

const std::vector<std::string>& dns::Resolver::domains ( ) const
inline
virtual void dns::Resolver::DoResolve ( const std::vector< std::string > &  names,
const std::vector< bool > &  skip,
std::vector< std::vector< std::string > > *  ipv4_addresses,
std::vector< std::vector< std::string > > *  ipv6_addresses,
std::vector< Failures > *  failures,
std::vector< unsigned > *  ttls,
std::vector< std::string > *  fqdns 
)
protectedpure virtual

Takes host names and returns the resolved lists of A and AAAA records in the same order. To keep it simple, returns only a single TTL per host, the lower value of both record types A/AAAA. The output vectors have the same size as the input vector names. Names that are handled by the base class are marked with skip[i] set to true. The input names are completed to fully qualified domain names.

Implemented in dns::NormalResolver, dns::HostfileResolver, and dns::CaresResolver.

Referenced by ResolveMany().

Here is the caller graph for this function:

bool dns::Resolver::ipv4_only ( ) const
inline

Definition at line 201 of file dns.h.

Referenced by dns::CaresResolver::DoResolve(), and dns::HostfileResolver::ParseHostFile().

Here is the caller graph for this function:

bool dns::Resolver::IsIpv4Address ( const std::string &  address)
protected

Basic input validation to ensure that this could syntactically represent a valid IPv4 address.

Definition at line 308 of file dns.cc.

Referenced by dns::HostfileResolver::ParseHostFile(), and ResolveMany().

Here is the call graph for this function:

Here is the caller graph for this function:

bool dns::Resolver::IsIpv6Address ( const std::string &  address)
protected

Basic input validation to ensure that this could syntactically represent a valid IPv6 address.

Definition at line 332 of file dns.cc.

Referenced by ResolveMany().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned dns::Resolver::max_ttl ( ) const
inline

Definition at line 210 of file dns.h.

Referenced by download::DownloadManager::Clone().

Here is the caller graph for this function:

unsigned dns::Resolver::min_ttl ( ) const
inline

Definition at line 208 of file dns.h.

Referenced by download::DownloadManager::Clone(), and download::DownloadManager::SetProxyChain().

Here is the caller graph for this function:

Host dns::Resolver::Resolve ( const std::string &  name)

Wrapper around the vector interface.

Definition at line 357 of file dns.cc.

Here is the call graph for this function:

void dns::Resolver::ResolveMany ( const std::vector< std::string > &  names,
std::vector< Host > *  hosts 
)

Calls the overwritten concrete resolver, verifies the sanity of the returned addresses and constructs the Host objects in the same order as the names.

Definition at line 370 of file dns.cc.

Referenced by Resolve(), and download::DownloadManager::SetProxyChain().

Here is the call graph for this function:

Here is the caller graph for this function:

const std::vector<std::string>& dns::Resolver::resolvers ( ) const
inline

Definition at line 202 of file dns.h.

Referenced by dns::NormalResolver::Create(), and dns::CaresResolver::SetResolvers().

Here is the caller graph for this function:

unsigned dns::Resolver::retries ( ) const
inline

Definition at line 203 of file dns.h.

Referenced by download::DownloadManager::Clone(), dns::CaresResolver::Create(), dns::NormalResolver::Create(), and download::DownloadManager::SetDnsParameters().

Here is the caller graph for this function:

void dns::Resolver::set_max_ttl ( unsigned  seconds)
inline

Definition at line 209 of file dns.h.

Referenced by download::DownloadManager::SetDnsTtlLimits().

Here is the caller graph for this function:

void dns::Resolver::set_min_ttl ( unsigned  seconds)
inline

Definition at line 207 of file dns.h.

Referenced by download::DownloadManager::SetDnsTtlLimits().

Here is the caller graph for this function:

void dns::Resolver::set_throttle ( const unsigned  throttle)
inline

Definition at line 205 of file dns.h.

Referenced by download::DownloadManager::SetMaxIpaddrPerProxy().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool dns::Resolver::SetResolvers ( const std::vector< std::string > &  resolvers)
pure virtual

A list of new resolvers in the form <IP address>="">[:port].

Implemented in dns::NormalResolver, dns::HostfileResolver, and dns::CaresResolver.

virtual bool dns::Resolver::SetSearchDomains ( const std::vector< std::string > &  domains)
pure virtual
virtual void dns::Resolver::SetSystemResolvers ( )
pure virtual
virtual void dns::Resolver::SetSystemSearchDomains ( )
pure virtual
unsigned dns::Resolver::throttle ( ) const
inline

Definition at line 206 of file dns.h.

Referenced by download::DownloadManager::Clone(), and set_throttle().

Here is the caller graph for this function:

unsigned dns::Resolver::timeout_ms ( ) const
inline

Member Data Documentation

std::vector<std::string> dns::Resolver::domains_
protected
bool dns::Resolver::ipv4_only_
protected

Do not try to get AAAA records if true.

Definition at line 239 of file dns.h.

Referenced by ipv4_only().

const unsigned dns::Resolver::kDefaultMaxTtl = 84600
static

Cut off very large TTLs by default to 1 day.

Definition at line 182 of file dns.h.

Referenced by MountPoint::SetupDnsTuning().

const unsigned dns::Resolver::kDefaultMinTtl = 60
static

Enlarge very small TTLs by default to 1 minute.

Definition at line 177 of file dns.h.

Referenced by MountPoint::SetupDnsTuning().

unsigned dns::Resolver::max_ttl_
protected

Effective maximum TTL, which by default is kDefaultMaxTtl

Definition at line 272 of file dns.h.

Referenced by max_ttl(), ResolveMany(), and set_max_ttl().

unsigned dns::Resolver::min_ttl_
protected

Effective minimum TTL, which by default is kDefaultMinTtl

Definition at line 267 of file dns.h.

Referenced by dns::HostfileResolver::DoResolve(), min_ttl(), ResolveMany(), and set_min_ttl().

Prng dns::Resolver::prng_
protected

Required for picking IP addresses in throttle_

Definition at line 277 of file dns.h.

Referenced by ResolveMany(), and Resolver().

std::vector<std::string> dns::Resolver::resolvers_
protected

Currently used resolver list in the form <ip address>="">:<port>

Definition at line 244 of file dns.h.

Referenced by dns::CaresResolver::Create(), dns::NormalResolver::Create(), resolvers(), and dns::CaresResolver::SetResolvers().

unsigned dns::Resolver::retries_
protected

1 + retries_ attempts to unresponsive servers, each attempt bounded by timeout_ms_

Definition at line 250 of file dns.h.

Referenced by dns::NormalResolver::Create(), and retries().

unsigned dns::Resolver::throttle_
protected

Limit number of resolved IP addresses. If throttle_ is 0 it has no effect. Otherwise, if more than thottle_ IPs are registered for a host, only throttle_ randomly picked IPs are returned.

Definition at line 262 of file dns.h.

Referenced by ResolveMany(), set_throttle(), and throttle().

unsigned dns::Resolver::timeout_ms_
protected

Timeout in milliseconds for DNS queries. Zero means no timeout.

Definition at line 255 of file dns.h.

Referenced by dns::NormalResolver::Create(), and timeout_ms().


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