]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
finish up ACL implementation
authorwessels <>
Fri, 12 Apr 1996 04:52:24 +0000 (04:52 +0000)
committerwessels <>
Fri, 12 Apr 1996 04:52:24 +0000 (04:52 +0000)
src/acl.cc
src/cache_cf.cc
src/errorpage.cc
src/http.cc
src/ipcache.cc
src/squid.h
src/stat.cc
src/url.cc

index 9c4f7e4f22f43e2829df7463c3ebda078427244c..5a81237cb6ee091d5c591299ab5a92440664962b 100644 (file)
@@ -1,4 +1,4 @@
-#ident "$Id: acl.cc,v 1.7 1996/04/11 19:23:36 wessels Exp $"
+#ident "$Id: acl.cc,v 1.8 1996/04/11 22:52:24 wessels Exp $"
 
 /*
  * DEBUG: Section 28          acl
@@ -6,11 +6,16 @@
 
 #include "squid.h"
 
-static struct _acl_access *AccessList = NULL;
-static struct _acl_access **AccessListTail = &AccessList;
+/* These two should never be referenced directly in this file! */
+struct _acl_access *HTTPAccessList = NULL;
+struct _acl_access *ICPAccessList = NULL;
+
 static struct _acl *AclList = NULL;
 static struct _acl **AclListTail = &AclList;
 
+static int aclMatchAcl _PARAMS((struct _acl *, struct in_addr, method_t, protocol_t, char *host, int port, char *request));
+static int aclMatchAclList _PARAMS((struct _acl_list *, struct in_addr, method_t, protocol_t, char *host, int port, char *request));
+
 static acl_t aclType(s)
      char *s;
 {
@@ -28,6 +33,8 @@ static acl_t aclType(s)
        return ACL_USER;
     if (!strcmp(s, "proto"))
        return ACL_PROTO;
+    if (!strcmp(s, "method"))
+       return ACL_METHOD;
     return ACL_NONE;
 }
 
@@ -65,12 +72,28 @@ intlist *aclParseProtoList()
     char *t = NULL;
     while ((t = strtok(NULL, w_space))) {
        q = (intlist *) xcalloc(1, sizeof(intlist));
-       q->i = proto_url_to_id(t);
+       q->i = (int) urlParseProtocol(t);
        *(Tail) = q;
        Tail = &q->next;
     }
     return head;
 }
+
+intlist *aclParseMethodList()
+{
+    intlist *head = NULL;
+    intlist **Tail = &head;
+    intlist *q = NULL;
+    char *t = NULL;
+    while ((t = strtok(NULL, w_space))) {
+       q = (intlist *) xcalloc(1, sizeof(intlist));
+       q->i = (int) urlParseMethod(t);
+       *(Tail) = q;
+       Tail = &q->next;
+    }
+    return head;
+}
+
 struct _acl_ip_data *aclParseIpList()
 {
     char *t = NULL;
@@ -106,7 +129,8 @@ struct _acl_ip_data *aclParseIpList()
                break;
            case 5:
                if (m1 < 0 || m1 > 32) {
-                   debug(3, 0, "aclParseIpList: Ignoring invalid IP acl entry '%s'\n", t);
+                   debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+                   debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry '%s'\n", t);
                    safe_free(q);
                    continue;
                }
@@ -116,7 +140,8 @@ struct _acl_ip_data *aclParseIpList()
                lmask.s_addr = htonl(m1 * 0x1000000 + m2 * 0x10000 + m3 * 0x100 + m4);
                break;
            default:
-               debug(3, 0, "aclParseIpList: Ignoring invalid IP acl entry '%s'\n", t);
+               debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+               debug(28, 0, "aclParseIpList: Ignoring invalid IP acl entry '%s'\n", t);
                safe_free(q);
                continue;
            }
