CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dns::HostfileResolver Class Reference

#include <dns.h>

Inheritance diagram for dns::HostfileResolver:
Collaboration diagram for dns::HostfileResolver:

Classes

struct  HostEntry
 

Public Member Functions

virtual ~HostfileResolver ()
 
virtual bool SetResolvers (const std::vector< std::string > &resolvers)
 
virtual bool SetSearchDomains (const std::vector< std::string > &domains)
 
virtual void SetSystemResolvers ()
 
virtual void SetSystemSearchDomains ()
 
- Public Member Functions inherited from dns::Resolver
 Resolver (const bool ipv4_only, const unsigned retries, const unsigned timeout_ms)
 
virtual ~Resolver ()
 
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 Member Functions

static HostfileResolverCreate (const std::string &path, bool ipv4_only)
 

Protected Member Functions

 HostfileResolver (const bool ipv4_only)
 
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)
 
- Protected Member Functions inherited from dns::Resolver
bool IsIpv4Address (const std::string &address)
 
bool IsIpv6Address (const std::string &address)
 

Private Member Functions

void ParseHostFile ()
 

Private Attributes

std::map< std::string, HostEntryhost_map_
 
FILE * fhosts_
 

Static Private Attributes

static const int kIpMaxLength = 45
 
static const int kHostnameMaxLength = 253
 

Friends

class NormalResolver
 

Additional Inherited Members

- Static Public Attributes inherited from dns::Resolver
static const unsigned kDefaultMinTtl = 60
 
static const unsigned kDefaultMaxTtl = 84600
 
- Protected Attributes inherited from dns::Resolver
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_
 

Detailed Description

Resolves against static name information like in /etc/hosts. Setting resolver addresses is a no-op for this resolver. Search domains are not automatically found but need to be set. Not the most efficient implementation but in the context of cvmfs should be called at most every 5 minutes.

Definition at line 333 of file dns.h.

Constructor & Destructor Documentation

dns::HostfileResolver::~HostfileResolver ( )
virtual

Definition at line 1143 of file dns.cc.

dns::HostfileResolver::HostfileResolver ( const bool  ipv4_only)
explicitprotected

Definition at line 1137 of file dns.cc.

Referenced by Create().

Here is the caller graph for this function:

Member Function Documentation

HostfileResolver * dns::HostfileResolver::Create ( const std::string &  path,
bool  ipv4_only 
)
static

Opens a file descriptor to the host file that stays open until destruction. If no path is given, the HOST_ALIASES environment variable is evaluated followed by /etc/hosts.

Definition at line 1041 of file dns.cc.

Referenced by dns::NormalResolver::Create().

Here is the call graph for this function:

Here is the caller graph for this function:

void dns::HostfileResolver::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 
)
protectedvirtual

Creates a fresh reverse lookup map

Implements dns::Resolver.

Definition at line 1084 of file dns.cc.

Referenced by dns::NormalResolver::DoResolve().

Here is the call graph for this function:

Here is the caller graph for this function:

void dns::HostfileResolver::ParseHostFile ( )
private

TODO: this should be only necessary when the modification timestamp changed.

Definition at line 1152 of file dns.cc.

Referenced by DoResolve().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool dns::HostfileResolver::SetResolvers ( const std::vector< std::string > &  resolvers)
inlinevirtual

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

Implements dns::Resolver.

Definition at line 339 of file dns.h.

bool dns::HostfileResolver::SetSearchDomains ( const std::vector< std::string > &  domains)
virtual

Implements dns::Resolver.

Definition at line 1240 of file dns.cc.

Referenced by dns::NormalResolver::Create(), dns::NormalResolver::SetSearchDomains(), and dns::NormalResolver::SetSystemSearchDomains().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void dns::HostfileResolver::SetSystemResolvers ( )
inlinevirtual

Implements dns::Resolver.

Definition at line 343 of file dns.h.

void dns::HostfileResolver::SetSystemSearchDomains ( )
virtual

Implements dns::Resolver.

Definition at line 1246 of file dns.cc.

Friends And Related Function Documentation

friend class NormalResolver
friend

Definition at line 334 of file dns.h.

Member Data Documentation

FILE* dns::HostfileResolver::fhosts_
private

Open the file descriptor when the resolver is constructed and only release on destruction. Thereby we can be relatively sure to not see I/O errors once constructed.

Definition at line 375 of file dns.h.

Referenced by Create(), ParseHostFile(), and ~HostfileResolver().

std::map<std::string, HostEntry> dns::HostfileResolver::host_map_
private

Host names to lists of IPv4 and IPv6 addresses. Reverse lookup in the hosts file.

Definition at line 368 of file dns.h.

Referenced by DoResolve(), and ParseHostFile().

const int dns::HostfileResolver::kHostnameMaxLength = 253
staticprivate

Definition at line 362 of file dns.h.

Referenced by ParseHostFile().

const int dns::HostfileResolver::kIpMaxLength = 45
staticprivate

Definition at line 361 of file dns.h.

Referenced by ParseHostFile().


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