]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
parse_peer() was checking for a self-configured peer, but its not
authorwessels <>
Tue, 5 Dec 2000 15:55:47 +0000 (15:55 +0000)
committerwessels <>
Tue, 5 Dec 2000 15:55:47 +0000 (15:55 +0000)
safe to call getMyHostname() before we parsed the whole config
file.  Therefore, I moved this check into neighbors_open().

src/cache_cf.cc
src/neighbors.cc

index 4c06a599138d6f48fa7ac23a91e305effc16c4b2..a59446588e660ab0d8c93df9a8af5421192d527f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.358 2000/12/05 06:24:00 wessels Exp $
+ * $Id: cache_cf.cc,v 1.359 2000/12/05 08:55:47 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -1028,8 +1028,6 @@ parse_peer(peer ** head)
     char *token = NULL;
     peer *p;
     int i;
-    sockaddr_in_list *s;
-    const char *me = getMyHostname();
     p = memAllocate(MEM_PEER);
     p->http_port = CACHE_HTTP_PORT;
     p->icp.port = CACHE_ICP_PORT;
@@ -1045,17 +1043,6 @@ parse_peer(peer ** head)
     p->http_port = (u_short) i;
     i = GetInteger();
     p->icp.port = (u_short) i;
-    if (strcmp(p->host, me) == 0) {
-       for (s = Config.Sockaddr.http; s; s = s->next) {
-           if (p->http_port != ntohs(s->s.sin_port))
-               continue;
-           debug(15, 1) ("parse_peer: Peer looks like myself: Ignoring %s %s/%d/%d\n",
-               neighborTypeStr(p), p->host, p->http_port, p->icp.port);
-           xfree(p->host);
-           memFree(p, MEM_PEER);
-           return;
-       }
-    }
     while ((token = strtok(NULL, w_space))) {
        if (!strcasecmp(token, "proxy-only")) {
            p->options.proxy_only = 1;
index 7a742213f5cd2a1c5d73f832e5f6e79bd230f894..95d03ed8575d788c134142f23bf2024ae7b9b6a4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: neighbors.cc,v 1.289 2000/12/05 06:24:00 wessels Exp $
+ * $Id: neighbors.cc,v 1.290 2000/12/05 08:55:47 wessels Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -351,9 +351,28 @@ neighbors_open(int fd)
     struct sockaddr_in name;
     socklen_t len = sizeof(struct sockaddr_in);
     struct servent *sep = NULL;
+    const char *me = getMyHostname();
+    peer *this;
+    peer *next;
     memset(&name, '\0', sizeof(struct sockaddr_in));
     if (getsockname(fd, (struct sockaddr *) &name, &len) < 0)
        debug(15, 1) ("getsockname(%d,%p,%p) failed.\n", fd, &name, &len);
+    for (this = Config.peers; this; this = next) {
+       sockaddr_in_list *s;
+       next = this->next;
+       if (0 != strcmp(this->host, me))
+           continue;
+       for (s = Config.Sockaddr.http; s; s = s->next) {
+           if (this->http_port != ntohs(s->s.sin_port))
+               continue;
+           debug(15, 1) ("WARNING: Peer looks like this host\n");
+           debug(15, 1) ("         Ignoring %s %s/%d/%d\n",
+               neighborTypeStr(this), this->host, this->http_port,
+               this->icp.port);
+           neighborRemove(this);
+       }
+    }
+
     peerRefreshDNS((void *) 1);
     if (0 == echo_hdr.opcode) {
        echo_hdr.opcode = ICP_SECHO;