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