@@ -131,7 +156,75 @@ struct _acl_ip_data *aclParseIpList()
 
 struct _acl_time_data *aclParseTimeSpec()
 {
-    return NULL;
+    struct _acl_time_data *data = NULL;
+    int h1, m1, h2, m2;
+    char *t = NULL;
+
+    data = (struct _acl_time_data *) xcalloc(1, sizeof(struct _acl_time_data));
+    while ((t = strtok(NULL, w_space))) {
+       if (*t < '0' || *t > '9') {
+           /* assume its day-of-week spec */
+           while (*t) {
+               switch (*t++) {
+               case 'S':
+                   data->weekbits |= ACL_SUNDAY;
+                   break;
+               case 'M':
+                   data->weekbits |= ACL_MONDAY;
+                   break;
+               case 'T':
+                   data->weekbits |= ACL_TUESDAY;
+                   break;
+               case 'W':
+                   data->weekbits |= ACL_WEDNESDAY;
+                   break;
+               case 'H':
+                   data->weekbits |= ACL_THURSDAY;
+                   break;
+               case 'F':
+                   data->weekbits |= ACL_FRIDAY;
+                   break;
+               case 'A':
+                   data->weekbits |= ACL_SATURDAY;
+                   break;
+               default:
+                   debug(28, 0, "cached.conf line %d: %s\n",
+                       config_lineno,
+                       config_input_line);
+                   debug(28, 0, "aclParseTimeSpec: Bad Day '%c'\n",
+                       *t);
+                   break;
+               }
+           }
+       } else {
+           /* assume its time-of-day spec */
+           if (sscanf(t, "%d:%d-%d:%d", &h1, &m1, &h2, &m2) < 4) {
+               debug(28, 0, "cached.conf line %d: %s\n",
+                   config_lineno,
+                   config_input_line);
+               debug(28, 0, "aclParseTimeSpec: Bad time range '%s'\n",
+                   t);
+               xfree(&data);
+               return NULL;
+           }
+           data->start = h1 * 60 + m1;
+           data->stop = h2 * 60 + m2;
+           if (data->start > data->stop) {
+               debug(28, 0, "cached.conf line %d: %s\n",
+                   config_lineno,
+                   config_input_line);
+               debug(28, 0, "aclParseTimeSpec: Reversed time range '%s'\n",
+                   t);
+               xfree(&data);
+               return NULL;
+           }
+       }
+    }
+    if (data->start == 0 && data->stop == 0)
+       data->stop = 23 * 60 + 59;
+    if (data->weekbits == 0)
+       data->weekbits = ACL_ALLWEEK;
+    return data;
 }
 
 struct _relist *aclParseRegexList()
@@ -143,8 +236,8 @@ struct _relist *aclParseRegexList()
     regex_t comp;
     while ((t = strtok(NULL, w_space))) {
        if (regcomp(&comp, t, REG_EXTENDED) != REG_NOERROR) {
-           debug(28, 0, "aclParseRegexList: Invalid regular expression: %s\n",
-               t);
+           debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+           debug(28, 0, "aclParseRegexList: Invalid regular expression: '%s'\n", t);
            continue;
        }
        q = (relist *) xcalloc(1, sizeof(relist));
@@ -182,15 +275,23 @@ void aclParseAclLine()
     A = (struct _acl *) xcalloc(1, sizeof(struct _acl));
     /* snarf the ACL name */
     if ((t = strtok(NULL, w_space)) == NULL) {
+       debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+       debug(28, 0, "aclParseAclLine: missing ACL name.\n");
+       xfree(A);
+       return;
+    }
+    if (aclFindByName(t)) {
+       debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+       debug(28, 0, "aclParseAclLine: ACL name '%s' already exists.\n", t);
        xfree(A);
-       debug(28, 1, "aclParseAclLine: missing ACL name.\n");
        return;
     }
     strncpy(A->name, t, ACL_NAME_SZ);
     /* snarf the ACL type */
     if ((t = strtok(NULL, w_space)) == NULL) {
        xfree(A);
-       debug(28, 1, "aclParseAclLine: missing ACL type.\n");
+       debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+       debug(28, 0, "aclParseAclLine: missing ACL type.\n");
        return;
     }
     switch (A->type = aclType(t)) {
@@ -215,10 +316,14 @@ void aclParseAclLine()
     case ACL_PROTO:
        A->data = (void *) aclParseProtoList();
        break;
+    case ACL_METHOD:
+       A->data = (void *) aclParseMethodList();
+       break;
     case ACL_NONE:
     default:
+       debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+       debug(28, 0, "aclParseAclLine: Invalid ACL type '%s'\n", t);
        xfree(A);
-       debug(28, 1, "aclParseAclLine: Invalid ACL type '%s'\n", t);
        return;
        break;
     }
@@ -227,17 +332,21 @@ void aclParseAclLine()
     AclListTail = &A->next;
 }
 
