EpcTools
An event based multi-threaded C++ development framework.
Public Member Functions | Static Public Member Functions | List of all members
DNS::Cache Class Reference

Defines the functionality associated with a DNS cache. More...

#include <dnscache.h>

Public Member Functions

 Cache ()
 Default constructor. More...
 
 ~Cache ()
 Class destructor. More...
 
Void addNamedServer (const char *address, int udp_port=53, int tcp_port=53)
 Adds a named server to this DNS cache object. More...
 
Void removeNamedServer (const char *address)
 Removes the specified named server from this DNS cache. More...
 
Void applyNamedServers ()
 Updates the named servers as a set in the underlying c-ares library. More...
 
QueryPtr query (ns_type rtype, const std::string &domain, Bool &cacheHit, Bool ignorecache=false)
 Performs a DNS query synchronously. More...
 
Void query (ns_type rtype, const std::string &domain, CachedDNSQueryCallback cb, const Void *data=NULL, Bool ignorecache=false)
 Performs a DNS query asynchronously. More...
 
Void loadQueries (const char *qfn)
 Executes the DNS queries at startup from the suppoied file. More...
 
Void loadQueries (const std::string &qfn)
 Executes the DNS queries at startup from the suppoied file. More...
 
Void initSaveQueries (const char *qfn, long qsf)
 Initializes the settings used to save queries. More...
 
Void saveQueries ()
 Saves the DNS queries that are part of the cache. More...
 
Void forceRefresh ()
 Forces a refresh of the DNS cache. More...
 
namedserverid_t getNamedServerId ()
 Retrieves the named server ID associated with this DNS cache. More...
 
long resetNewQueryCount ()
 Resets the number of new queries (not saved) to zero. More...
 

Static Public Member Functions

static CachegetInstance (namedserverid_t nsid)
 Retrieves/creates the Cache instance associated with the named server ID. More...
 
static CachegetInstance ()
 Retrieves/creates the default Cache instance. More...
 
static unsigned int getRefreshConcurrent ()
 Retrieves the current setting of the maximum number of conncurrent DNS queries that can be performed while refreshing the DNS cache. More...
 
static unsigned int setRefreshConcurrent (unsigned int concur)
 Sets the maximum number of conncurrent DNS queries that can be performed while refreshing the DNS cache. More...
 
static int getRefreshPercent ()
 Retrieves the current refresh percentage value. More...
 
static int setRefreshPercent (int percent)
 Assigns the refresh percentage value. More...
 
static long getRefeshInterval ()
 Retrieves the refresh interval. More...
 
static long setRefreshInterval (long interval)
 Assigns the refresh interval. More...
 

Detailed Description

Defines the functionality associated with a DNS cache.

Constructor & Destructor Documentation

◆ Cache()

DNS::Cache::Cache ( )

Default constructor.

◆ ~Cache()

DNS::Cache::~Cache ( )

Class destructor.

Member Function Documentation

◆ addNamedServer()

Void DNS::Cache::addNamedServer ( const char *  address,
int  udp_port = 53,
int  tcp_port = 53 
)

Adds a named server to this DNS cache object.

Parameters
addressthe address of the named server.
udp_portthe UDP port to communicate with the DNS server on.
tcp_portthe TCP port to communicate with the DNS server on.

◆ applyNamedServers()

Void DNS::Cache::applyNamedServers ( )

Updates the named servers as a set in the underlying c-ares library.

◆ forceRefresh()

Void DNS::Cache::forceRefresh ( )

Forces a refresh of the DNS cache.

◆ getInstance() [1/2]

static Cache& DNS::Cache::getInstance ( )
inlinestatic

Retrieves/creates the default Cache instance.

Returns
a reference to the Cache object.

◆ getInstance() [2/2]

Cache & DNS::Cache::getInstance ( namedserverid_t  nsid)
static

Retrieves/creates the Cache instance associated with the named server ID.

