]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
dstdomain ACL does reverse lookup for ip addresses in urls
authorwessels <>
Wed, 18 Dec 1996 07:02:59 +0000 (07:02 +0000)
committerwessels <>
Wed, 18 Dec 1996 07:02:59 +0000 (07:02 +0000)
src/acl.cc
src/client_side.cc
src/ipcache.cc

index ba6a7bda4ff6494e7255f8e0bb8df5e1ca3f762b..5bfbd71080c8b8c0d12a5ece61765f8aa7592483 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: acl.cc,v 1.69 1996/12/17 21:16:53 wessels Exp $
+ * $Id: acl.cc,v 1.70 1996/12/18 00:02:59 wessels Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -905,7 +905,18 @@ aclMatchAcl(struct _acl *acl, aclCheck_t * checklist)
        }
        /* NOTREACHED */
     case ACL_DST_DOMAIN:
-       return aclMatchDomainList(acl->data, r->host);
+       if ((ia = ipcacheCheckNumeric(r->host)) == NULL)
+           return aclMatchDomainList(acl->data, r->host);
+       fqdn = fqdncache_gethostbyaddr(ia->in_addrs[0], FQDN_LOOKUP_IF_MISS);
+       if (fqdn)
+           return aclMatchDomainList(acl->data, fqdn);
+       if (checklist->state[ACL_DST_DOMAIN] == ACL_LOOKUP_NONE) {
+           debug(28, 3, "aclMatchAcl: Can't yet compare '%s' ACL for '%s'\n",
+               acl->name, inet_ntoa(ia->in_addrs[0]));
+           checklist->state[ACL_DST_DOMAIN] = ACL_LOOKUP_NEED;
+           return 0;
+       }
+       return aclMatchDomainList(acl->data, "none");
        /* NOTREACHED */
     case ACL_SRC_DOMAIN:
        fqdn = fqdncache_gethostbyaddr(checklist->src_addr, FQDN_LOOKUP_IF_MISS);
index b35a7d73b2359a0399e5ae15a0e25bebac4013c3..1bc892ec694bb5329a48df9c4be1589758362c6d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.76 1996/12/17 21:16:54 wessels Exp $
+ * $Id: client_side.cc,v 1.77 1996/12/18 00:03:00 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -35,6 +35,7 @@ static void clientRedirectDone _PARAMS((void *data, char *result));
 static void icpHandleIMSReply _PARAMS((int fd, StoreEntry * entry, void *data));
 static void clientLookupDstIPDone _PARAMS((int fd, const ipcache_addrs *, void *data));
 static void clientLookupSrcFQDNDone _PARAMS((int fd, const char *fqdn, void *data));
+static void clientLookupDstFQDNDone _PARAMS((int fd, const char *fqdn, void *data));
 static int clientGetsOldEntry _PARAMS((StoreEntry * new, StoreEntry * old, request_t * request));
 static int checkAccelOnly _PARAMS((icpStateData * icpState));
 
@@ -68,6 +69,18 @@ clientLookupSrcFQDNDone(int fd, const char *fqdn, void *data)
     clientAccessCheck(icpState, icpState->aclHandler);
 }
 
+static void
+clientLookupDstFQDNDone(int fd, const char *fqdn, void *data)
+{
+    icpStateData *icpState = data;
+    debug(33, 0, "clientLookupDstFQDNDone: FD %d, '%s', FQDN %s\n",
+       fd,
+       icpState->url,
+       fqdn ? fqdn : "NULL");
+    icpState->aclChecklist->state[ACL_SRC_DOMAIN] = ACL_LOOKUP_DONE;
+    clientAccessCheck(icpState, icpState->aclHandler);
+}
+
 static void
 clientLookupIdentDone(void *data)
 {
@@ -125,6 +138,7 @@ clientAccessCheck(icpStateData * icpState, void (*handler) (icpStateData *, int)
     int answer = 1;
     aclCheck_t *ch = NULL;
     char *browser = NULL;
+    const ipcache_addrs *ia = NULL;
 
     if (Config.identLookup && icpState->ident.state == IDENT_NONE) {
        icpState->aclHandler = handler;
@@ -182,6 +196,15 @@ clientAccessCheck(icpStateData * icpState, void (*handler) (icpStateData *, int)
                clientLookupSrcFQDNDone,
                icpState);
            return;
+       } else if (ch->state[ACL_DST_DOMAIN] == ACL_LOOKUP_NEED) {
+           ch->state[ACL_DST_DOMAIN] = ACL_LOOKUP_PENDING;     /* first */
+           ia = ipcacheCheckNumeric(icpState->request->host);
+           if (ia != NULL)
+           fqdncache_nbgethostbyaddr(ia->in_addrs[0],
+               icpState->fd,
+               clientLookupDstFQDNDone,
+               icpState);
+           return;
        }
     }
     requestUnlink(icpState->aclChecklist->request);
index 534439fd5b4f4fa5ca3355194603615ce29ca309..813ce84d8f29fa69cd2ab2e2c6d82412ab17ff7e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ipcache.cc,v 1.89 1996/11/24 04:33:00 wessels Exp $
+ * $Id: ipcache.cc,v 1.90 1996/12/18 00:03:00 wessels Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -155,7 +155,6 @@ static void ipcacheAddPending _PARAMS((ipcache_entry *, int fd, IPH, void *));
 static void ipcacheEnqueue _PARAMS((ipcache_entry *));
 static void *ipcacheDequeue _PARAMS((void));
 static void ipcache_dnsDispatch _PARAMS((dnsserver_t *, ipcache_entry *));
-static ipcache_addrs *ipcacheCheckNumeric _PARAMS((const char *name));
 static void ipcacheStatPrint _PARAMS((ipcache_entry *, StoreEntry *));
 static void ipcacheUnlockEntry _PARAMS((ipcache_entry *));
 static void ipcacheLockEntry _PARAMS((ipcache_entry *));
@@ -966,7 +965,7 @@ ipcacheInvalidate(const char *name)
      * FMR */
 }
 
-static ipcache_addrs *
+ipcache_addrs *
 ipcacheCheckNumeric(const char *name)
 {
     unsigned int ip;