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

#include <dns.h>

Public Member Functions

 Host ()
 
 Host (const Host &other)
 
Hostoperator= (const Host &other)
 
bool IsEquivalent (const Host &other) const
 
bool IsExpired () const
 
bool IsValid () const
 
time_t deadline () const
 
int64_t id () const
 
bool HasIpv4 () const
 
bool HasIpv6 () const
 
const std::set< std::string > & ipv4_addresses () const
 
const std::set< std::string > & ipv6_addresses () const
 
const std::set< std::string > & ViewBestAddresses (IpPreference preference) const
 
const std::string & name () const
 
Failures status () const
 

Static Public Member Functions

static Host ExtendDeadline (const Host &original, unsigned seconds_from_now)
 

Private Member Functions

 FRIEND_TEST (T_Dns, HostEquivalent)
 
 FRIEND_TEST (T_Dns, HostExpired)
 
 FRIEND_TEST (T_Dns, HostValid)
 
 FRIEND_TEST (T_Dns, HostExtendDeadline)
 
 FRIEND_TEST (T_Dns, HostBestAddresses)
 
void CopyFrom (const Host &other)
 

Private Attributes

time_t deadline_
 
int64_t id_
 
std::set< std::string > ipv4_addresses_
 
std::set< std::string > ipv6_addresses_
 
std::string name_
 
Failures status_
 

Static Private Attributes

static atomic_int64 global_id_ = 0
 

Friends

class Resolver
 

Detailed Description

Stores the resolved IPv4 and IPv6 addresses of a host name including their time to live. Data in these objects are immutable. They are created by a a Resolver. Once the TTL has expired, they become invalid and a new Host object should be fetched from a resolver.

A host object can be copied into a new object with an extended deadline. This is useful if an attempt to resolve a name fails where it previously succeeded. In this case, the extended deadline can be used to delay another name resolution attempt for some grace period.

For successful name resolution, the name is the fully qualified domain name, even if a short name was given to the resolver.

Definition at line 90 of file dns.h.

Constructor & Destructor Documentation

dns::Host::Host ( )

All fields except the unique id_ are set by the resolver. Host objects can be copied around but only the resolver can create valid, new objects.

Definition at line 243 of file dns.cc.

dns::Host::Host ( const Host other)

Definition at line 251 of file dns.cc.

Here is the call graph for this function:

Member Function Documentation

void dns::Host::CopyFrom ( const Host other)
private

Definition at line 217 of file dns.cc.

Referenced by Host(), and operator=().

Here is the caller graph for this function:

time_t dns::Host::deadline ( ) const
inline

Definition at line 107 of file dns.h.

Host dns::Host::ExtendDeadline ( const Host original,
unsigned  seconds_from_now 
)
static

Creates a copy of the original host with a new ID and sets a new dealine given in seconds from the current time.

Definition at line 231 of file dns.cc.

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

Here is the caller graph for this function:

dns::Host::FRIEND_TEST ( T_Dns  ,
HostEquivalent   
)
private
dns::Host::FRIEND_TEST ( T_Dns  ,
HostExpired   
)
private
dns::Host::FRIEND_TEST ( T_Dns  ,
HostValid   
)
private
dns::Host::FRIEND_TEST ( T_Dns  ,
HostExtendDeadline   
)
private
dns::Host::FRIEND_TEST ( T_Dns  ,
HostBestAddresses   
)
private
bool dns::Host::HasIpv4 ( ) const
inline

Definition at line 109 of file dns.h.

bool dns::Host::HasIpv6 ( ) const
inline

Definition at line 110 of file dns.h.

int64_t dns::Host::id ( ) const
inline

Definition at line 108 of file dns.h.

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

Here is the caller graph for this function:

const std::set<std::string>& dns::Host::ipv4_addresses ( ) const
inline

Definition at line 111 of file dns.h.

Referenced by s3fanout::S3FanoutManager::InitializeDnsSettings().

Here is the caller graph for this function:

const std::set<std::string>& dns::Host::ipv6_addresses ( ) const
inline

Definition at line 114 of file dns.h.

bool dns::Host::IsEquivalent ( const Host other) const

Compares the name and the resolved addresses independent of deadlines. Used to decide if the current proxy list needs to be changed after re-resolving a host name.

Definition at line 269 of file dns.cc.

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

Here is the caller graph for this function:

bool dns::Host::IsExpired ( ) const

Compares the TTL from a provious call to time() with the current time.

Definition at line 280 of file dns.cc.

Referenced by IsValid(), and download::DownloadManager::ValidateProxyIpsUnlocked().

Here is the call graph for this function:

Here is the caller graph for this function:

bool dns::Host::IsValid ( ) const

A host object is valid after it has been successfully resolved and until the DNS ttl expires. Successful name resolution means that there is at least one IP address.

Definition at line 292 of file dns.cc.

Here is the call graph for this function:

const std::string& dns::Host::name ( ) const
inline

Definition at line 118 of file dns.h.

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

Here is the caller graph for this function:

Host & dns::Host::operator= ( const Host other)

Definition at line 256 of file dns.cc.

Here is the call graph for this function:

Failures dns::Host::status ( ) const
inline

Definition at line 119 of file dns.h.

Referenced by download::DownloadManager::SetUrlOptions(), and download::DownloadManager::ValidateProxyIpsUnlocked().

Here is the caller graph for this function:

const set< string > & dns::Host::ViewBestAddresses ( IpPreference  preference) const

Definition at line 205 of file dns.cc.

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

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class Resolver
friend

Definition at line 96 of file dns.h.

Member Data Documentation

time_t dns::Host::deadline_
private

When the name resolution becomes outdated, in UTC seconds since UNIX epoch. Once the deadline is passed, IsValid returns false.

Definition at line 135 of file dns.h.

Referenced by CopyFrom(), deadline(), ExtendDeadline(), IsExpired(), and dns::Resolver::ResolveMany().

atomic_int64 dns::Host::global_id_ = 0
staticprivate

Counter that is increased with every creation of a host object. Allows to distinguish two Host objects with the same host name. E.g. when the proxy list in Download.cc reads "http://A:3128|http://A:3128".

Definition at line 129 of file dns.h.

int64_t dns::Host::id_
private

The unique id of this instance of Host.

Definition at line 140 of file dns.h.

Referenced by CopyFrom(), ExtendDeadline(), and id().

std::set<std::string> dns::Host::ipv4_addresses_
private

ASCII representation of IPv4 addresses (a.b.c.d), so that they can be readily used by curl.

Definition at line 146 of file dns.h.

Referenced by CopyFrom(), HasIpv4(), ipv4_addresses(), IsEquivalent(), IsValid(), and dns::Resolver::ResolveMany().

std::set<std::string> dns::Host::ipv6_addresses_
private

ASCII representation of IPv6 addresses in the form "[a:b:c:d:e:f:g:h]", so that they can be readily used by curl.

Definition at line 152 of file dns.h.

Referenced by CopyFrom(), HasIpv6(), ipv6_addresses(), IsEquivalent(), IsValid(), and dns::Resolver::ResolveMany().

std::string dns::Host::name_
private

The host name either fully qualified or within the search domain.

Definition at line 157 of file dns.h.

Referenced by CopyFrom(), IsEquivalent(), name(), and dns::Resolver::ResolveMany().

Failures dns::Host::status_
private

Error code of the name resolution that led to this object.

Definition at line 162 of file dns.h.

Referenced by CopyFrom(), IsEquivalent(), IsValid(), dns::Resolver::ResolveMany(), and status().


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