CachePeer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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"
19 #include "security/PeerOptions.h"
20 
21 #include <iosfwd>
22 
24 class PconnPool;
25 class PeerDigest;
26 class PeerPoolMgr;
27 
28 class CachePeer
29 {
31 
32 public:
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;
77  int ignored_replies = 0;
80  time_t probe_start = 0;
81  time_t last_query = 0;
82  time_t last_reply = 0;
84  time_t last_connect_probe = 0;
86  int conn_open = 0;
87  } stats;
88 
89  struct icp_ {
90  icp_() { memset(&counts, 0, sizeof(counts)); }
92  int counts[ICP_END+1];
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;
101  } htcp;
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;
115  bool weighted_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;
139  } carp_key;
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;
148  } options;
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 {
161  bool count_event_pending = false;
162  bool counting = false;
163  } flags;
164  } mcast;
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;
188  } carp;
189 #if USE_AUTH
190  struct {
191  unsigned int hash = 0;
192  double load_multiplier = 0.0;
193  double load_factor = 0.0;
194  } userhash;
195 #endif
196  struct {
197  unsigned int hash = 0;
198  double load_multiplier = 0.0;
199  double load_factor = 0.0;
200  } sourcehash;
201 
202  char *login = nullptr; /* Proxy authorization */
203  time_t connect_timeout_raw = 0;
205  int max_conn = 0;
206 
208  struct {
209  PconnPool *pool = nullptr;
211  int limit = 0;
212  bool waitingForClose = false;
213  } standby;
214 
215  char *domain = nullptr;
216 
217  // TODO: Remove secure and sslContext when FuturePeerContext below becomes PeerContext
222 
224 
225  int front_end_https = 0;
226  int connection_auth = 2;
227 
229 
230 private:
231  void countFailure();
232 };
233 
236 inline void
238 {
239  if (peer)
240  peer->noteSuccess();
241 }
242 
245 inline void
247 {
248  if (peer)
249  peer->noteFailure();
250 }
251 
253 std::ostream &operator <<(std::ostream &, const CachePeer &);
254 
255 #endif /* SQUID_SRC_CACHEPEER_H */
256 
bool waitingForClose
a conn must close before we open a standby conn
Definition: CachePeer.h:212
bool proxy_only
Definition: CachePeer.h:109
int testing_now
Definition: CachePeer.h:182
Maintains an fixed-size "standby" PconnPool for a single CachePeer.
Definition: PeerPoolMgr.h:23
bool no_query
Definition: CachePeer.h:110
Ip::Address addresses[10]
Definition: CachePeer.h:179
bool htcp_no_clr
Definition: CachePeer.h:121
int connection_auth
0 - off, 1 - on, 2 - auto
Definition: CachePeer.h:226
bool background_ping
Definition: CachePeer.h:111
double version
Definition: CachePeer.h:98
PeerDigest * digest
Definition: CachePeer.h:167
struct CachePeer::@27::@33 carp_key
struct CachePeer::@26 htcp
double load_factor
normalized weight value
Definition: CachePeer.h:187
acl_access * access
Definition: CachePeer.h:106
int fetches
Definition: CachePeer.h:75
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:29
u_int index
n-th cache_peer directive, starting with 1
Definition: CachePeer.h:53
Ip::Address in_addr
Definition: CachePeer.h:70
time_t last_connect_failure
Definition: CachePeer.h:83
peer_t type
Definition: CachePeer.h:68
void noteSuccess()
reacts to a successful establishment of a connection to this cache_peer
Definition: CachePeer.cc:71
PconnPool * pool
idle connection pool for this peer
Definition: CachePeer.h:209
#define CACHE_HTTP_PORT
Definition: squid.h:16
char * login
Definition: CachePeer.h:202
#define PEER_ALIVE
Definition: defines.h:84
bool reprobe
whether to do another TCP probe after current TCP probes
Definition: CachePeer.h:177
struct CachePeer::@25 stats
double load_multiplier
Definition: CachePeer.h:186
bool allow_miss
Definition: CachePeer.h:130
unsigned short port
Definition: CachePeer.h:93
int connect_fail_limit
Definition: CachePeer.h:204
A combination of PeerOptions and the corresponding Context.
Definition: PeerOptions.h:154
bool no_tproxy
Definition: CachePeer.h:145
#define CACHE_ICP_PORT
Definition: squid.h:17
Security::SessionStatePointer sslSession
Definition: CachePeer.h:223
int limit
the limit itself
Definition: CachePeer.h:211
time_t connectTimeout() const
Definition: CachePeer.cc:120
bool counting
Definition: CachePeer.h:162
int front_end_https
0 - off, 1 - on, 2 - auto
Definition: CachePeer.h:225
bool sourcehash
Definition: CachePeer.h:143
char * name
Definition: CachePeer.h:61
bool roundrobin
Definition: CachePeer.h:114
bool auth_no_keytab
Definition: CachePeer.h:147
char * domain
Forced domain.
Definition: CachePeer.h:215
int pings_acked
Definition: CachePeer.h:74
int weight
Definition: CachePeer.h:150
Security::FuturePeerContext tlsContext
Definition: CachePeer.h:221
NeighborTypeDomainList * typelist
Definition: CachePeer.h:105
void countFailure()
bool htcp_forward_clr
Definition: CachePeer.h:124
struct CachePeer::@28 mcast
time_t last_reply
Definition: CachePeer.h:82
bool userhash
Definition: CachePeer.h:141
peer_t
Definition: enums.h:22
bool no_digest
Definition: CachePeer.h:112
void noteFailure()
reacts to a failed attempt to establish a connection to this cache_peer
Definition: CachePeer.cc:86
int n_keepalives_sent
Definition: CachePeer.h:78
PrecomputedCodeContextPointer probeCodeContext
Definition: CachePeer.h:228
bool htcp_no_purge_clr
Definition: CachePeer.h:122
int n_addresses
Definition: CachePeer.h:180
bool no_netdb_exchange
Definition: CachePeer.h:126
~CachePeer()
Definition: CachePeer.cc:34
void rename(const char *)
(re)configure cache_peer name=value
Definition: CachePeer.cc:110
TLS squid.conf settings for a remote server peer.
Definition: PeerOptions.h:25
struct CachePeer::@32 standby
optional "cache_peer standby=limit" feature
bool scheme
Definition: CachePeer.h:134
double avg_n_members
Definition: CachePeer.h:154
CbcPointer< PeerPoolMgr > mgr
pool manager
Definition: CachePeer.h:210
bool set
Definition: CachePeer.h:133
representation of a neighbor_type_domain configuration directive. A POD
void NoteOutgoingConnectionFailure(CachePeer *const peer)
Definition: CachePeer.h:246
struct CachePeer::icp_ icp
@ PEER_NONE
Definition: enums.h:23
bool default_parent
Definition: CachePeer.h:113
bool closest_only
Definition: CachePeer.h:117
Security::ContextPointer sslContext
Definition: CachePeer.h:220
bool no_delay
Definition: CachePeer.h:128
struct CachePeer::@28::@34 flags
CachePeer(const char *hostname)
Definition: CachePeer.cc:25
std::ostream & operator<<(std::ostream &, const CachePeer &)
identify the given cache peer in cache.log messages and such
Definition: CachePeer.cc:128
void NoteOutgoingConnectionSuccess(CachePeer *const peer)
Definition: CachePeer.h:237
bool carp
Definition: CachePeer.h:131
int n_times_counted
Definition: CachePeer.h:155
bool mcast_responder
Definition: CachePeer.h:116
bool params
Definition: CachePeer.h:138
int pings_sent
Definition: CachePeer.h:73
int tcp_up
Definition: CachePeer.h:174
time_t last_query
Definition: CachePeer.h:81
char * host
Definition: CachePeer.h:66
bool mcast_siblings
Definition: CachePeer.h:146
bool htcp_oldsquid
Definition: CachePeer.h:120
int max_conn
Definition: CachePeer.h:205
std::unique_ptr< SSL_SESSION, HardFun< void, SSL_SESSION *, &SSL_SESSION_free > > SessionStatePointer
Definition: Session.h:55
unsigned int hash
Definition: CachePeer.h:185
unsigned short port
Definition: CachePeer.h:100
time_t connect_timeout_raw
connect_timeout; use connectTimeout() instead!
Definition: CachePeer.h:203
int rtt
Definition: CachePeer.h:76
int rr_count
Definition: CachePeer.h:181
int logged_state
so we can print dead/revived msgs
Definition: CachePeer.h:85
@ ICP_END
Definition: icp_opcode.h:39
struct CachePeer::@27 options
bool htcp_only_clr
Definition: CachePeer.h:123
time_t last_connect_probe
Definition: CachePeer.h:84
int n_keepalives_recv
Definition: CachePeer.h:79
int ignored_replies
Definition: CachePeer.h:77
Security::FuturePeerContext * securityContext()
Definition: CachePeer.cc:63
bool path
Definition: CachePeer.h:137
bool weighted_roundrobin
Definition: CachePeer.h:115
#define ICP_VERSION_CURRENT
Definition: defines.h:44
Security::PeerOptions secure
security settings for peer connection
Definition: CachePeer.h:219
int counts[2]
Definition: CachePeer.h:99
int counts[ICP_END+1]
Definition: CachePeer.h:92
unsigned short http_port
Definition: CachePeer.h:104
int conn_open
current opened connections
Definition: CachePeer.h:86
int n_replies_expected
Definition: CachePeer.h:156
bool count_event_pending
Definition: CachePeer.h:161
int basetime
Definition: CachePeer.h:151
bool originserver
Definition: CachePeer.h:144
time_t probe_start
Definition: CachePeer.h:80
CBDATA_CLASS(CachePeer)
char * digest_url
Definition: CachePeer.h:168

 

Introduction

Documentation

Support

Miscellaneous