#include "squid.h"
#include "base/RunnersRegistry.h"
#include "client_db.h"
#include "ClientInfo.h"
#include "event.h"
#include "format/Token.h"
#include "fqdncache.h"
#include "ip/Address.h"
#include "log/access_log.h"
#include "mgr/Registration.h"
#include "SquidConfig.h"
#include "SquidMath.h"
#include "StatCounters.h"
#include "Store.h"
#include "tools.h"
#include "snmp_core.h"
Go to the source code of this file.
Classes | |
class | ClientDbRr |
Macros | |
#define | CLIENT_DB_HASH_SIZE 65357 |
#define | CUTOFF_SECONDS 3600 |
Functions | |
static ClientInfo * | clientdbAdd (const Ip::Address &addr) |
static void | clientdbStartGC (void) |
static void | clientdbScheduledGC (void *) |
static void | clientdbInit (void) |
DefineRunnerRegistrator (ClientDbRr) | |
ClientInfo * | clientdbGetInfo (const Ip::Address &addr) |
void | clientdbUpdate (const Ip::Address &addr, const LogTags <ype, AnyP::ProtocolType p, size_t size) |
int | clientdbEstablished (const Ip::Address &addr, int delta) |
int | clientdbCutoffDenied (const Ip::Address &addr) |
void | clientdbDump (StoreEntry *sentry) |
static void | clientdbFreeItem (void *data) |
static void | clientdbGC (void *) |
Ip::Address * | client_entry (Ip::Address *current) |
variable_list * | snmp_meshCtblFn (variable_list *Var, snint *ErrP) |
Variables | |
static hash_table * | client_table = nullptr |
static FREE | clientdbFreeItem |
static int | max_clients = 32768 |
static int | cleanup_running = 0 |
static int | cleanup_scheduled = 0 |
static int | cleanup_removed |
Macro Definition Documentation
◆ CLIENT_DB_HASH_SIZE
#define CLIENT_DB_HASH_SIZE 65357 |
Definition at line 49 of file client_db.cc.
◆ CUTOFF_SECONDS
#define CUTOFF_SECONDS 3600 |
Definition at line 206 of file client_db.cc.
Function Documentation
◆ client_entry()
Ip::Address * client_entry | ( | Ip::Address * | current | ) |
Definition at line 421 of file client_db.cc.
References ClientInfo::addr, client_table, hash, hash_first(), hash_last(), hash_next(), hashKeyStr(), MAX_IPSTRLEN, and Ip::Address::toStr().
Referenced by client_Inst().
◆ clientdbAdd()
|
static |
Definition at line 76 of file client_db.cc.
References cleanup_running, cleanup_scheduled, StatCounters::client_http, client_table, clientdbScheduledGC(), StatCounters::clients, eventAdd(), hash_join(), max_clients, and statCounter.
Referenced by clientdbEstablished(), and clientdbUpdate().
◆ clientdbCutoffDenied()
int clientdbCutoffDenied | ( | const Ip::Address & | addr | ) |
Definition at line 209 of file client_db.cc.
References SquidConfig::client_db, client_table, Config, ClientInfo::cutoff, CUTOFF_SECONDS, DBG_CRITICAL, debugs, hash_lookup(), ClientInfo::Icp, LOG_UDP_DENIED, MAX_IPSTRLEN, ClientInfo::Cutoff::n_denied, ClientInfo::Cutoff::n_req, ClientInfo::Protocol::n_requests, SquidConfig::onoff, ClientInfo::Protocol::result_hist, squid_curtime, ClientInfo::Cutoff::time, and Ip::Address::toStr().
Referenced by icpDenyAccess().
◆ clientdbDump()
void clientdbDump | ( | StoreEntry * | sentry | ) |
Definition at line 267 of file client_db.cc.
References ClientInfo::addr, client_table, fqdncache_gethostbyaddr(), hash, hash_first(), hash_next(), hashKeyStr(), ClientInfo::Http, ClientInfo::Icp, Math::intPercent(), LOG_TAG_NONE, LOG_TYPE_MAX, LOG_UDP_HIT, ClientInfo::n_established, ClientInfo::Protocol::n_requests, ClientInfo::Protocol::result_hist, and storeAppendPrintf().
Referenced by ClientDbRr::useConfig().
◆ clientdbEstablished()
int clientdbEstablished | ( | const Ip::Address & | addr, |
int | delta | ||
) |
This function tracks the number of currently established connections for a client IP address. When a connection is accepted, call this with delta = 1. When the connection is closed, call with delta = -1. To get the current value, simply call with delta = 0.
Definition at line 182 of file client_db.cc.
References SquidConfig::client_db, client_table, clientdbAdd(), Config, debug_trap(), hash_lookup(), MAX_IPSTRLEN, ClientInfo::n_established, SquidConfig::onoff, and Ip::Address::toStr().
Referenced by Comm::TcpAcceptor::acceptInto(), ACLMaxConnection::match(), ConnStateData::swanSong(), and ConnStateData::whenClientIpKnown().
◆ clientdbFreeItem()
|
static |
Definition at line 329 of file client_db.cc.
◆ clientdbGC()
|
static |
Definition at line 357 of file client_db.cc.
References cleanup_removed, cleanup_running, cleanup_scheduled, CLIENT_DB_HASH_SIZE, StatCounters::client_http, client_table, clientdbFreeItem, clientdbGC(), clientdbScheduledGC(), StatCounters::clients, debugs, eventAdd(), hash_get_bucket(), hash_remove_link(), ClientInfo::Http, ClientInfo::Icp, ClientInfo::last_seen, max_clients, ClientInfo::n_established, ClientInfo::Protocol::n_requests, hash_link::next, squid_curtime, and statCounter.
Referenced by clientdbGC(), and clientdbStartGC().
◆ clientdbGetInfo()
ClientInfo * clientdbGetInfo | ( | const Ip::Address & | addr | ) |
Definition at line 119 of file client_db.cc.
References SquidConfig::client_db, client_table, Config, DBG_IMPORTANT, debugs, hash_lookup(), MAX_IPSTRLEN, SquidConfig::onoff, and Ip::Address::toStr().
Referenced by ConnStateData::whenClientIpKnown().
◆ clientdbInit()
|
static |
Definition at line 91 of file client_db.cc.
References CLIENT_DB_HASH_SIZE, client_table, hash_create(), and hash_string.
Referenced by ClientDbRr::useConfig().
◆ clientdbScheduledGC()
|
static |
Definition at line 350 of file client_db.cc.
References cleanup_scheduled, and clientdbStartGC().
Referenced by clientdbAdd(), and clientdbGC().
◆ clientdbStartGC()
|
static |
Definition at line 410 of file client_db.cc.
References cleanup_removed, cleanup_running, StatCounters::client_http, clientdbGC(), StatCounters::clients, max_clients, and statCounter.
Referenced by clientdbScheduledGC().
◆ clientdbUpdate()
void clientdbUpdate | ( | const Ip::Address & | addr, |
const LogTags & | ltype, | ||
AnyP::ProtocolType | p, | ||
size_t | size | ||
) |
Definition at line 138 of file client_db.cc.
References SquidConfig::client_db, client_table, clientdbAdd(), Config, debug_trap(), hash_lookup(), ClientInfo::Protocol::hit_kbytes_out, ClientInfo::Http, ClientInfo::Icp, LogTags::isTcpHit(), ClientInfo::Protocol::kbytes_out, ClientInfo::last_seen, LOG_UDP_HIT, MAX_IPSTRLEN, ClientInfo::Protocol::n_requests, LogTags::oldType, SquidConfig::onoff, AnyP::PROTO_HTTP, AnyP::PROTO_ICP, ClientInfo::Protocol::result_hist, size, squid_curtime, and Ip::Address::toStr().
Referenced by icpDenyAccess(), icpLogIcp(), and ClientHttpRequest::logRequest().
◆ DefineRunnerRegistrator()
DefineRunnerRegistrator | ( | ClientDbRr | ) |
◆ snmp_meshCtblFn()
variable_list * snmp_meshCtblFn | ( | variable_list * | Var, |
snint * | ErrP | ||
) |
Definition at line 442 of file client_db.cc.
References ClientInfo::addr, ASN_OCTET_STR, client_table, debugs, hash_lookup(), ClientInfo::Protocol::hit_kbytes_out, ClientInfo::Http, ClientInfo::Icp, INETADDRESSTYPE_IPV4, INETADDRESSTYPE_IPV6, Ip::Address::isIPv4(), ByteCounter::kb, ClientInfo::Protocol::kbytes_out, LEN_SQ_NET, LOG_TAG_NONE, LOG_TYPE_MAX, LOG_UDP_HIT, MAX_IPSTRLEN, MESH_CTBL_ADDR, MESH_CTBL_ADDR_TYPE, MESH_CTBL_HTBYTES, MESH_CTBL_HTHITBYTES, MESH_CTBL_HTHITS, MESH_CTBL_HTREQ, MESH_CTBL_ICPBYTES, MESH_CTBL_ICPHITBYTES, MESH_CTBL_ICPHITS, MESH_CTBL_ICPREQ, ClientInfo::Protocol::n_requests, variable_list::name, variable_list::name_length, oid2addr(), ClientInfo::Protocol::result_hist, SMI_COUNTER32, SMI_INTEGER, SNMP_ERR_NOERROR, SNMP_ERR_NOSUCHNAME, snmp_var_new(), snmp_var_new_integer(), snmpDebugOid(), variable_list::string, Ip::Address::toStr(), variable_list::type, variable_list::val, variable_list::val_len, and xstrdup.
Referenced by snmpInit().
Variable Documentation
◆ cleanup_removed
|
static |
Definition at line 46 of file client_db.cc.
Referenced by clientdbGC(), and clientdbStartGC().
◆ cleanup_running
|
static |
Definition at line 44 of file client_db.cc.
Referenced by clientdbAdd(), clientdbGC(), and clientdbStartGC().
◆ cleanup_scheduled
|
static |
Definition at line 45 of file client_db.cc.
Referenced by clientdbAdd(), clientdbGC(), and clientdbScheduledGC().
◆ client_table
|
static |
Definition at line 31 of file client_db.cc.
Referenced by client_entry(), clientdbAdd(), clientdbCutoffDenied(), clientdbDump(), clientdbEstablished(), clientdbGC(), clientdbGetInfo(), clientdbInit(), clientdbUpdate(), and snmp_meshCtblFn().
◆ clientdbFreeItem
|
static |
Definition at line 34 of file client_db.cc.
Referenced by clientdbGC().
◆ max_clients
|
static |
Definition at line 39 of file client_db.cc.
Referenced by clientdbAdd(), clientdbGC(), and clientdbStartGC().