Here are a new set of patches which I remember being posted to squid-dev
a couple of months back, but nothing happened.
Again, they seem to make sense. Can I get some feedback on these? If
I don't hear anything, I'll simply commit away in a day or two .. :-)
adrian
----- Forwarded message from Brian Degenhardt <bmd@mp3.com> -----
Date: Fri, 10 Nov 2000 10:03:01 -0800
From: Brian Degenhardt <bmd@mp3.com>
To: Adrian Chadd <adrian@creative.net.au>
Subject: Re: doublecheck patches .
X-Mailer: Mutt 0.95.6i
These!
One stops a machine from making itself a cache peer (stops forwarding loops).
The other fixes a problem with squid using it's non FQDN which breaks
internal objects when append-domain is set among other things.
See http://www.squid-cache.org/mail-archive/squid-dev/200008/0080.html
for a better explanation of the problem.
They're against an older HEAD of 2.4 so it might take some massaging to get
them in, but they're so trivial I figured it'd be ok.
cheers
-bmd
On Fri, Nov 10, 2000 at 11:17:12PM +0800, Adrian Chadd wrote:
>
> .. are applied to squid-HEAD. Thanks Robert!
>
> Ok, whats next ?
>
>
>
> adrian
>
> --
> Adrian Chadd "God: Damn! I left pot everywhere!
> <adrian@creative.net.au> Now I'll have to create Republicans!"
> - Bill Hicks
--- cache_cf.c.old Tue Oct 17 13:01:52 2000
+++ cache_cf.c Tue Oct 17 13:03:00 2000
@@ -1012,63 +1012,65 @@
snprintf(xname, 128, "cache_peer_access %s", p->host);
dump_acl_access(entry, xname, p->access);
}
for (t = p->typelist; t; t = t->next) {
storeAppendPrintf(entry, "neighbor_type_domain %s %s %s\n",
p->host,
peer_type_str(t->type),
t->domain);
}
p = p->next;
}
}
static void
parse_peer(peer ** head)
{
char *token = NULL;
peer *p;
int i;
sockaddr_in_list *s;
- const char *me = null_string; /* XXX */
+ const char *me = getMyHostname();
p = memAllocate(MEM_PEER);
p->http_port = CACHE_HTTP_PORT;
p->icp.port = CACHE_ICP_PORT;
p->weight = 1;
p->stats.logged_state = PEER_ALIVE;
if ((token = strtok(NULL, w_space)) == NULL)
self_destruct();
p->host = xstrdup(token);
if ((token = strtok(NULL, w_space)) == NULL)
self_destruct();
p->type = parseNeighborType(token);
i = GetInteger();
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, 0) ("parse_peer: Peer looks like myself: %s %s/%d/%d\n",
- p->type, p->host, p->http_port, p->icp.port);
- self_destruct();
+ 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;
} else if (!strcasecmp(token, "no-query")) {
p->options.no_query = 1;
} else if (!strcasecmp(token, "no-digest")) {
p->options.no_digest = 1;
} else if (!strcasecmp(token, "multicast-responder")) {
p->options.mcast_responder = 1;
} else if (!strncasecmp(token, "weight=", 7)) {
p->weight = atoi(token + 7);
} else if (!strcasecmp(token, "closest-only")) {
p->options.closest_only = 1;
} else if (!strncasecmp(token, "ttl=", 4)) {
p->mcast.ttl = atoi(token + 4);
if (p->mcast.ttl < 0)
p->mcast.ttl = 0;
if (p->mcast.ttl > 128)
--- tools.c.old Tue Oct 17 13:01:49 2000
+++ tools.c Tue Oct 17 13:05:05 2000
@@ -432,60 +432,63 @@
if (Config.visibleHostname != NULL)
return Config.visibleHostname;
if (present)
return host;
host[0] = '\0';
if (Config.Sockaddr.http->s.sin_addr.s_addr != any_addr.s_addr) {
/*
* If the first http_port address has a specific address, try a
* reverse DNS lookup on it.
*/
h = gethostbyaddr((char *) &Config.Sockaddr.http->s.sin_addr,
sizeof(Config.Sockaddr.http->s.sin_addr), AF_INET);
if (h != NULL) {
/* DNS lookup successful */
/* use the official name from DNS lookup */
xstrncpy(host, h->h_name, SQUIDHOSTNAMELEN);
debug(50, 4) ("getMyHostname: resolved %s to '%s'\n",
inet_ntoa(Config.Sockaddr.http->s.sin_addr),
host);
present = 1;
- return host;
+ if( strchr( host, '.' ) )
+ return host;
+
}
- debug(50, 1) ("WARNING: failed to resolve %s to a hostname\n",
+ debug(50, 1) ("WARNING: failed to resolve %s to a fully qualified hostname\n",
inet_ntoa(Config.Sockaddr.http->s.sin_addr));
}
/*
* Get the host name and store it in host to return
*/
if (gethostname(host, SQUIDHOSTNAMELEN) < 0) {
debug(50, 1) ("WARNING: gethostname failed: %s\n", xstrerror());
} else if ((h = gethostbyname(host)) == NULL) {
debug(50, 1) ("WARNING: gethostbyname failed for %s\n", host);
} else {
debug(50, 6) ("getMyHostname: '%s' resolved into '%s'\n",
host, h->h_name);
/* DNS lookup successful */
/* use the official name from DNS lookup */
xstrncpy(host, h->h_name, SQUIDHOSTNAMELEN);
present = 1;
- return host;
+ if( strchr( host, '.' ) )
+ return host;
}
fatal("Could not determine fully qualified hostname. Please set 'visible_hostname'\n");
return NULL; /* keep compiler happy */
}
const char *
uniqueHostname(void)
{
return Config.uniqueHostname ? Config.uniqueHostname : getMyHostname();
}
void
safeunlink(const char *s, int quiet)
{
statCounter.syscalls.disk.unlinks++;
if (unlink(s) < 0 && !quiet)
debug(50, 1) ("safeunlink: Couldn't delete %s: %s\n", s, xstrerror());
}
/* leave a privilegied section. (Give up any privilegies)
----- End forwarded message -----
-- Adrian Chadd "God: Damn! I left pot everywhere! <adrian@creative.net.au> Now I'll have to create Republicans!" - Bill HicksReceived on Mon Nov 13 2000 - 07:37:15 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:58 MST