]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/FilledChecklist.cc
Prepare external_acl_type format codes for libformat upgrade
[thirdparty/squid.git] / src / acl / FilledChecklist.cc
CommitLineData
582c2af2
FC
1#include "squid.h"
2#include "acl/FilledChecklist.h"
351fe86d 3#include "client_side.h"
582c2af2
FC
4#include "comm/Connection.h"
5#include "comm/forward.h"
6#include "HttpReply.h"
7#include "HttpRequest.h"
4d5904f7 8#include "SquidConfig.h"
2f1431ea 9#if USE_AUTH
351fe86d
AR
10#include "auth/UserRequest.h"
11#include "auth/AclProxyAuth.h"
2f1431ea 12#endif
582c2af2 13
351fe86d
AR
14CBDATA_CLASS_INIT(ACLFilledChecklist);
15
351fe86d
AR
16ACLFilledChecklist::ACLFilledChecklist() :
17 dst_peer(NULL),
12ef783b 18 dst_rdns(NULL),
351fe86d
AR
19 request (NULL),
20 reply (NULL),
2f1431ea 21#if USE_AUTH
351fe86d 22 auth_user_request (NULL),
2f1431ea 23#endif
351fe86d
AR
24#if SQUID_SNMP
25 snmp_community(NULL),
351fe86d 26#endif
fa24d749 27#if USE_SSL
7a957a93 28 sslErrors(NULL),
fa24d749 29#endif
351fe86d
AR
30 extacl_entry (NULL),
31 conn_(NULL),
32 fd_(-1),
33 destinationDomainChecked_(false),
34 sourceDomainChecked_(false)
35{
36 my_addr.SetEmpty();
37 src_addr.SetEmpty();
38 dst_addr.SetEmpty();
39 rfc931[0] = '\0';
40}
41
351fe86d
AR
42ACLFilledChecklist::~ACLFilledChecklist()
43{
44 assert (!asyncInProgress());
45
12ef783b
AJ
46 safe_free(dst_rdns); // created by xstrdup().
47
351fe86d
AR
48 if (extacl_entry)
49 cbdataReferenceDone(extacl_entry);
50
51 HTTPMSGUNLOCK(request);
52
53 HTTPMSGUNLOCK(reply);
54
351fe86d
AR
55 cbdataReferenceDone(conn_);
56
fa24d749 57#if USE_SSL
7a957a93 58 cbdataReferenceDone(sslErrors);
fa24d749 59#endif
4fb72cb9 60
351fe86d
AR
61 debugs(28, 4, HERE << "ACLFilledChecklist destroyed " << this);
62}
63
351fe86d
AR
64ConnStateData *
65ACLFilledChecklist::conn() const
66{
67 return conn_;
68}
69
70void
71ACLFilledChecklist::conn(ConnStateData *aConn)
72{
16a16ffe
CT
73 if (conn() == aConn)
74 return;
351fe86d
AR
75 assert (conn() == NULL);
76 conn_ = cbdataReference(aConn);
77}
78
79int
80ACLFilledChecklist::fd() const
81{
73c36fd9 82 return (conn_ != NULL && conn_->clientConnection != NULL) ? conn_->clientConnection->fd : fd_;
351fe86d
AR
83}
84
85void
86ACLFilledChecklist::fd(int aDescriptor)
87{
73c36fd9 88 assert(!conn() || conn()->clientConnection == NULL || conn()->clientConnection->fd == aDescriptor);
351fe86d
AR
89 fd_ = aDescriptor;
90}
91
92bool
93ACLFilledChecklist::destinationDomainChecked() const
94{
95 return destinationDomainChecked_;
96}
97
98void
99ACLFilledChecklist::markDestinationDomainChecked()
100{
101 assert (!finished() && !destinationDomainChecked());
102 destinationDomainChecked_ = true;
103}
104
105bool
106ACLFilledChecklist::sourceDomainChecked() const
107{
108 return sourceDomainChecked_;
109}
110
111void
112ACLFilledChecklist::markSourceDomainChecked()
113{
114 assert (!finished() && !sourceDomainChecked());
115 sourceDomainChecked_ = true;
116}
117
118/*
119 * There are two common ACLFilledChecklist lifecycles paths:
120 *
121 * A) Using aclCheckFast(): The caller creates an ACLFilledChecklist object
122 * on stack and calls aclCheckFast().
123 *
124 * B) Using aclNBCheck() and callbacks: The caller allocates an
125 * ACLFilledChecklist object (via operator new) and passes it to
126 * aclNBCheck(). Control eventually passes to ACLChecklist::checkCallback(),
127 * which will invoke the callback function as requested by the
128 * original caller of aclNBCheck(). This callback function must
129 * *not* delete the list. After the callback function returns,
130 * checkCallback() will delete the list (i.e., self).
131 */
f4462b38 132ACLFilledChecklist::ACLFilledChecklist(const acl_access *A, HttpRequest *http_request, const char *ident):
af6a12ee 133 dst_peer(NULL),
12ef783b 134 dst_rdns(NULL),
af6a12ee
AJ
135 request(NULL),
136 reply(NULL),
2f1431ea 137#if USE_AUTh
af6a12ee 138 auth_user_request(NULL),
2f1431ea 139#endif
351fe86d 140#if SQUID_SNMP
af6a12ee 141 snmp_community(NULL),
351fe86d 142#endif
fa24d749 143#if USE_SSL
7a957a93 144 sslErrors(NULL),
fa24d749 145#endif
af6a12ee
AJ
146 extacl_entry (NULL),
147 conn_(NULL),
148 fd_(-1),
149 destinationDomainChecked_(false),
150 sourceDomainChecked_(false)
351fe86d
AR
151{
152 my_addr.SetEmpty();
153 src_addr.SetEmpty();
154 dst_addr.SetEmpty();
155 rfc931[0] = '\0';
af6a12ee 156
351fe86d
AR
157 // cbdataReferenceDone() is in either fastCheck() or the destructor
158 if (A)
159 accessList = cbdataReference(A);
160
f4462b38 161 if (http_request != NULL) {
b248c2a3
AJ
162 request = http_request;
163 HTTPMSGLOCK(request);
351fe86d
AR
164#if FOLLOW_X_FORWARDED_FOR
165 if (Config.onoff.acl_uses_indirect_client)
166 src_addr = request->indirect_client_addr;
167 else
168#endif /* FOLLOW_X_FORWARDED_FOR */
169 src_addr = request->client_addr;
170 my_addr = request->my_addr;
16a16ffe
CT
171
172 if (request->clientConnectionManager.valid())
76fae079 173 conn(request->clientConnectionManager.get());
351fe86d
AR
174 }
175
176#if USE_IDENT
177 if (ident)
178 xstrncpy(rfc931, ident, USER_IDENT_SZ);
179#endif
180}