]> git.ipfire.org Git - thirdparty/squid.git/blob - src/CachePeer.h
Source Format Enforcement (#963)
[thirdparty/squid.git] / src / CachePeer.h
1 /*
2 * Copyright (C) 1996-2022 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_CACHEPEER_H_
10 #define SQUID_CACHEPEER_H_
11
12 #include "acl/forward.h"
13 #include "base/CbcPointer.h"
14 #include "enums.h"
15 #include "icp_opcode.h"
16 #include "ip/Address.h"
17 #include "security/PeerOptions.h"
18
19 //TODO: remove, it is unconditionally defined and always used.
20 #define PEER_MULTICAST_SIBLINGS 1
21
22 class NeighborTypeDomainList;
23 class PconnPool;
24 class PeerDigest;
25 class PeerPoolMgr;
26
27 class CachePeer
28 {
29 CBDATA_CLASS(CachePeer);
30
31 public:
32 CachePeer() = default;
33 ~CachePeer();
34
35 /// \returns the effective connect timeout for the given peer
36 time_t connectTimeout() const;
37
38 u_int index = 0;
39 char *name = nullptr;
40 char *host = nullptr;
41 peer_t type = PEER_NONE;
42
43 Ip::Address in_addr;
44
45 struct {
46 int pings_sent = 0;
47 int pings_acked = 0;
48 int fetches = 0;
49 int rtt = 0;
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
60 } stats;
61
62 struct icp_ {
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;
67 } icp;
68
69 #if USE_HTCP
70 struct {
71 double version = 0.0;
72 int counts[2] = {0, 0};
73 unsigned short port = 0;
74 } htcp;
75 #endif
76
77 unsigned short http_port = CACHE_HTTP_PORT;
78 NeighborTypeDomainList *typelist = nullptr;
79 acl_access *access = nullptr;
80
81 struct {
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;
91 #if USE_HTCP
92 bool htcp = 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;
98 #endif
99 bool no_netdb_exchange = false;
100 #if USE_DELAY_POOLS
101 bool no_delay = false;
102 #endif
103 bool allow_miss = false;
104 bool carp = false;
105 struct {
106 bool set = false; //If false, whole url is to be used. Overrides others
107 bool scheme = false;
108 bool host = false;
109 bool port = false;
110 bool path = false;
111 bool params = false;
112 } carp_key;
113 #if USE_AUTH
114 bool userhash = false;
115 #endif
116 bool sourcehash = false;
117 bool originserver = false;
118 bool no_tproxy = false;
119 #if PEER_MULTICAST_SIBLINGS
120 bool mcast_siblings = false;
121 #endif
122 bool auth_no_keytab = false;
123 } options;
124
125 int weight = 1;
126 int basetime = 0;
127
128 struct {
129 double avg_n_members = 0.0;
130 int n_times_counted = 0;
131 int n_replies_expected = 0;
132 int ttl = 0;
133 int id = 0;
134
135 struct {
136 bool count_event_pending = false;
137 bool counting = false;
138 } flags;
139 } mcast;
140
141 #if USE_CACHE_DIGESTS
142 PeerDigest *digest = nullptr;
143 char *digest_url = nullptr;
144 #endif
145
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;
149
150 Ip::Address addresses[10];
151 int n_addresses = 0;
152 int rr_count = 0;
153 CachePeer *next = nullptr;
154 int testing_now = 0;
155
156 struct {
157 unsigned int hash = 0;
158 double load_multiplier = 0.0;
159 double load_factor = 0.0; ///< normalized weight value
160 } carp;
161 #if USE_AUTH
162 struct {
163 unsigned int hash = 0;
164 double load_multiplier = 0.0;
165 double load_factor = 0.0; ///< normalized weight value
166 } userhash;
167 #endif
168 struct {
169 unsigned int hash = 0;
170 double load_multiplier = 0.0;
171 double load_factor = 0.0; ///< normalized weight value
172 } sourcehash;
173
174 char *login = nullptr; /* Proxy authorization */
175 time_t connect_timeout_raw = 0; ///< connect_timeout; use connectTimeout() instead!
176 int connect_fail_limit = 0;
177 int max_conn = 0;
178
179 /// optional "cache_peer standby=limit" feature
180 struct {
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
185 } standby;
186
187 char *domain = nullptr; ///< Forced domain
188
189 /// security settings for peer connection
190 Security::PeerOptions secure;
191 Security::ContextPointer sslContext;
192 Security::SessionStatePointer sslSession;
193
194 int front_end_https = 0; ///< 0 - off, 1 - on, 2 - auto
195 int connection_auth = 2; ///< 0 - off, 1 - on, 2 - auto
196 };
197
198 #endif /* SQUID_CACHEPEER_H_ */
199