2 * Copyright (C) 1996-2014 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() :
31 auth_user_request (NULL
),
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 ACLFilledChecklist::conn() const
76 ACLFilledChecklist::conn(ConnStateData
*aConn
)
80 assert (conn() == NULL
);
81 conn_
= cbdataReference(aConn
);
85 ACLFilledChecklist::fd() const
87 return (conn_
!= NULL
&& conn_
->clientConnection
!= NULL
) ? conn_
->clientConnection
->fd
: fd_
;
91 ACLFilledChecklist::fd(int aDescriptor
)
93 assert(!conn() || conn()->clientConnection
== NULL
|| conn()->clientConnection
->fd
== aDescriptor
);
98 ACLFilledChecklist::destinationDomainChecked() const
100 return destinationDomainChecked_
;
104 ACLFilledChecklist::markDestinationDomainChecked()
106 assert (!finished() && !destinationDomainChecked());
107 destinationDomainChecked_
= true;
111 ACLFilledChecklist::sourceDomainChecked() const
113 return sourceDomainChecked_
;
117 ACLFilledChecklist::markSourceDomainChecked()
119 assert (!finished() && !sourceDomainChecked());
120 sourceDomainChecked_
= true;
124 * There are two common ACLFilledChecklist lifecycles paths:
126 * A) Using aclCheckFast(): The caller creates an ACLFilledChecklist object
127 * on stack and calls aclCheckFast().
129 * B) Using aclNBCheck() and callbacks: The caller allocates an
130 * ACLFilledChecklist object (via operator new) and passes it to
131 * aclNBCheck(). Control eventually passes to ACLChecklist::checkCallback(),
132 * which will invoke the callback function as requested by the
133 * original caller of aclNBCheck(). This callback function must
134 * *not* delete the list. After the callback function returns,
135 * checkCallback() will delete the list (i.e., self).
137 ACLFilledChecklist::ACLFilledChecklist(const acl_access
*A
, HttpRequest
*http_request
, const char *ident
):
143 auth_user_request(NULL
),
146 snmp_community(NULL
),
153 destinationDomainChecked_(false),
154 sourceDomainChecked_(false)
161 // cbdataReferenceDone() is in either fastCheck() or the destructor
163 accessList
= cbdataReference(A
);
165 if (http_request
!= NULL
) {
166 request
= http_request
;
167 HTTPMSGLOCK(request
);
168 #if FOLLOW_X_FORWARDED_FOR
169 if (Config
.onoff
.acl_uses_indirect_client
)
170 src_addr
= request
->indirect_client_addr
;
172 #endif /* FOLLOW_X_FORWARDED_FOR */
173 src_addr
= request
->client_addr
;
174 my_addr
= request
->my_addr
;
176 if (request
->clientConnectionManager
.valid())
177 conn(request
->clientConnectionManager
.get());
182 xstrncpy(rfc931
, ident
, USER_IDENT_SZ
);