9#ifndef SQUID_SRC_IPCACHE_H
10#define SQUID_SRC_IPCACHE_H
45template <
class Iterator>
61 bool empty() const noexcept {
return ips.empty(); }
62 size_t size() const noexcept {
return ips.size(); }
114 typedef std::vector<CachedIp>
Raw;
144 typedef std::vector<CachedIp>
Raw;
178template <
class Iterator>
187 Iterator
end() const noexcept {
return cend(); }
bool bad_
whether the address is currently deemed problematic
CachedIp(const Ip::Address &anIp)
void forgetMarking()
undo markAsBad()
bool bad() const
whether the address is currently deemed problematic for any reason
void markAsBad()
mark the address as problematic; it might already be marked
void markAsBad(const char *name, const Ip::Address &ip)
const Ip::Address & current() const
size_t goodPosition
position of the IP returned by current()
void reset(const Ip::Address &ip)
replace all info with the given (presumed good) IP address
void pushUnique(const Ip::Address &ip)
bool have(const Ip::Address &ip, size_t *position=nullptr) const
size_t badCount_
number of IPs that are currently marked as bad
const Storage & raw() const
all cached entries
size_t size() const noexcept
all cached IPs
void forgetMarking(const char *name, const Ip::Address &ip)
undo successful markAsBad()
bool seekNewGood(const char *name)
std::vector< CachedIp > Storage
IpsSelector< GoodIpsIterator > good() const
good IPs
Storage ips
good and bad IPs
IpsSelector< IpsIterator > goodAndBad() const
all IPs
void restoreGoodness(const char *name)
makes current() calls possible after a successful markAsBad()
void reportCurrent(std::ostream &os) const
prints current IP and other debugging information
size_t badCount() const noexcept
bad IPs
bool empty() const noexcept
whether we cached no IPs at all
Iterates over good IPs in CachedIps, starting at the so called current one.
const Raw & raw_
CachedIps being iterated.
GoodIpsIterator & operator++()
size_t position_
current iteration location, modulo raw.size()
bool operator==(const GoodIpsIterator them) const
const CachedIp & current() const
GoodIpsIterator(const Raw &raw)
Raw::const_iterator RawIterator
pointer operator->() const
size_t processed_
number of visited positions, including skipped ones
std::vector< CachedIp > Raw
std::forward_iterator_tag iterator_category
GoodIpsIterator operator++(int)
GoodIpsIterator(const Raw &raw, const size_t currentPos)
reference operator*() const
bool operator!=(const GoodIpsIterator them) const
an interface for receiving IP::Addresses from nbgethostbyname()
virtual void noteIps(const CachedIps *ips, const LookupDetails &details)=0
virtual void noteIp(const Ip::Address &)
Called when/if nbgethostbyname() discovers a new good IP address.
virtual void noteLookup(const Dns::LookupDetails &)
Iterates over any (good and/or bad) IPs in CachedIps, in unspecified order.
std::vector< CachedIp > Raw
IpsIterator & operator++()
Raw::const_iterator RawIterator
bool operator!=(const IpsIterator them) const
IpsIterator operator++(int)
reference operator*() const
std::forward_iterator_tag iterator_category
pointer operator->() const
IpsIterator(const Raw &raw)
RawIterator position_
current iteration location
bool operator==(const IpsIterator them) const
IpsIterator(const Raw &raw, const size_t)
const CachedIps & ips_
master IP storage we are wrapping
Iterator cend() const noexcept
IpsSelector(const CachedIps &ips)
Iterator cbegin() const noexcept
Iterator begin() const noexcept
Iterator end() const noexcept
encapsulates DNS lookup results
void ipcacheInvalidateNegative(const char *)
void ipcache_restart(void)
const ipcache_addrs * ipcache_gethostbyname(const char *, int flags)
void ipcacheInvalidate(const char *)
void ipcache_purgelru(void *)
void ipcacheMarkGoodAddr(const char *name, const Ip::Address &)
int ipcacheAddEntryFromHosts(const char *name, const char *ipaddr)
void ipcache_nbgethostbyname(const char *name, IPH *handler, void *handlerData)
Dns::CachedIps ipcache_addrs
deprecated alias
void ipcacheMarkBadAddr(const char *name, const Ip::Address &)
void IPH(const ipcache_addrs *, const Dns::LookupDetails &details, void *)
void nbgethostbyname(const char *name, const CbcPointer< IpReceiver > &receiver)
initiate an (often) asynchronous DNS lookup; the receiver gets the results
std::ostream & operator<<(std::ostream &os, const LookupDetails &dns)