2 * Copyright (C) 1996-2016 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.
10 #include "acl/FilledChecklist.h"
11 #include "client_side.h"
12 #include "comm/Connection.h"
13 #include "comm/forward.h"
14 #include "ExternalACLEntry.h"
15 #include "HttpReply.h"
16 #include "HttpRequest.h"
17 #include "SquidConfig.h"
19 #include "auth/AclProxyAuth.h"
20 #include "auth/UserRequest.h"
23 CBDATA_CLASS_INIT(ACLFilledChecklist
);
25 ACLFilledChecklist::ACLFilledChecklist() :
30 auth_user_request (NULL
),
38 requestErrorType(ERR_MAX
),
41 destinationDomainChecked_(false),
42 sourceDomainChecked_(false)
50 ACLFilledChecklist::~ACLFilledChecklist()
52 assert (!asyncInProgress());
54 safe_free(dst_rdns
); // created by xstrdup().
56 HTTPMSGUNLOCK(request
);
60 cbdataReferenceDone(conn_
);
63 cbdataReferenceDone(sslErrors
);
66 debugs(28, 4, HERE
<< "ACLFilledChecklist destroyed " << this);
70 showDebugWarning(const char *msg
)
72 static uint16_t count
= 0;
77 debugs(28, DBG_IMPORTANT
, "ALE missing " << msg
);
81 ACLFilledChecklist::syncAle() const
83 // make sure the ALE fields used by Format::assemble to
84 // fill the old external_acl_type codes are set if any
85 // data on them exists in the Checklist
87 if (!al
->cache
.port
&& conn()) {
88 showDebugWarning("listening port");
89 al
->cache
.port
= conn()->port
;
94 showDebugWarning("HttpRequest object");
95 al
->request
= request
;
96 HTTPMSGLOCK(al
->request
);
99 if (!al
->adapted_request
) {
100 showDebugWarning("adapted HttpRequest object");
101 al
->adapted_request
= request
;
102 HTTPMSGLOCK(al
->adapted_request
);
106 showDebugWarning("URL");
107 al
->url
= xstrdup(request
->url
.absolute().c_str());
111 if (reply
&& !al
->reply
) {
112 showDebugWarning("HttpReply object");
114 HTTPMSGLOCK(al
->reply
);
118 if (*rfc931
&& !al
->cache
.rfc931
) {
119 showDebugWarning("IDENT");
120 al
->cache
.rfc931
= xstrdup(rfc931
);
126 ACLFilledChecklist::conn() const
132 ACLFilledChecklist::conn(ConnStateData
*aConn
)
136 assert (conn() == NULL
);
137 conn_
= cbdataReference(aConn
);
141 ACLFilledChecklist::fd() const
143 return (conn_
!= NULL
&& conn_
->clientConnection
!= NULL
) ? conn_
->clientConnection
->fd
: fd_
;
147 ACLFilledChecklist::fd(int aDescriptor
)
149 assert(!conn() || conn()->clientConnection
== NULL
|| conn()->clientConnection
->fd
== aDescriptor
);
154 ACLFilledChecklist::destinationDomainChecked() const
156 return destinationDomainChecked_
;
160 ACLFilledChecklist::markDestinationDomainChecked()
162 assert (!finished() && !destinationDomainChecked());
163 destinationDomainChecked_
= true;
167 ACLFilledChecklist::sourceDomainChecked() const
169 return sourceDomainChecked_
;
173 ACLFilledChecklist::markSourceDomainChecked()
175 assert (!finished() && !sourceDomainChecked());
176 sourceDomainChecked_
= true;
180 * There are two common ACLFilledChecklist lifecycles paths:
182 * A) Using aclCheckFast(): The caller creates an ACLFilledChecklist object
183 * on stack and calls aclCheckFast().
185 * B) Using aclNBCheck() and callbacks: The caller allocates an
186 * ACLFilledChecklist object (via operator new) and passes it to
187 * aclNBCheck(). Control eventually passes to ACLChecklist::checkCallback(),
188 * which will invoke the callback function as requested by the
189 * original caller of aclNBCheck(). This callback function must
190 * *not* delete the list. After the callback function returns,
191 * checkCallback() will delete the list (i.e., self).
193 ACLFilledChecklist::ACLFilledChecklist(const acl_access
*A
, HttpRequest
*http_request
, const char *ident
):
198 auth_user_request(NULL
),
201 snmp_community(NULL
),
206 requestErrorType(ERR_MAX
),
209 destinationDomainChecked_(false),
210 sourceDomainChecked_(false)
219 if (http_request
!= NULL
) {
220 request
= http_request
;
221 HTTPMSGLOCK(request
);
222 #if FOLLOW_X_FORWARDED_FOR
223 if (Config
.onoff
.acl_uses_indirect_client
)
224 src_addr
= request
->indirect_client_addr
;
226 #endif /* FOLLOW_X_FORWARDED_FOR */
227 src_addr
= request
->client_addr
;
228 my_addr
= request
->my_addr
;
230 if (request
->clientConnectionManager
.valid())
231 conn(request
->clientConnectionManager
.get());
236 xstrncpy(rfc931
, ident
, USER_IDENT_SZ
);