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