-void aclParseAccessLine()
+void aclParseAccessLine(head)
+    struct _acl_access **head;
 {
     char *t = NULL;
     struct _acl_access *A = NULL;
+    struct _acl_access *B = NULL;
+    struct _acl_access **T = NULL;
     struct _acl_list *L = NULL;
     struct _acl_list **Tail = NULL;
     struct _acl *a = NULL;
 
     /* first expect either 'allow' or 'deny' */
     if ((t = strtok(NULL, w_space)) == NULL) {
-       debug(28, 1, "aclParseAccessLine: missing 'allow' or 'deny'.\n");
+       debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+       debug(28, 0, "aclParseAccessLine: missing 'allow' or 'deny'.\n");
        return;
     }
     A = (struct _acl_access *) xcalloc(1, sizeof(struct _acl_access));
@@ -246,7 +355,8 @@ void aclParseAccessLine()
     else if (!strcmp(t, "deny"))
        A->allow = 0;
     else {
-       debug(28, 1, "aclParseAccessLine: expecting 'allow' or 'deny', got '%s'.\n", t);
+       debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
+       debug(28, 0, "aclParseAccessLine: expecting 'allow' or 'deny', got '%s'.\n", t);
        xfree(A);
        return;
     }
@@ -262,10 +372,10 @@ void aclParseAccessLine()
            L->op = 0;
            t++;
        }
-       debug(28, 1, "aclParseAccessLine: looking for ACL name '%s'\n",
-           t);
+       debug(28, 1, "aclParseAccessLine: looking for ACL name '%s'\n", t);
        a = aclFindByName(t);
        if (a == NULL) {
+           debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
            debug(28, 0, "aclParseAccessLine: ACL name '%s' not found.\n", t);
            xfree(L);
            continue;
@@ -275,14 +385,14 @@ void aclParseAccessLine()
        Tail = &L->next;
     }
     if (A->acl_list == NULL) {
+       debug(28, 0, "cached.conf line %d: %s\n", config_lineno, config_input_line);
        debug(28, 0, "aclParseAccessLine: Access line contains no ACL's, skipping\n");
-       debug(28, 0, "aclParseAccessLine: '%s'\n", config_input_line);
        xfree(A);
        return;
     }
     A->cfgline = xstrdup(config_input_line);
-    *AccessListTail = A;
-    AccessListTail = &A->next;
+    for (B=*head, T=head; B; T=&B->next, B=B->next);   /* find the tail */
+    *T = A;
 }
 
 int aclMatchIp(data, c)
