]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
added myip ACL type (luyer)
authorwessels <>
Sat, 30 Jan 1999 04:28:06 +0000 (04:28 +0000)
committerwessels <>
Sat, 30 Jan 1999 04:28:06 +0000 (04:28 +0000)
15 files changed:
src/acl.cc
src/asn.cc
src/cf.data.pre
src/client_side.cc
src/enums.h
src/forward.cc
src/icp_v2.cc
src/icp_v3.cc
src/neighbors.cc
src/net_db.cc
src/peer_digest.cc
src/peer_select.cc
src/protos.h
src/structs.h
src/urn.cc

index 2c404158527c60288d7e29581160b022dd6c4488..96f478ff713256762de2c39de800cffa09c6619d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: acl.cc,v 1.196 1999/01/24 04:03:48 wessels Exp $
+ * $Id: acl.cc,v 1.197 1999/01/29 21:28:06 wessels Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -153,6 +153,8 @@ aclStrToType(const char *s)
        return ACL_SRC_IP;
     if (!strcmp(s, "dst"))
        return ACL_DST_IP;
+    if (!strcmp(s, "myip"))
+       return ACL_MY_IP;
     if (!strcmp(s, "domain"))
        return ACL_DST_DOMAIN;
     if (!strcmp(s, "dstdomain"))
@@ -209,6 +211,8 @@ aclTypeToStr(squid_acl type)
        return "src";
     if (type == ACL_DST_IP)
        return "dst";
+    if (type == ACL_MY_IP)
+       return "myip";
     if (type == ACL_DST_DOMAIN)
        return "dstdomain";
     if (type == ACL_SRC_DOMAIN)
