]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
clean up aclParseIpList() a bit
authorwessels <>
Sat, 11 Jan 1997 06:14:20 +0000 (06:14 +0000)
committerwessels <>
Sat, 11 Jan 1997 06:14:20 +0000 (06:14 +0000)
add '!' for firewall_ip_list
add udp_hit_obj_size option
fix cachemgr.cgi to print 'NEVER' instead of '27Y ago'
set ICP_FLAG_NETDB_GUNK in replies
initialize icpState->ident.fd to -1.

src/acl.cc
src/cache_cf.cc
src/cachemgr.cc
src/store.cc

index 762d2541595060e91a56c490ac764c0368cad7a5..194e8e40376c8e7348b85dfb3c06a5d9efbf3d93 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: acl.cc,v 1.72 1997/01/10 18:48:42 wessels Exp $
+ * $Id: acl.cc,v 1.73 1997/01/10 23:14:20 wessels Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -255,88 +255,81 @@ decode_addr(const char *asc, struct in_addr *addr, struct in_addr *mask)
     return 1;
 }
 
+static struct _acl_ip_data *
+aclParseIpData(const char *t)
+{
+    LOCAL_ARRAY(char, addr1, 256);
+    LOCAL_ARRAY(char, addr2, 256);
+    LOCAL_ARRAY(char, mask, 256);
+    struct _acl_ip_data *q = xcalloc(1, sizeof(struct _acl_ip_data));
+    if (!strcasecmp(t, "all")) {
+       q->addr1.s_addr = 0;
+       q->addr2.s_addr = 0;
+       q->mask.s_addr = 0;
+       return q;
+    }
+    memset(addr1, 0, 256);
+    memset(addr2, 0, 256);
+    memset(mask, 0, 256);
+    if (sscanf(t, "%[0-9.]-%[0-9.]/%[0-9.]", addr1, addr2, mask) == 3) {
+       (void) 0;
+    } else if (sscanf(t, "%[0-9.]-%[0-9.]", addr1, addr2) == 2) {
+       mask[0] = '\0';
+    } else if (sscanf(t, "%[0-9.]/%[0-9.]", addr1, mask) == 2) {
+       addr2[0] = '\0';
+    } else if (sscanf(t, "%[0-9.]", addr1) == 1) {
+       addr2[0] = '\0';
+       mask[0] = '\0';
+    } else if (sscanf(t, "%[^/]/%s", addr1, mask) == 2) {
+       addr2[0] = '\0';
+    } else if (sscanf(t, "%s", addr1) == 1) {
+       addr2[0] = '\0';
+       mask[0] = '\0';
+    } else {
+       debug(28, 0, "aclParseIpList: Bad host/IP: '%s'\n", t);
+       safe_free(q);
+       return NULL;
+    }
+    /* Decode addr1 */
+    if (!decode_addr(addr1, &q->addr1, &q->mask)) {
+       debug(28, 0, "%s line %d: %s\n",
+           cfg_filename, config_lineno, config_input_line);
+       debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry: unknown first address '%s'\n", addr1);
+       safe_free(q);
+       return NULL;
+    }
+    /* Decode addr2 */
+    if (*addr2 && !decode_addr(addr2, &q->addr2, &q->mask)) {
+       debug(28, 0, "%s line %d: %s\n",
+           cfg_filename, config_lineno, config_input_line);
+       debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry: unknown second address '%s'\n", addr2);
+       safe_free(q);
+       return NULL;
+    }
+    /* Decode mask */
+    if (*mask && !decode_addr(mask, &q->mask, NULL)) {
+       debug(28, 0, "%s line %d: %s\n",
+           cfg_filename, config_lineno, config_input_line);
+       debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry: unknown netmask '%s'\n", mask);
+       safe_free(q);
+       return NULL;
+    }
+    q->addr1.s_addr &= q->mask.s_addr;
+    q->addr2.s_addr &= q->mask.s_addr;
+    /* 1.2.3.4/255.255.255.0  --> 1.2.3.0 */
+    return q;
+}
 
 static struct _acl_ip_data *
 aclParseIpList(void)
 {
     char *t = NULL;
-    char *p = NULL;
     struct _acl_ip_data *head = NULL;
     struct _acl_ip_data **Tail = &head;
     struct _acl_ip_data *q = NULL;
-    LOCAL_ARRAY(char, addr1, 256);
-    LOCAL_ARRAY(char, addr2, 256);
-    LOCAL_ARRAY(char, mask, 256);
-
     while ((t = strtokFile())) {
-       q = xcalloc(1, sizeof(struct _acl_ip_data));
-       if (!strcasecmp(t, "all")) {
-           q->addr1.s_addr = 0;
-           q->addr2.s_addr = 0;
-           q->mask.s_addr = 0;
-       } else {
-           p = t;
-           memset(addr1, 0, 256);
-           memset(addr2, 0, 256);
-           memset(mask, 0, 256);
-
-           for (;;) {
-               if (sscanf(t, "%[0-9.]-%[0-9.]/%[0-9.]", addr1, addr2, mask) == 3)
-                   break;
-               if (sscanf(t, "%[0-9.]-%[0-9.]", addr1, addr2) == 2) {
-                   mask[0] = '\0';
-                   break;
-               }
-               if (sscanf(t, "%[0-9.]/%[0-9.]", addr1, mask) == 2) {
-                   addr2[0] = '\0';
-                   break;
-               }
-               if (sscanf(t, "%[0-9.]", addr1) == 1) {
-                   addr2[0] = '\0';
-                   mask[0] = '\0';
-                   break;
-               }
-               if (sscanf(t, "%[^/]/%s", addr1, mask) == 2) {
-                   addr2[0] = '\0';
-                   break;
-               }
-               if (sscanf(t, "%s", addr1) == 1) {
-                   addr2[0] = '\0';
-                   mask[0] = '\0';
-                   break;
-               }
-               debug(28, 0, "aclParseIpList: Bad host/IP: '%s'\n", t);
-               break;
-           }
-
-           /* Decode addr1 */
-           if (!decode_addr(addr1, &q->addr1, &q->mask)) {
-               debug(28, 0, "%s line %d: %s\n",
-                   cfg_filename, config_lineno, config_input_line);
-               debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry: unknown first address '%s'\n", addr1);
-               safe_free(q);
-               continue;
-           }
-           /* Decode addr2 */
-           if (*addr2 && !decode_addr(addr2, &q->addr2, &q->mask)) {
-               debug(28, 0, "%s line %d: %s\n",
-                   cfg_filename, config_lineno, config_input_line);
-               debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry: unknown second address '%s'\n", addr2);
-               safe_free(q);
+       if ((q = aclParseIpData(t)) == NULL)
                continue;
-           }
-           /* Decode mask */
-           if (*mask && !decode_addr(mask, &q->mask, NULL)) {
-               debug(28, 0, "%s line %d: %s\n",
-                   cfg_filename, config_lineno, config_input_line);
-               debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry: unknown netmask '%s'\n", mask);
-               safe_free(q);
-               continue;
-           }
-           q->addr1.s_addr &= q->mask.s_addr;
-           q->addr2.s_addr &= q->mask.s_addr;
-           /* 1.2.3.4/255.255.255.0  --> 1.2.3.0 */
-       }
        *(Tail) = q;
        Tail = &q->next;
     }
index 9935251fc06e595d6cb74f39615a86e8d620d11e..1e2e809044da4b8e06f413d6a6f317e6e72bc9f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cache_cf.cc,v 1.161 1996/12/21 07:54:50 wessels Exp $
+ * $Id: cache_cf.cc,v 1.162 1997/01/10 23:14:22 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -181,6 +181,7 @@ struct SquidConfig Config;
 #define DefaultAnnounceFile    (char *)NULL    /* default NONE */
 #define DefaultAnnounceRate    0       /* Default off */
 #define DefaultTcpRcvBufsz     0       /* use system default */
+#define DefaultUdpMaxHitObjsz  SQUID_UDP_SO_SNDBUF     /* from configure */
 #define DefaultTcpIncomingAddr INADDR_ANY
 #define DefaultTcpOutgoingAddr inaddr_none
 #define DefaultUdpIncomingAddr INADDR_ANY
@@ -331,6 +332,7 @@ addToIPACL(ip_acl ** list, const char *ip_str, ip_access_type access)
     int a1, a2, a3, a4;
     int m1, m2, m3, m4;
     struct in_addr lmask;
+    int inv = 0;
     int c;
 
     if (!ip_str) {
@@ -351,8 +353,11 @@ addToIPACL(ip_acl ** list, const char *ip_str, ip_access_type access)
        p->next = q;
     }
 
-
     /* decode ip address */
+    if (*ip_str == '!') {
+       ip_str++;
+       inv = 1;
+    }
     if (!strcasecmp(ip_str, "all")) {
        a1 = a2 = a3 = a4 = 0;
        lmask.s_addr = 0;
@@ -395,7 +400,8 @@ addToIPACL(ip_acl ** list, const char *ip_str, ip_access_type access)
        }
     }
 
-    q->access = access;
+    if (inv)
+       q->access = (access == IP_ALLOW) ? IP_DENY : IP_ALLOW;
     q->addr.s_addr = htonl(a1 * 0x1000000 + a2 * 0x10000 + a3 * 0x100 + a4);
     q->mask.s_addr = lmask.s_addr;
 }
@@ -1343,6 +1349,8 @@ parseConfigFile(const char *file_name)
            parseOnOff(&opt_mem_pools);
        else if (!strcmp(token, "udp_hit_obj"))
            parseOnOff(&opt_udp_hit_obj);
+        else if (!strcmp(token, "udp_hit_obj_size"))
+            parseIntegerValue(&Config.udpMaxHitObjsz);
        else if (!strcmp(token, "forwarded_for"))
            parseOnOff(&opt_forwarded_for);
        else if (!strcmp(token, "log_icp_queries"))
@@ -1561,6 +1569,7 @@ configSetFactoryDefaults(void)
     Config.Announce.rate = DefaultAnnounceRate;
     Config.Announce.on = 0;
     Config.tcpRcvBufsz = DefaultTcpRcvBufsz;
+    Config.udpMaxHitObjsz = DefaultUdpMaxHitObjsz;
     Config.Addrs.tcp_outgoing.s_addr = DefaultTcpOutgoingAddr;
     Config.Addrs.tcp_incoming.s_addr = DefaultTcpIncomingAddr;
     Config.Addrs.udp_outgoing.s_addr = DefaultUdpOutgoingAddr;