@@ -308,9 +418,9 @@ int aclMatchWord(data, word)
      wordlist *data;
      char *word;
 {
-    debug(28, 1, "aclMatchWord: looking for '%s'\n", word);
+    debug(28, 1, "aclMatchWord: checking '%s'\n", word);
     while (data) {
-       debug(28, 1, "aclMatchWord: checking '%s'\n", data->key);
+       debug(28, 1, "aclMatchWord: looking for '%s'\n", data->key);
        if (strstr(word, data->key))
            return 1;
        data = data->next;
@@ -321,9 +431,9 @@ int aclMatchRegex(data, word)
      relist *data;
      char *word;
 {
-    debug(28, 1, "aclMatchRegex: looking for '%s'\n", word);
+    debug(28, 1, "aclMatchRegex: checking '%s'\n", word);
     while (data) {
-       debug(28, 1, "aclMatchRegex: checking '%s'\n", data->pattern);
+       debug(28, 1, "aclMatchRegex: looking for '%s'\n", data->pattern);
        if (regexec(&data->regex, word, 0, 0, 0) == 0)
            return 1;
        data = data->next;
@@ -342,9 +452,32 @@ int aclMatchInteger(data, i)
     return 0;
 }
 
-int aclMatchAcl(acl, c, pr, h, po, r)
+int aclMatchTime(data, when)
+       struct _acl_time_data *data;
+       time_t when;
+{
+       static time_t last_when = 0;
+       static struct tm tm;
+       time_t t;
+
+       if (when != last_when) {
+               last_when = when;
+               memcpy(&tm, localtime(&when), sizeof(struct tm));
+       }
+
+       debug(28, 1, "aclMatchTime: checking %d-%d, weekbits=%x\n",
+               data->start, data->stop, data->weekbits);
+
+       t = (time_t) (tm.tm_hour * 60 + tm.tm_min);
+       if (t < data->start || t > data->stop)
+               return 0;
+       return data->weekbits & tm.tm_wday ? 1 : 0;
+}
+
+static int aclMatchAcl(acl, c, m, pr, h, po, r)
      struct _acl *acl;
      struct in_addr c;
+     method_t m;
      protocol_t pr;
      char *h;
      int po;
@@ -361,7 +494,7 @@ int aclMatchAcl(acl, c, pr, h, po, r)
        return aclMatchWord(acl->data, h);
        break;
     case ACL_TIME:
-       debug(28, 0, "aclMatchAcl: ACL_TIME unimplemented\n");
+       return aclMatchTime(acl->data, cached_curtime);
        return 0;
        break;
     case ACL_URL_REGEX:
@@ -377,6 +510,9 @@ int aclMatchAcl(acl, c, pr, h, po, r)
     case ACL_PROTO:
        return aclMatchInteger(acl->data, pr);
        break;
+    case ACL_METHOD:
+       return aclMatchInteger(acl->data, m);
+       break;
     case ACL_NONE:
     default:
        debug(28, 0, "aclMatchAcl: '%s' has bad type %d\n",
@@ -387,9 +523,10 @@ int aclMatchAcl(acl, c, pr, h, po, r)
     return 0;
 }
 
-int aclMatchAclList(list, c, pr, h, po, r)
+static int aclMatchAclList(list, c, m, pr, h, po, r)
      struct _acl_list *list;
      struct in_addr c;
+     method_t m;
      protocol_t pr;
      char *h;
      int po;
@@ -397,7 +534,7 @@ int aclMatchAclList(list, c, pr, h, po, r)
 {
     debug(28, 1, "aclMatchAclList: list=%p  op=%d\n", list, list->op);
     while (list) {
-       if (aclMatchAcl(list->acl, c, pr, h, po, r) != list->op) {
+       if (aclMatchAcl(list->acl, c, m, pr, h, po, r) != list->op) {
            debug(28, 1, "aclMatchAclList: returning 0\n");
            return 0;
        }
@@ -407,29 +544,128 @@ int aclMatchAclList(list, c, pr, h, po, r)
     return 1;
 }
 
-int aclCheck(cli_addr, proto, host, port, request)
+int aclCheck(A, cli_addr, method, proto, host, port, request)
+     struct _acl_access *A;
      struct in_addr cli_addr;
+     method_t method;
      protocol_t proto;
      char *host;
      int port;
      char *request;
 {
-    struct _acl_access *A = NULL;
     int allow = 0;
 
     debug(28, 1, "aclCheck: cli_addr=%s\n", inet_ntoa(cli_addr));
+    debug(28, 1, "aclCheck: method=%d\n", method);
     debug(28, 1, "aclCheck: proto=%d\n", proto);
     debug(28, 1, "aclCheck: host=%s\n", host);
     debug(28, 1, "aclCheck: port=%d\n", port);
     debug(28, 1, "aclCheck: request=%s\n", request);
 
-    for (A = AccessList; A; A = A->next) {
+    while (A) {
        debug(28, 1, "aclCheck: checking '%s'\n", A->cfgline);
        allow = A->allow;
-       if (aclMatchAclList(A->acl_list, cli_addr, proto, host, port, request)) {
+       if (aclMatchAclList(A->acl_list, cli_addr, method, proto, host, port, request)) {
            debug(28, 1, "aclCheck: match found, returning %d\n", allow);
            return allow;
        }
+       A = A->next;
     }
     return !allow;
 }
+
+static void aclDestroyIpList(data)
+       struct _acl_ip_data *data;
+{
+       struct _acl_ip_data *next;
+       for (; data; data=next) {
+               next = data->next;
+               safe_free(data);
+       }
+}
+
+static void aclDestroyTimeList(data)
+       struct _acl_time_data *data;
+{
+       struct _acl_time_data *next;
+       for (; data; data=next) {
+               next = data->next;
+               safe_free(data);
+       }
+}
+
+static void aclDestroyRegexList(data)
+       struct _relist *data;
+{
+       struct _relist *next;
+       for (; data; data=next) {
+               next = data->next;
+               regfree(&data->regex);
+               safe_free(data->pattern);
+               safe_free(data);
+       }
+}
+
+void aclDestroyAcls() {
+       struct _acl *a = NULL;
+       struct _acl *next = NULL;
+       for (a=AclList; a; a=next) {
+               next = a->next;
+               debug(28,1,"aclDestroyAcls: '%s'\n", a->cfgline);
+               switch(a->type) {
+               case ACL_SRC_IP:
+                       aclDestroyIpList(a->data);
+                       break;
+               case ACL_DST_DOMAIN:
+               case ACL_USER:
+                       wordlistDestroy((wordlist **) &a->data);
+                       break;
+               case ACL_TIME:
+                       aclDestroyTimeList(a->data);
+                       break;
+               case ACL_URL_REGEX:
+                       aclDestroyRegexList(a->data);
+                       break;
+               case ACL_URL_PORT:
+               case ACL_PROTO:
+               case ACL_METHOD:
+                       intlistDestroy((intlist **) &a->data);
+                       break;
+               case ACL_NONE:
+               default:
+                       fatal_dump("aclDestroyAcls: Found ACL_NONE?");
+                       break;
+               }
+               safe_free(a->cfgline);
+               safe_free(a);
+       }
+       AclList = NULL;
+        AclListTail = &AclList;
+}
+
+void aclDestroyAclList(list)
+       struct _acl_list *list;
+{
+       struct _acl_list *next = NULL;
+       for (; list ; list=next) {
+               next = list->next;
+               safe_free(list);
+       }
+}
+
+void aclDestroyAccessList(list)
+       struct _acl_access **list;
+{
+       struct _acl_access *l = NULL;
+       struct _acl_access *next = NULL;
+       for (l=*list; l ; l=next) {
+               debug(28,1,"aclDestroyAccessList: '%s'\n", l->cfgline);
+               next = l->next;
+               aclDestroyAclList(l->acl_list);
+               l->acl_list = NULL;
+               safe_free(l->cfgline);
+               safe_free(l);
+       }
+       *list = NULL;
+}
+
index 0732099c4ec424da6a71c2115b392391ad6c3047..30a6e65a7501df19388f45d47ba692c0eb4857af 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cache_cf.cc,v 1.33 1996/04/11 19:23:37 wessels Exp $ */
+/* $Id: cache_cf.cc,v 1.34 1996/04/11 22:52:25 wessels Exp $ */
 
 /* DEBUG: Section 3             cache_cf: Configuration file parsing */
 
@@ -315,7 +315,7 @@ void addToIPACL(list, ip_str, access)
     q->mask.s_addr = lmask.s_addr;
 }
 
-static void wordlistDestroy(list)
+void wordlistDestroy(list)
      wordlist **list;
 {
     wordlist *w = NULL;
@@ -352,11 +352,25 @@ void wordlistAdd(list, key)
     }
 }
 
-static void addToIntList(list, str)
+void intlistDestroy(list)
+     intlist **list;
+{
+    intlist *w = NULL;
+    intlist *n = NULL;
+
+    for (w = *list; w; w = n) {
+       n = w->next;
+       safe_free(w);
+    }
+    *list = NULL;
+}
+
+static void intlistAdd(list, str)
      intlist **list;
      char *str;
 {
-    intlist *p, *q;
+    intlist *p = NULL;
+    intlist *q = NULL;
 
     if (!(*list)) {
        /* empty list */
@@ -818,6 +832,7 @@ static void parseWAISRelayLine()
     Config.Wais.maxObjSize = i << 20;
 }
 
+#ifdef OLD_CODE
 static void parseProxyAllowLine()
 {
     char *token;
@@ -871,6 +886,7 @@ static void parseManagerDenyLine()
        return;
     addToIPACL(&manager_ip_acl, token, IP_DENY);
 }
+#endif
 
 static void parseLocalIPLine()
 {
@@ -1038,7 +1054,7 @@ static void parseConnectPortsLine()
        origPortList = 0;
     }
     while ((token = strtok(NULL, w_space))) {
-       addToIntList(&connect_port_list, token);
+       intlistAdd(&connect_port_list, token);
     }
 }
 
@@ -1081,6 +1097,9 @@ int parseConfigFile(file_name)
 
     configFreeMemory();
     configSetFactoryDefaults();
+    aclDestroyAcls();
+    aclDestroyAccessList(&HTTPAccessList);
+    aclDestroyAccessList(&ICPAccessList);
 
     if ((fp = fopen(file_name, "r")) == NULL) {
        sprintf(fatal_str, "Unable to open configuration file: %s", file_name);
@@ -1098,7 +1117,7 @@ int parseConfigFile(file_name)
            continue;
        debug(3, 5, "Processing: '%s'\n", config_input_line);
        strcpy(tmp_line, config_input_line);
-       if ((token = strtok(config_input_line, w_space)) == NULL)
+       if ((token = strtok(tmp_line, w_space)) == NULL)
            continue;
 
        /* Parse a cache_host line */
@@ -1180,6 +1199,7 @@ int parseConfigFile(file_name)
        else if (!strcmp(token, "cache_mgr"))
            parseMgrLine();
 
+#ifdef OLD_CODE
        /* Parse a proxy_allow line */
        else if (!strcmp(token, "proxy_allow"))
            parseProxyAllowLine();
@@ -1203,12 +1223,16 @@ int parseConfigFile(file_name)
        /* Parse a manager_deny line */
        else if (!strcmp(token, "manager_deny"))
            parseManagerDenyLine();
+#endif /* OLD_CODE */
 
        else if (!strcmp(token, "acl"))
            aclParseAclLine();
 
-       else if (!strcmp(token, "access"))
-           aclParseAccessLine();
+       else if (!strcmp(token, "http_access"))
+           aclParseAccessLine(&HTTPAccessList);
+
+       else if (!strcmp(token, "icp_access"))
+           aclParseAccessLine(&ICPAccessList);
 
        /* Parse a http_stop line */
        else if (!strcmp(token, "http_stop"))
@@ -1355,7 +1379,9 @@ int parseConfigFile(file_name)
 
        /* If unknown, treat as a comment line */
        else {
-           /* EMPTY */ ;
+           debug(3,0,"parseConfigFile: line %d unrecognized: '%s'\n",
+               config_lineno,
+               config_input_line);
        }
     }
 
index a1536e351766b1cda60cf426abc15da8ff108f50..48ed814d612c1f3d858a8736b1ae67186766345e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errorpage.cc,v 1.18 1996/04/11 04:48:08 wessels Exp $ */
+/* $Id: errorpage.cc,v 1.19 1996/04/11 22:52:27 wessels Exp $ */
 
 /* DEBUG: Section 4             cached_error: Error printing routines */
 
@@ -220,16 +220,16 @@ char *access_denied_msg(code, method, url, client)
      char *client;
 {
     sprintf(tmp_error_buf, "\
-HTTP/1.0 %d Access Denied\r\n\
+HTTP/1.0 %d Cache Access Denied\r\n\
 Content-type: text/html\r\n\
 \r\n\
-<TITLE>Access Denied</TITLE>\n\
+<TITLE>Cache Access Denied</TITLE>\n\
 <H2>Access Denied</H2>\n\
 <P>\n\
-Sorry, you are not currently allowed to access\n\
+Sorry, you are not currently allowed to request\n\
 <PRE>    %s</PRE>\n\
-Please check with the cache administrator if you believe this\n\
-is incorrect.\n\
+From this cache.  Please check with the cache administrator if you\n\
+believe this is incorrect.\n\
 <HR>\n\
 <ADDRESS>\n\
 Generated by cached/%s@%s\n\
index f10a0a723f44b352ed7da3a6b2e0d12355a425ee..28cc0b1c6c94e5d9ca4b4cf56364b72ff2f384b6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: http.cc,v 1.37 1996/04/11 04:47:23 wessels Exp $ */
+/* $Id: http.cc,v 1.38 1996/04/11 22:52:28 wessels Exp $ */
 
 /*
  * DEBUG: Section 11          http: HTTP
@@ -27,14 +27,6 @@ typedef struct _httpdata {
     int reply_hdr_state;
 } HttpData;
 
-char *RequestMethodStr[] =
-{
-    "NONE",
-    "GET",
-    "POST",
-    "HEAD"
-};
-
 static void httpCloseAndFree(fd, data)
      int fd;
      HttpData *data;
index 0eaa6977d867798a4190432161c4f463391040a2..545e39a38033af55f32d82b2d3fd5e62b5b9786d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: ipcache.cc,v 1.20 1996/04/10 20:53:46 wessels Exp $ */
+/* $Id: ipcache.cc,v 1.21 1996/04/11 22:52:29 wessels Exp $ */
 
 /*
  * DEBUG: Section 14          ipcache: IP Cache
@@ -912,6 +912,8 @@ int ipcache_dnsHandleRead(fd, data)
        data->alive = 0;
        update_dns_child_alive();
        ipcache_cleanup_pendinglist(data);
+       close(fd);
+       fdstat_close(fd);
        return 0;
     }
     data->offset += len;
index 7ae76afcf4876da686436eebaf4f17d4dc048f16..0faf1172dff60748bd7d083ed63d5cd56034895d 100644 (file)
@@ -1,5 +1,5 @@
 
-/* $Id: squid.h,v 1.14 1996/04/11 04:47:25 wessels Exp $ */
+/* $Id: squid.h,v 1.15 1996/04/11 22:52:30 wessels Exp $ */
 
 #include "config.h"
 #include "autoconf.h"
@@ -96,6 +96,7 @@ typedef unsigned long u_num32;
 #include "fdstat.h"
 #include "filemap.h"
 #include "hash.h"
+#include "url.h"
 #include "proto.h"
 #include "icp.h"
 #include "cached_error.h"      /* must go after icp.h */
@@ -108,7 +109,6 @@ typedef unsigned long u_num32;
 #include "store.h"
 #include "tools.h"
 #include "ttl.h"
-#include "url.h"
 #include "storetoString.h"
 #include "http.h"
 #include "ftp.h"
index d95c397d997c01ef9f1d4cfcfe93fafca0d543ec..87c0eba60f05bc44ad781292011dea258c04d19f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stat.cc,v 1.21 1996/04/11 04:48:09 wessels Exp $ */
+/* $Id: stat.cc,v 1.22 1996/04/11 22:52:30 wessels Exp $ */
 
 /*
  * DEBUG: Section 18          stat
@@ -946,39 +946,6 @@ void proto_miss(obj, proto_id)
     obj->proto_stat_data[proto_id].miss++;
 }
 
-protocol_t proto_url_to_id(url)
-     char *url;
-{
-    if (strncasecmp(url, "http", 4) == 0)
-       return PROTO_HTTP;
-    if (strncasecmp(url, "ftp", 3) == 0)
-       return PROTO_FTP;
-    if (strncasecmp(url, "gopher", 6) == 0)
-       return PROTO_GOPHER;
-    if (strncasecmp(url, "cache_object", 12) == 0)
-       return PROTO_CACHEOBJ;
-    if (strncasecmp(url, "file", 4) == 0)
-       return PROTO_FTP;
-    return PROTO_NONE;
-}
-
-int proto_default_port(p)
-     protocol_t p;
-{
-    switch (p) {
-    case PROTO_HTTP:
-       return 80;
-    case PROTO_FTP:
-       return 21;
-    case PROTO_GOPHER:
-       return 70;
-    case PROTO_CACHEOBJ:
-       return CACHE_HTTP_PORT;
-    default:
-       return 0;
-    }
-}
-
 
 void stat_init(object, logfilename)
      cacheinfo **object;
@@ -1016,7 +983,7 @@ void stat_init(object, logfilename)
     }
     obj->logfile_access = file_write_lock(obj->logfile_fd);
 
-    obj->proto_id = proto_url_to_id;
+    obj->proto_id = urlParseProtocol;
     obj->proto_newobject = proto_newobject;
     obj->proto_purgeobject = proto_purgeobject;
     obj->proto_touchobject = proto_touchobject;
index 809c0319dec0a63d9924dcd48901ab15833fc586..87106d3c0b508fc65c52f0a8496328c5cc488c03 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: url.cc,v 1.9 1996/04/10 05:06:38 wessels Exp $ */
+/* $Id: url.cc,v 1.10 1996/04/11 22:52:32 wessels Exp $ */
 
 /* 
  * DEBUG: Section 23          url
@@ -137,3 +137,69 @@ char *the_url(e)
     }
 }
 #endif
+
+char *RequestMethodStr[] =
+{
+    "NONE",
+    "GET",
+    "POST",
+    "HEAD"
+};
+
+char *ProtocolStr[] =
+{
+    "NONE",
+    "http",
+    "ftp",
+    "wais",
+    "cache_object",
+    "TOTAL"
+};
+
+method_t urlParseMethod(s)
+     char *s;
+{
+    if (strcasecmp(s, "GET") == 0) {
+       return METHOD_GET;
+    } else if (strcasecmp(s, "POST") == 0) {
+       return METHOD_POST;
+    } else if (strcasecmp(s, "HEAD") == 0) {
+       return METHOD_HEAD;
+    }
+    return METHOD_NONE;
+}
+
+
+protocol_t urlParseProtocol(s)
+     char *s;
+{
+    if (strncasecmp(s, "http", 4) == 0)
+        return PROTO_HTTP;
+    if (strncasecmp(s, "ftp", 3) == 0)
+        return PROTO_FTP;
+    if (strncasecmp(s, "gopher", 6) == 0)
+        return PROTO_GOPHER;
+    if (strncasecmp(s, "cache_object", 12) == 0)
+        return PROTO_CACHEOBJ;
+    if (strncasecmp(s, "file", 4) == 0)
+        return PROTO_FTP;
+    return PROTO_NONE;
+}
+
+
+int urlDefaultPort(p)
+     protocol_t p;
+{
+    switch (p) {
+    case PROTO_HTTP:
+        return 80;
+    case PROTO_FTP:
+        return 21;
+    case PROTO_GOPHER:
+        return 70;
+    case PROTO_CACHEOBJ:
+        return CACHE_HTTP_PORT;
+    default:
+        return 0;
+    }
+}