Parameters
nsidthe named server ID.
Returns
a reference to the Cache object.

◆ getNamedServerId()

namedserverid_t DNS::Cache::getNamedServerId ( )
inline

Retrieves the named server ID associated with this DNS cache.

Returns
the named server ID associated with this DNS cache.

◆ getRefeshInterval()

static long DNS::Cache::getRefeshInterval ( )
inlinestatic

Retrieves the refresh interval.

Returns
the refresh interval.

◆ getRefreshConcurrent()

static unsigned int DNS::Cache::getRefreshConcurrent ( )
inlinestatic

Retrieves the current setting of the maximum number of conncurrent DNS queries that can be performed while refreshing the DNS cache.

◆ getRefreshPercent()

static int DNS::Cache::getRefreshPercent ( )
inlinestatic

Retrieves the current refresh percentage value.

Returns
the current refresh percenting value.

◆ initSaveQueries()

Void DNS::Cache::initSaveQueries ( const char *  qfn,
long  qsf 
)

Initializes the settings used to save queries.

Parameters
qfnthe file name to save the DNS queries to.
qsfthe frequency in milliseconds to save the DNS queries.

◆ loadQueries() [1/2]

Void DNS::Cache::loadQueries ( const char *  qfn)

Executes the DNS queries at startup from the suppoied file.

Parameters
qfnthe DNS query file name to load.

◆ loadQueries() [2/2]

Void DNS::Cache::loadQueries ( const std::string &  qfn)
inline

Executes the DNS queries at startup from the suppoied file.

Parameters
qfnthe DNS query file name to load.

◆ query() [1/2]

QueryPtr DNS::Cache::query ( ns_type  rtype,
const std::string &  domain,
Bool &  cacheHit,
Bool  ignorecache = false 
)

Performs a DNS query synchronously.

Parameters
rtypethe named server type of the query.
domainthe domain name of the query.
cacheHitupdated with an indication if the result came from the local DNS cache.
ignorecachedirects the query to optionally ignore any results in the local DNS cache.
Returns
a QueryPtr with the DNS query results.

◆ query() [2/2]

Void DNS::Cache::query ( ns_type  rtype,
const std::string &  domain,
CachedDNSQueryCallback  cb,
const Void *  data = NULL,
Bool  ignorecache = false 
)

Performs a DNS query asynchronously.

Parameters
rtypethe named server type of the query.
domainthe domain name of the query.
cba callback function pointer that will be called when the query is complete.
dataa Void pointer that will be passed to the callback function when the query is complete.
ignorecachedirects the query to optionally ignore any results in the local DNS cache.

◆ removeNamedServer()

Void DNS::Cache::removeNamedServer ( const char *  address)

Removes the specified named server from this DNS cache.

Parameters
addressthe address of the named server to remove.

◆ resetNewQueryCount()

long DNS::Cache::resetNewQueryCount ( )
inline

Resets the number of new queries (not saved) to zero.

Returns
the previous the number of new queries (not saved).

◆ saveQueries()

Void DNS::Cache::saveQueries ( )

Saves the DNS queries that are part of the cache.

◆ setRefreshConcurrent()

static unsigned int DNS::Cache::setRefreshConcurrent ( unsigned int  concur)
inlinestatic

Sets the maximum number of conncurrent DNS queries that can be performed while refreshing the DNS cache.

Parameters
concurthe maximum number of concurrent DNS queries.
Returns
the current maximum number of concurrent DNS queries.

◆ setRefreshInterval()

static long DNS::Cache::setRefreshInterval ( long  interval)
inlinestatic

Assigns the refresh interval.

Parameters
intervalthe new refresh interval.
Returns
the refresh interval.

◆ setRefreshPercent()

static int DNS::Cache::setRefreshPercent ( int  percent)
inlinestatic

Assigns the refresh percentage value.

Parameters
percentthe refresh percentage value.
Returns
the refresh percenting value.

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