#include <ipcache.h>

Collaboration diagram for Dns::CachedIps:

Public Types

typedef std::vector< CachedIpStorage
 

Public Member Functions

bool have (const Ip::Address &ip, size_t *position=nullptr) const
 
const Ip::Addresscurrent () const
 
bool empty () const noexcept
 whether we cached no IPs at all More...
 
size_t size () const noexcept
 all cached IPs More...
 
size_t badCount () const noexcept
 bad IPs More...
 
IpsSelector< GoodIpsIteratorgood () const
 good IPs More...
 
IpsSelector< IpsIteratorgoodAndBad () const
 all IPs More...
 
const Storageraw () const
 all cached entries More...
 
void markAsBad (const char *name, const Ip::Address &ip)
 
void forgetMarking (const char *name, const Ip::Address &ip)
 undo successful markAsBad() More...
 
void pushUnique (const Ip::Address &ip)
 
void reset (const Ip::Address &ip)
 replace all info with the given (presumed good) IP address More...
 
void reportCurrent (std::ostream &os) const
 prints current IP and other debugging information More...
 

Private Member Functions

bool seekNewGood (const char *name)
 
void restoreGoodness (const char *name)
 makes current() calls possible after a successful markAsBad() More...
 

Private Attributes

Storage ips
 good and bad IPs More...
 
size_t goodPosition = 0
 position of the IP returned by current() More...
 
size_t badCount_ = 0
 number of IPs that are currently marked as bad More...
 

Friends

template<class Iterator >
class IpsSelector
 

Detailed Description

A small container of IP addresses with a "current good address" getter API. Ignores Ip::Address port.

Definition at line 50 of file ipcache.h.

Member Typedef Documentation

◆ Storage

Definition at line 68 of file ipcache.h.

Member Function Documentation

◆ badCount()

size_t Dns::CachedIps::badCount ( ) const
inlinenoexcept

Definition at line 63 of file ipcache.h.

References badCount_.

Referenced by ipcacheStatPrint().

◆ current()

const Ip::Address & Dns::CachedIps::current ( ) const
inline
Returns
a good address does not auto-rotate IPs but calling markAsBad() may change the answer

Definition at line 59 of file ipcache.h.

References goodPosition, and ips.

Referenced by icapLookupDnsResults(), netdbClosestParent(), and netdbSendPing().

◆ empty()

bool Dns::CachedIps::empty ( ) const
inlinenoexcept

◆ forgetMarking()

void Dns::CachedIps::forgetMarking ( const char *  name,
const Ip::Address ip 
)

Definition at line 1039 of file ipcache.cc.

References assert, and debugs.

◆ good()

Dns::IpsSelector< Dns::GoodIpsIterator > Dns::CachedIps::good ( ) const
inline

Definition at line 243 of file ipcache.h.

Referenced by IpCacheLookupForwarder::forwardHits().

◆ goodAndBad()

Dns::IpsSelector< Dns::IpsIterator > Dns::CachedIps::goodAndBad ( ) const
inline

◆ have()

bool Dns::CachedIps::have ( const Ip::Address ip,
size_t position = nullptr 
) const

whether we have at least one of the given IP addresses (ignoring ports) upon success, also sets *position if the position is not nil

Definition at line 982 of file ipcache.cc.

References debugs.

Referenced by ipcache_entry::addGood(), and ClientRequestContext::hostHeaderIpVerify().

◆ markAsBad()

void Dns::CachedIps::markAsBad ( const char *  name,
const Ip::Address ip 
)

Finds and marks the given address as bad, adjusting current() if needed. Has no effect if the search fails or the found address is already bad. XXX: An attempt to mark the last good address erases all marks instead. XXX: It is impossible to successfully mark a single address as bad.

Definition at line 1019 of file ipcache.cc.

References debugs.

◆ pushUnique()

void Dns::CachedIps::pushUnique ( const Ip::Address ip)

appends an IP address if we do not have() it already invalidates all iterators

Definition at line 1000 of file ipcache.cc.

References assert.

Referenced by ipcache_entry::addGood(), and ipcacheAddEntryFromHosts().

◆ raw()

const Storage & Dns::CachedIps::raw ( ) const
inline

◆ reportCurrent()

void Dns::CachedIps::reportCurrent ( std::ostream &  os) const

Definition at line 1008 of file ipcache.cc.

References size.

Referenced by Dns::operator<<().

◆ reset()

void Dns::CachedIps::reset ( const Ip::Address ip)

Definition at line 956 of file ipcache.cc.

Referenced by ipcacheCheckNumeric().

◆ restoreGoodness()

void Dns::CachedIps::restoreGoodness ( const char *  name)
private

Definition at line 968 of file ipcache.cc.

References debugs, Must, and size.

◆ seekNewGood()

bool Dns::CachedIps::seekNewGood ( const char *  name)
private

find the next good IP, wrapping if needed

Returns
whether the search was successful

Definition at line 939 of file ipcache.cc.

References debugs, goodPosition, and ips.

◆ size()

size_t Dns::CachedIps::size ( ) const
inlinenoexcept

Definition at line 62 of file ipcache.h.

References ips.

Referenced by ipcache_entry::addGood(), ipcacheStatPrint(), peerDNSConfigure(), and ipcache_entry::updateTtl().

Friends And Related Function Documentation

◆ IpsSelector

template<class Iterator >
friend class IpsSelector
friend

Definition at line 99 of file ipcache.h.

Member Data Documentation

◆ badCount_

size_t Dns::CachedIps::badCount_ = 0
private

Definition at line 101 of file ipcache.h.

Referenced by badCount().

◆ goodPosition

size_t Dns::CachedIps::goodPosition = 0
private

Definition at line 100 of file ipcache.h.

Referenced by Dns::IpsSelector< Iterator >::cbegin(), current(), and seekNewGood().

◆ ips

Storage Dns::CachedIps::ips
private

Definition at line 97 of file ipcache.h.

Referenced by current(), empty(), raw(), seekNewGood(), and size().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors