2 * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_CACHEPEER_H_
10 #define SQUID_CACHEPEER_H_
12 #include "acl/forward.h"
13 #include "base/CbcPointer.h"
15 #include "icp_opcode.h"
16 #include "ip/Address.h"
17 #include "security/PeerOptions.h"
19 //TODO: remove, it is unconditionally defined and always used.
20 #define PEER_MULTICAST_SIBLINGS 1
22 class NeighborTypeDomainList
;
29 CBDATA_CLASS(CachePeer
);
32 CachePeer() = default;
35 /// \returns the effective connect timeout for the given peer
36 time_t connectTimeout() const;
41 peer_t type
= PEER_NONE
;
50 int ignored_replies
= 0;
51 int n_keepalives_sent
= 0;
52 int n_keepalives_recv
= 0;
53 time_t probe_start
= 0;
54 time_t last_query
= 0;
55 time_t last_reply
= 0;
56 time_t last_connect_failure
= 0;
57 time_t last_connect_probe
= 0;
58 int logged_state
= PEER_ALIVE
; ///< so we can print dead/revived msgs
59 int conn_open
= 0; ///< current opened connections
63 icp_() { memset(&counts
, 0, sizeof(counts
)); }
64 int version
= ICP_VERSION_CURRENT
;
65 int counts
[ICP_END
+1];
66 unsigned short port
= CACHE_ICP_PORT
;
72 int counts
[2] = {0, 0};
73 unsigned short port
= 0;
77 unsigned short http_port
= CACHE_HTTP_PORT
;
78 NeighborTypeDomainList
*typelist
= nullptr;
79 acl_access
*access
= nullptr;
82 bool proxy_only
= false;
83 bool no_query
= false;
84 bool background_ping
= false;
85 bool no_digest
= false;
86 bool default_parent
= false;
87 bool roundrobin
= false;
88 bool weighted_roundrobin
= false;
89 bool mcast_responder
= false;
90 bool closest_only
= false;
93 bool htcp_oldsquid
= false;
94 bool htcp_no_clr
= false;
95 bool htcp_no_purge_clr
= false;
96 bool htcp_only_clr
= false;
97 bool htcp_forward_clr
= false;
99 bool no_netdb_exchange
= false;
101 bool no_delay
= false;
103 bool allow_miss
= false;
106 bool set
= false; //If false, whole url is to be used. Overrides others
114 bool userhash
= false;
116 bool sourcehash
= false;
117 bool originserver
= false;
118 bool no_tproxy
= false;
119 #if PEER_MULTICAST_SIBLINGS
120 bool mcast_siblings
= false;
122 bool auth_no_keytab
= false;
129 double avg_n_members
= 0.0;
130 int n_times_counted
= 0;
131 int n_replies_expected
= 0;
136 bool count_event_pending
= false;
137 bool counting
= false;
141 #if USE_CACHE_DIGESTS
142 PeerDigest
*digest
= nullptr;
143 char *digest_url
= nullptr;
146 int tcp_up
= 0; /* 0 if a connect() fails */
147 /// whether to do another TCP probe after current TCP probes
148 bool reprobe
= false;
150 Ip::Address addresses
[10];
153 CachePeer
*next
= nullptr;
157 unsigned int hash
= 0;
158 double load_multiplier
= 0.0;
159 double load_factor
= 0.0; ///< normalized weight value
163 unsigned int hash
= 0;
164 double load_multiplier
= 0.0;
165 double load_factor
= 0.0; ///< normalized weight value
169 unsigned int hash
= 0;
170 double load_multiplier
= 0.0;
171 double load_factor
= 0.0; ///< normalized weight value
174 char *login
= nullptr; /* Proxy authorization */
175 time_t connect_timeout_raw
= 0; ///< connect_timeout; use connectTimeout() instead!
176 int connect_fail_limit
= 0;
179 /// optional "cache_peer standby=limit" feature
181 PconnPool
*pool
= nullptr; ///< idle connection pool for this peer
182 CbcPointer
<PeerPoolMgr
> mgr
; ///< pool manager
183 int limit
= 0; ///< the limit itself
184 bool waitingForClose
= false; ///< a conn must close before we open a standby conn
187 char *domain
= nullptr; ///< Forced domain
189 /// security settings for peer connection
190 Security::PeerOptions secure
;
191 Security::ContextPointer sslContext
;
192 Security::SessionStatePointer sslSession
;
194 int front_end_https
= 0; ///< 0 - off, 1 - on, 2 - auto
195 int connection_auth
= 2; ///< 0 - off, 1 - on, 2 - auto
198 #endif /* SQUID_CACHEPEER_H_ */