Squid Web Cache master
Loading...
Searching...
No Matches
CachePeer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_SRC_CACHEPEER_H
10#define SQUID_SRC_CACHEPEER_H
11
12#include "acl/forward.h"
13#include "base/CbcPointer.h"
14#include "base/forward.h"
15#include "enums.h"
16#include "http/StatusCode.h"
17#include "icp_opcode.h"
18#include "ip/Address.h"
20
21#include <iosfwd>
22
24class PconnPool;
25class PeerDigest;
26class PeerPoolMgr;
27
29{
31
32public:
33 explicit CachePeer(const char *hostname);
34 ~CachePeer();
35
37 void noteSuccess();
38
40 void noteFailure();
41
43 void rename(const char *);
44
46 time_t connectTimeout() const;
47
51
53 u_int index = 0;
54
61 char *name = nullptr;
62
66 char *host = nullptr;
67
69
71
72 struct {
73 int pings_sent = 0;
74 int pings_acked = 0;
75 int fetches = 0;
76 int rtt = 0;
80 time_t probe_start = 0;
81 time_t last_query = 0;
82 time_t last_reply = 0;
86 int conn_open = 0;
88
89 struct icp_ {
90 icp_() { memset(&counts, 0, sizeof(counts)); }
93 unsigned short port = CACHE_ICP_PORT;
94 } icp;
95
96#if USE_HTCP
97 struct {
98 double version = 0.0;
99 int counts[2] = {0, 0};
100 unsigned short port = 0;
102#endif
103
104 unsigned short http_port = CACHE_HTTP_PORT;
106 acl_access *access = nullptr;
107
108 struct {
109 bool proxy_only = false;
110 bool no_query = false;
111 bool background_ping = false;
112 bool no_digest = false;
113 bool default_parent = false;
114 bool roundrobin = false;
116 bool mcast_responder = false;
117 bool closest_only = false;
118#if USE_HTCP
119 bool htcp = false;
120 bool htcp_oldsquid = false;
121 bool htcp_no_clr = false;
122 bool htcp_no_purge_clr = false;
123 bool htcp_only_clr = false;
124 bool htcp_forward_clr = false;
125#endif
126 bool no_netdb_exchange = false;
127#if USE_DELAY_POOLS
128 bool no_delay = false;
129#endif
130 bool allow_miss = false;
131 bool carp = false;
132 struct {
133 bool set = false; //If false, whole url is to be used. Overrides others
134 bool scheme = false;
135 bool host = false;
136 bool port = false;
137 bool path = false;
138 bool params = false;
140#if USE_AUTH
141 bool userhash = false;
142#endif
143 bool sourcehash = false;
144 bool originserver = false;
145 bool no_tproxy = false;
146 bool mcast_siblings = false;
147 bool auth_no_keytab = false;
149
150 int weight = 1;
151 int basetime = 0;
152
153 struct {
154 double avg_n_members = 0.0;
157 int ttl = 0;
158 int id = 0;
159
160 struct {
162 bool counting = false;
165
166#if USE_CACHE_DIGESTS
167 PeerDigest *digest = nullptr;
168 char *digest_url = nullptr;
169#endif
170
174 int tcp_up = 0;
175
177 bool reprobe = false;
178
180 int n_addresses = 0;
181 int rr_count = 0;
182 int testing_now = 0;
183
184 struct {
185 unsigned int hash = 0;
186 double load_multiplier = 0.0;
187 double load_factor = 0.0;
189#if USE_AUTH
190 struct {
191 unsigned int hash = 0;
192 double load_multiplier = 0.0;
193 double load_factor = 0.0;
195#endif
196 struct {
197 unsigned int hash = 0;
198 double load_multiplier = 0.0;
199 double load_factor = 0.0;
201
202 char *login = nullptr; /* Proxy authorization */
205 int max_conn = 0;
206
208 struct {
209 PconnPool *pool = nullptr;
211 int limit = 0;
212 bool waitingForClose = false;
214
215 char *domain = nullptr;
216
217 // TODO: Remove secure and sslContext when FuturePeerContext below becomes PeerContext
222
224
227
229
230private:
232};
233
236inline void
238{
239 if (peer)
240 peer->noteSuccess();
241}
242
245inline void
247{
248 if (peer)
249 peer->noteFailure();
250}
251
253std::ostream &operator <<(std::ostream &, const CachePeer &);
254
255#endif /* SQUID_SRC_CACHEPEER_H */
256
void NoteOutgoingConnectionFailure(CachePeer *const peer)
Definition CachePeer.h:246
void NoteOutgoingConnectionSuccess(CachePeer *const peer)
Definition CachePeer.h:237
std::ostream & operator<<(std::ostream &, const CachePeer &)
identify the given cache peer in cache.log messages and such
Definition CachePeer.cc:128
CbcPointer< PeerPoolMgr > mgr
pool manager
Definition CachePeer.h:210
acl_access * access
Definition CachePeer.h:106
bool closest_only
Definition CachePeer.h:117
struct CachePeer::@21::@27 flags
int n_keepalives_recv
Definition CachePeer.h:79
int n_keepalives_sent
Definition CachePeer.h:78
bool no_tproxy
Definition CachePeer.h:145
void noteSuccess()
reacts to a successful establishment of a connection to this cache_peer
Definition CachePeer.cc:71
bool htcp_oldsquid
Definition CachePeer.h:120
bool no_query
Definition CachePeer.h:110
Security::FuturePeerContext * securityContext()
Definition CachePeer.cc:63
NeighborTypeDomainList * typelist
Definition CachePeer.h:105
int basetime
Definition CachePeer.h:151
bool originserver
Definition CachePeer.h:144
time_t probe_start
Definition CachePeer.h:80
bool background_ping
Definition CachePeer.h:111
peer_t type
Definition CachePeer.h:68
bool scheme
Definition CachePeer.h:134
bool roundrobin
Definition CachePeer.h:114
int n_addresses
Definition CachePeer.h:180
int connection_auth
0 - off, 1 - on, 2 - auto
Definition CachePeer.h:226
struct CachePeer::@20 options
unsigned short http_port
Definition CachePeer.h:104
bool proxy_only
Definition CachePeer.h:109
int pings_sent
Definition CachePeer.h:73
int logged_state
so we can print dead/revived msgs
Definition CachePeer.h:85
char * login
Definition CachePeer.h:202
time_t last_connect_probe
Definition CachePeer.h:84
bool htcp_no_purge_clr
Definition CachePeer.h:122
char * host
Definition CachePeer.h:66
Security::PeerOptions secure
security settings for peer connection
Definition CachePeer.h:219
time_t connect_timeout_raw
connect_timeout; use connectTimeout() instead!
Definition CachePeer.h:203
struct CachePeer::@18 stats
bool mcast_siblings
Definition CachePeer.h:146
struct CachePeer::@21 mcast
char * domain
Forced domain.
Definition CachePeer.h:215
int limit
the limit itself
Definition CachePeer.h:211
time_t last_connect_failure
Definition CachePeer.h:83
unsigned short port
Definition CachePeer.h:100
time_t last_query
Definition CachePeer.h:81
Security::FuturePeerContext tlsContext
Definition CachePeer.h:221
CBDATA_CLASS(CachePeer)
double load_factor
normalized weight value
Definition CachePeer.h:187
PeerDigest * digest
Definition CachePeer.h:167
int n_replies_expected
Definition CachePeer.h:156
struct CachePeer::@25 standby
optional "cache_peer standby=limit" feature
bool counting
Definition CachePeer.h:162
bool auth_no_keytab
Definition CachePeer.h:147
bool no_digest
Definition CachePeer.h:112
struct CachePeer::@20::@26 carp_key
PrecomputedCodeContextPointer probeCodeContext
Definition CachePeer.h:228
bool htcp_forward_clr
Definition CachePeer.h:124
void countFailure()
Ip::Address in_addr
Definition CachePeer.h:70
PconnPool * pool
idle connection pool for this peer
Definition CachePeer.h:209
int rr_count
Definition CachePeer.h:181
bool waitingForClose
a conn must close before we open a standby conn
Definition CachePeer.h:212
bool sourcehash
Definition CachePeer.h:143
Security::SessionStatePointer sslSession
Definition CachePeer.h:223
u_int index
n-th cache_peer directive, starting with 1
Definition CachePeer.h:53
int connect_fail_limit
Definition CachePeer.h:204
double avg_n_members
Definition CachePeer.h:154
int front_end_https
0 - off, 1 - on, 2 - auto
Definition CachePeer.h:225
int n_times_counted
Definition CachePeer.h:155
struct CachePeer::icp_ icp
time_t last_reply
Definition CachePeer.h:82
int pings_acked
Definition CachePeer.h:74
bool no_netdb_exchange
Definition CachePeer.h:126
int max_conn
Definition CachePeer.h:205
Security::ContextPointer sslContext
Definition CachePeer.h:220
bool htcp_only_clr
Definition CachePeer.h:123
bool params
Definition CachePeer.h:138
time_t connectTimeout() const
Definition CachePeer.cc:120
struct CachePeer::@19 htcp
void noteFailure()
reacts to a failed attempt to establish a connection to this cache_peer
Definition CachePeer.cc:86
int counts[2]
Definition CachePeer.h:99
bool count_event_pending
Definition CachePeer.h:161
void rename(const char *)
(re)configure cache_peer name=value
Definition CachePeer.cc:110
char * name
Definition CachePeer.h:61
Ip::Address addresses[10]
Definition CachePeer.h:179
bool userhash
Definition CachePeer.h:141
int conn_open
current opened connections
Definition CachePeer.h:86
int testing_now
Definition CachePeer.h:182
bool default_parent
Definition CachePeer.h:113
bool carp
Definition CachePeer.h:131
bool reprobe
whether to do another TCP probe after current TCP probes
Definition CachePeer.h:177
unsigned int hash
Definition CachePeer.h:185
bool allow_miss
Definition CachePeer.h:130
char * digest_url
Definition CachePeer.h:168
int ignored_replies
Definition CachePeer.h:77
int fetches
Definition CachePeer.h:75
double version
Definition CachePeer.h:98
double load_multiplier
Definition CachePeer.h:186
bool mcast_responder
Definition CachePeer.h:116
bool weighted_roundrobin
Definition CachePeer.h:115
bool path
Definition CachePeer.h:137
bool htcp_no_clr
Definition CachePeer.h:121
bool no_delay
Definition CachePeer.h:128
representation of a neighbor_type_domain configuration directive. A POD
Maintains an fixed-size "standby" PconnPool for a single CachePeer.
Definition PeerPoolMgr.h:24
A combination of PeerOptions and the corresponding Context.
TLS squid.conf settings for a remote server peer.
Definition PeerOptions.h:26
#define ICP_VERSION_CURRENT
Definition defines.h:44
#define PEER_ALIVE
Definition defines.h:84
peer_t
Definition enums.h:22
@ PEER_NONE
Definition enums.h:23
@ ICP_END
Definition icp_opcode.h:39
std::shared_ptr< SSL_CTX > ContextPointer
Definition Context.h:29
std::unique_ptr< SSL_SESSION, HardFun< void, SSL_SESSION *, &SSL_SESSION_free > > SessionStatePointer
Definition Session.h:55
#define CACHE_ICP_PORT
Definition squid.h:17
#define CACHE_HTTP_PORT
Definition squid.h:16
unsigned short port
Definition CachePeer.h:93
int counts[ICP_END+1]
Definition CachePeer.h:92