@@ -672,6 +676,7 @@ aclParseAclLine(acl ** head)
     switch (A->type) {
     case ACL_SRC_IP:
     case ACL_DST_IP:
+    case ACL_MY_IP:
        aclParseIpList(&A->data);
        break;
     case ACL_SRC_DOMAIN:
@@ -1228,6 +1233,9 @@ aclMatchAcl(acl * ae, aclCheck_t * checklist)
     case ACL_SRC_IP:
        return aclMatchIp(&ae->data, checklist->src_addr);
        /* NOTREACHED */
+    case ACL_MY_IP:
+       return aclMatchIp(&ae->data, checklist->my_addr);
+       /* NOTREACHED */
     case ACL_DST_IP:
        ia = ipcache_gethostbyname(r->host, IP_LOOKUP_IF_MISS);
        if (ia) {
@@ -1659,6 +1667,7 @@ aclCheck_t *
 aclChecklistCreate(const acl_access * A,
     request_t * request,
     struct in_addr src_addr,
+    struct in_addr my_addr,
     const char *user_agent,
     const char *ident)
 {
@@ -1674,6 +1683,7 @@ aclChecklistCreate(const acl_access * A,
     if (request != NULL)
        checklist->request = requestLink(request);
     checklist->src_addr = src_addr;
+    checklist->my_addr = my_addr;
     for (i = 0; i < ACL_ENUM_MAX; i++)
        checklist->state[i] = ACL_LOOKUP_NONE;
     if (user_agent)
@@ -1753,6 +1763,7 @@ aclDestroyAcls(acl ** head)
        switch (a->type) {
        case ACL_SRC_IP:
        case ACL_DST_IP:
+       case ACL_MY_IP:
            splay_destroy(a->data, aclFreeIpData);
            break;
        case ACL_SRC_ARP:
@@ -2082,6 +2093,7 @@ aclDumpGeneric(const acl * a)
     switch (a->type) {
     case ACL_SRC_IP:
     case ACL_DST_IP:
+    case ACL_MY_IP:
        return aclDumpIpList(a->data);
        break;
     case ACL_SRC_DOMAIN:
index 26cfcbef9c58f137399cd0366985b3e689fb4d10..5f17c00244a915ddf7778406ee904d3eaf79fbbe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: asn.cc,v 1.55 1999/01/19 16:35:13 wessels Exp $
+ * $Id: asn.cc,v 1.56 1999/01/29 21:28:07 wessels Exp $
  *
  * DEBUG: section 53    AS Number handling
  * AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -196,7 +196,7 @@ asnCacheStart(int as)
     if ((e = storeGetPublic(asres, METHOD_GET)) == NULL) {
        e = storeCreateEntry(asres, asres, null_request_flags, METHOD_GET);
        storeClientListAdd(e, asState);
-       fwdStart(-1, e, asState->request, no_addr);
+       fwdStart(-1, e, asState->request, no_addr, no_addr);
     } else {
        storeLockObject(e);
        storeClientListAdd(e, asState);
index 23c27a6efa03b24e5a6de7080e5904908c83fffc..eb002c7eb77b723ca85731c66c1fb4f7bd39343a 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.141 1999/01/29 21:05:21 wessels Exp $
+# $Id: cf.data.pre,v 1.142 1999/01/29 21:28:08 wessels Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1413,6 +1413,7 @@ DOC_START
        acl aclname src      ip-address/netmask ... (clients IP address)
        acl aclname src      addr1-addr2/netmask ... (range of addresses)
        acl aclname dst      ip-address/netmask ... (URL host's IP address)
+       acl aclname myip     ip-address/netmask ... (local socket IP address)
 
        acl aclname srcdomain   foo.com ...     # reverse lookup, client IP
        acl aclname dstdomain   foo.com ...     # Destination server from URL
index ed743cab72ec3b1673b599e14c1b292ddb0990a3..87d17ce89b328fcee2886a98de3b029317d75543 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.437 1999/01/24 04:03:50 wessels Exp $
+ * $Id: client_side.cc,v 1.438 1999/01/29 21:28:10 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -133,6 +133,7 @@ clientAccessCheck(void *data)
     http->acl_checklist = aclChecklistCreate(Config.accessList.http,
        http->request,
        conn->peer.sin_addr,
+       conn->me.sin_addr,
        browser,
        conn->ident);
 #if USE_IDENT
@@ -304,7 +305,7 @@ clientProcessExpired(void *data)
     http->entry = entry;
     http->out.offset = 0;
     fwdStart(http->conn->fd, http->entry, http->request,
-       http->conn->peer.sin_addr);
+       http->conn->peer.sin_addr, http->conn->me.sin_addr);
     /* Register with storage manager to receive updates when data comes in. */
     if (EBIT_TEST(entry->flags, ENTRY_ABORTED))
        debug(33, 0) ("clientProcessExpired: found ENTRY_ABORTED object\n");
@@ -852,6 +853,7 @@ clientCachable(clientHttpRequest * http)
      * This may not work yet for 'dst' and 'dst_domain' ACLs.
      */
     ch.src_addr = http->conn->peer.sin_addr;
+    ch.my_addr = http->conn->me.sin_addr;
     ch.request = http->request;
     /*
      * aclCheckFast returns 1 for ALLOW and 0 for DENY.  The default
@@ -1860,7 +1862,8 @@ clientProcessMiss(clientHttpRequest * http)
     }
     if (http->flags.internal)
        r->protocol = PROTO_INTERNAL;
-    fwdStart(http->conn->fd, http->entry, r, http->conn->peer.sin_addr);
+    fwdStart(http->conn->fd, http->entry, r,
+       http->conn->peer.sin_addr, http->conn->me.sin_addr);
 }
 
 static clientHttpRequest *
index d428959d46a4d1466d08dfc3bc49d4d2c6247958..c1b3a159edb749f06935ba90ba467cf760a3f2cb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.144 1999/01/24 04:03:51 wessels Exp $
+ * $Id: enums.h,v 1.145 1999/01/29 21:28:11 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -89,6 +89,7 @@ typedef enum {
     ACL_NONE,
     ACL_SRC_IP,
     ACL_DST_IP,
+    ACL_MY_IP,
     ACL_SRC_DOMAIN,
     ACL_DST_DOMAIN,
     ACL_SRC_DOM_REGEX,
index 858b979bb8df76ce9df4cd4fa27d4fbac98ca954..06eb2b57566b640b176d589287511e92444a048c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.52 1999/01/19 19:23:27 wessels Exp $
+ * $Id: forward.cc,v 1.53 1999/01/29 21:28:12 wessels Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -384,7 +384,8 @@ fwdReforward(FwdState * fwdState)
 /* PUBLIC FUNCTIONS */
 
 void
-fwdStart(int fd, StoreEntry * e, request_t * r, struct in_addr client_addr)
+fwdStart(int fd, StoreEntry * e, request_t * r, struct in_addr client_addr,
+    struct in_addr my_addr)
 {
     FwdState *fwdState;
     aclCheck_t ch;
@@ -401,6 +402,7 @@ fwdStart(int fd, StoreEntry * e, request_t * r, struct in_addr client_addr)
         */
        memset(&ch, '\0', sizeof(aclCheck_t));
        ch.src_addr = client_addr;
+       ch.my_addr = my_addr;
        ch.request = r;
        answer = aclCheckFast(Config.accessList.miss, &ch);
        if (answer == 0) {
index c7c3695953ca1f54d5020eb32bb037ec074b2a91..6b16c821eeaff24f06d1121f0ced76428ed77fca 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icp_v2.cc,v 1.57 1999/01/11 23:29:42 wessels Exp $
+ * $Id: icp_v2.cc,v 1.58 1999/01/29 21:28:13 wessels Exp $
  *
  * DEBUG: section 12    Internet Cache Protocol
  * AUTHOR: Duane Wessels
@@ -218,6 +218,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
            break;
        }
        checklist.src_addr = from.sin_addr;
+       checklist.my_addr = no_addr;
        checklist.request = icp_request;
        allow = aclCheckFast(Config.accessList.icp, &checklist);
        if (!allow) {
index 181b80dcc1abc4fba95079c44e36664c39c5df9e..4213a9a9fa39b4cf48fa72926a67264e8dec3605 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icp_v3.cc,v 1.27 1998/12/05 00:54:30 wessels Exp $
+ * $Id: icp_v3.cc,v 1.28 1999/01/29 21:28:14 wessels Exp $
  *
  * DEBUG: section 12    Internet Cache Protocol
  * AUTHOR: Duane Wessels
@@ -72,6 +72,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
            break;
        }
        checklist.src_addr = from.sin_addr;
+       checklist.my_addr = no_addr;
        checklist.request = icp_request;
        allow = aclCheckFast(Config.accessList.icp, &checklist);
        if (!allow) {
index cd48e048dd93899f5b16ec54a0d17d0cb722fcd9..bf3b46e61495dc753e362cc18123fd220df0f6c5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: neighbors.cc,v 1.267 1999/01/11 16:50:33 wessels Exp $
+ * $Id: neighbors.cc,v 1.268 1999/01/29 21:28:15 wessels Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -147,6 +147,7 @@ peerAllowedToUse(const peer * p, request_t * request)
     if (p->access == NULL)
        return do_ping;
     checklist.src_addr = request->client_addr;
+    checklist.my_addr = no_addr;       /* XXX wrong */
     checklist.request = request;
     return aclCheckFast(p->access, &checklist);
 }
index ee41bd1fd6400a96264f3ee0a5dc3d823683df7f..08f5e5b4f7cfcc67cd44505fa9502b89e8d472ab 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.135 1999/01/11 16:50:35 wessels Exp $
+ * $Id: net_db.cc,v 1.136 1999/01/29 21:28:16 wessels Exp $
  *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -971,7 +971,7 @@ netdbExchangeStart(void *data)
     storeClientCopy(ex->e, ex->seen, ex->used, ex->buf_sz,
        ex->buf, netdbExchangeHandleReply, ex);
     ex->r->flags.loopdetect = 1;       /* cheat! -- force direct */
-    fwdStart(-1, ex->e, ex->r, no_addr);
+    fwdStart(-1, ex->e, ex->r, no_addr, no_addr);
 #endif
 }
 
index 00af1f49b2a8c1feb1f966e4b2d0c9fa1bb8d098..14204b1cd9a090274d6c92868b741ff5f5e29879 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_digest.cc,v 1.69 1999/01/11 16:50:36 wessels Exp $
+ * $Id: peer_digest.cc,v 1.70 1999/01/29 21:28:17 wessels Exp $
  *
  * DEBUG: section 72    Peer Digest Routines
  * AUTHOR: Alex Rousskov
@@ -317,7 +317,7 @@ peerDigestRequest(PeerDigest * pd)
 
     /* push towards peer cache */
     debug(72, 3) ("peerDigestRequest: forwarding to fwdStart...\n");
-    fwdStart(-1, e, req, no_addr);
+    fwdStart(-1, e, req, no_addr, no_addr);
     cbdataLock(fetch);
     cbdataLock(fetch->pd);
     storeClientCopy(e, 0, 0, 4096, memAllocate(MEM_4K_BUF),
index 3f1194508d6dfc0217fb46badc8cd5aa5487d744..b1af9d371789699a66e32708553f138f98eb5bc9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_select.cc,v 1.96 1999/01/29 17:20:56 wessels Exp $
+ * $Id: peer_select.cc,v 1.97 1999/01/29 21:28:18 wessels Exp $
  *
  * DEBUG: section 44    Peer Selection Algorithm
  * AUTHOR: Duane Wessels
@@ -237,6 +237,7 @@ peerSelectFoo(ps_state * ps)
                Config.accessList.AlwaysDirect,
                request,
                request->client_addr,
+               no_addr,        /* XXX wrong */
                NULL,           /* user agent */
                NULL);          /* ident */
            aclNBCheck(ps->acl_checklist,
@@ -250,6 +251,7 @@ peerSelectFoo(ps_state * ps)
                Config.accessList.NeverDirect,
                request,
                request->client_addr,
+               no_addr,        /* XXX wrong */
                NULL,           /* user agent */
                NULL);          /* ident */
            aclNBCheck(ps->acl_checklist,
index 87b5d910cbffc17e590b18d7b4a9edf988739ccf..4087a5e274306a403047339e70fc56bfc94b6a3e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.312 1999/01/24 04:03:53 wessels Exp $
+ * $Id: protos.h,v 1.313 1999/01/29 21:28:19 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -45,6 +45,7 @@ extern void fvdbCountForw(const char *key);
 extern aclCheck_t *aclChecklistCreate(const struct _acl_access *,
     request_t *,
     struct in_addr src,
+    struct in_addr me,
     const char *user_agent,
     const char *ident);
 extern void aclNBCheck(aclCheck_t *, PF *, void *);
@@ -651,7 +652,7 @@ extern void peerDigestNotePeerGone(PeerDigest * pd);
 extern void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e);
 
 /* forward.c */
-extern void fwdStart(int, StoreEntry *, request_t *, struct in_addr);
+extern void fwdStart(int, StoreEntry *, request_t *, struct in_addr, struct in_addr);
 extern DEFER fwdCheckDeferRead;
 extern void fwdFail(FwdState *, ErrorState *);
 extern void fwdUnregister(int fd, FwdState *);
index 0ec3d9e802285cee6ec18e1823fbf264a8deb5d7..da9f5407a1fa2d8f94efcf2f565285f86965950e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.273 1999/01/24 04:03:54 wessels Exp $
+ * $Id: structs.h,v 1.274 1999/01/29 21:28:21 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -141,6 +141,7 @@ struct _aclCheck_t {
     const acl_access *access_list;
     struct in_addr src_addr;
     struct in_addr dst_addr;
+    struct in_addr my_addr;
     request_t *request;
 #if USE_IDENT
     ConnStateData *conn;       /* hack for ident */
index a462d414039463e88fbad4abb433023f2f7cdb1c..e6405c27f502b15ffe1089a9009d1ea2550e53e7 100644 (file)
@@ -1,7 +1,7 @@
 
 /*
  *
- * $Id: urn.cc,v 1.50 1999/01/11 16:50:43 wessels Exp $
+ * $Id: urn.cc,v 1.51 1999/01/29 21:28:22 wessels Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
@@ -138,7 +138,7 @@ urnStart(request_t * r, StoreEntry * e)
     if ((urlres_e = storeGetPublic(urlres, METHOD_GET)) == NULL) {
        urlres_e = storeCreateEntry(urlres, urlres, null_request_flags, METHOD_GET);
        storeClientListAdd(urlres_e, urnState);
-       fwdStart(-1, urlres_e, urlres_r, no_addr);
+       fwdStart(-1, urlres_e, urlres_r, no_addr, no_addr);
     } else {
        storeLockObject(urlres_e);
        storeClientListAdd(urlres_e, urnState);