host_addr = src;
if ( host_addr.IsAnyAddr() ) {
xstrncpy(host, src, SQUIDHOSTNAMELEN);
+ host_is_numeric = 0;
} else {
host_addr.ToHostname(host, SQUIDHOSTNAMELEN);
debugs(23, 3, "HttpRequest::SetHost() given IP: " << host_addr);
+ host_is_numeric = 1;
}
};
inline const char* GetHost(void) const { return host; };
+ inline const int GetHostIsNumeric(void) const { return host_is_numeric; };
#if USE_ADAPTATION
/// Returns possibly nil history, creating it if adapt. logging is enabled
private:
char host[SQUIDHOSTNAMELEN];
+ int host_is_numeric;
/***
* The client side connection data of pinned connections for the client side
{
assert(checklist != NULL && checklist->request != NULL);
- const ipcache_addrs *ia = NULL;
- const char *fqdn = NULL;
-
- if (data->match(checklist->request->GetHost()))
+ if (data->match(checklist->request->GetHost())) {
return 1;
+ }
+
+ /* numeric IPA? no, trust the above result. */
+ if(checklist->request->GetHostIsNumeric() == 0) {
+ return 0;
+ }
+
+ /* do we already have the rDNS? match on it if we do. */
+ if (checklist->dst_rdns) {
+ debugs(28, 3, "aclMatchAcl: '" << AclMatchedName << "' match with stored rDNS '" << checklist->dst_rdns << "' for '" << checklist->request->GetHost() << "'");
+ return data->match(checklist->dst_rdns);
+ }
- /* numeric IPA? */
- if ((ia = ipcacheCheckNumeric(checklist->request->GetHost())) == NULL)
+ /* raw IP without rDNS? look it up and wait for the result */
+ const ipcache_addrs *ia = ipcacheCheckNumeric(checklist->request->GetHost());
+ if (!ia) {
+ /* not a valid IPA */
+ checklist->dst_rdns = xstrdup("invalid");
return 0;
+ }
checklist->dst_addr = ia->in_addrs[0];
- fqdn = fqdncache_gethostbyaddr(checklist->dst_addr, FQDN_LOOKUP_IF_MISS);
+ const char *fqdn = fqdncache_gethostbyaddr(checklist->dst_addr, FQDN_LOOKUP_IF_MISS);
if (fqdn) {
+ checklist->dst_rdns = xstrdup(fqdn);
return data->match(fqdn);
} else if (!checklist->destinationDomainChecked()) {
/* FIXME: Using AclMatchedName here is not OO correct. Should find a way to the current acl */
ACLFilledChecklist::ACLFilledChecklist() :
dst_peer(NULL),
+ dst_rdns(NULL),
request (NULL),
reply (NULL),
auth_user_request (NULL),
{
assert (!asyncInProgress());
+ safe_free(dst_rdns); // created by xstrdup().
+
if (extacl_entry)
cbdataReferenceDone(extacl_entry);
*/
ACLFilledChecklist::ACLFilledChecklist(const acl_access *A, HttpRequest *http_request, const char *ident):
dst_peer(NULL),
+ dst_rdns(NULL),
request(NULL),
reply(NULL),
auth_user_request(NULL),