@@ -1595,4 +1604,6 @@ configDoConfigure(void)
        getMyHostname(),
        (int) Config.Port.http,
        SQUID_VERSION);
+    if (!Config.udpMaxHitObjsz || Config.udpMaxHitObjsz > SQUID_UDP_SO_SNDBUF)
+       Config.udpMaxHitObjsz = SQUID_UDP_SO_SNDBUF;
 }
index 58442ab9cd34d6d6549c808538c933e42cf3018a..ef18a0850d52f43ae90ddc1d4cd47238e68aab6e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cachemgr.cc,v 1.51 1997/01/03 22:43:54 wessels Exp $
+ * $Id: cachemgr.cc,v 1.52 1997/01/10 23:14:23 wessels Exp $
  *
  * DEBUG: section 0     CGI Cache Manager
  * AUTHOR: Harvest Derived
@@ -497,6 +497,8 @@ describeTimeSince(time_t then)
        delta = (-delta);
        fmt = "in %s";
     }
+    if (then < 0)
+       return "NEVER";
     if (delta < ONE_MINUTE)
        sprintf(buf, "%ds", (int) (delta / ONE_SECOND));
     else if (delta < ONE_HOUR)
index aa1d04b6c1a9c50e0a99d4965a8507da687c339d..087e190e9e9ff31fe401908b17dc7452355c4c69 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.189 1997/01/07 03:37:42 wessels Exp $
+ * $Id: store.cc,v 1.190 1997/01/10 23:14:27 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -1888,7 +1888,6 @@ storeGetBucketNum(void)
     return (bucket++);
 }
 
-#define SWAP_LRUSCAN_BLOCK 16
 #define SWAP_MAX_HELP (store_buckets/2)
 
 /* The maximum objects to scan for maintain storage space */