--------------------- PatchSet 5277 Date: 2007/08/12 09:06:05 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Fix URL with bracket-wrapped IP not resolved by squid. - pt 2, moves unwrapping to ipcacheChecNumeric() where it belongs for now Members: src/ACLDestinationDomain.cc:1.7.6.12->1.7.6.13 src/ACLDestinationIP.cc:1.6.6.7->1.6.6.8 src/asn.cc:1.16.6.22->1.16.6.23 src/ipcache.cc:1.9.2.38->1.9.2.39 src/net_db.cc:1.13.4.26->1.13.4.27 Index: squid3/src/ACLDestinationDomain.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLDestinationDomain.cc,v retrieving revision 1.7.6.12 retrieving revision 1.7.6.13 diff -u -r1.7.6.12 -r1.7.6.13 --- squid3/src/ACLDestinationDomain.cc 11 Aug 2007 13:26:01 -0000 1.7.6.12 +++ squid3/src/ACLDestinationDomain.cc 12 Aug 2007 09:06:05 -0000 1.7.6.13 @@ -1,5 +1,5 @@ /* - * $Id: ACLDestinationDomain.cc,v 1.7.6.12 2007/08/11 13:26:01 amosjeffries Exp $ + * $Id: ACLDestinationDomain.cc,v 1.7.6.13 2007/08/12 09:06:05 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -82,17 +82,11 @@ if (data->match(checklist->request->GetHost())) return 1; - /* wrapped numeric IPA */ - if ( checklist->request->GetHost()[0] == '[') - fqdn = fqdncache_gethostbyaddr(checklist->request->host_addr, FQDN_LOOKUP_IF_MISS); - - /* unwrapped? numeric IPA or invalid. */ - else { - if ((ia = ipcacheCheckNumeric(checklist->request->GetHost())) == NULL) - return 0; + /* numeric IPA? */ + if ((ia = ipcacheCheckNumeric(checklist->request->GetHost())) == NULL) + return 0; - fqdn = fqdncache_gethostbyaddr(ia->in_addrs[0], FQDN_LOOKUP_IF_MISS); - } + fqdn = fqdncache_gethostbyaddr(ia->in_addrs[0], FQDN_LOOKUP_IF_MISS); if (fqdn) { return data->match(fqdn); Index: squid3/src/ACLDestinationIP.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ACLDestinationIP.cc,v retrieving revision 1.6.6.7 retrieving revision 1.6.6.8 diff -u -r1.6.6.7 -r1.6.6.8 --- squid3/src/ACLDestinationIP.cc 11 Aug 2007 13:26:01 -0000 1.6.6.7 +++ squid3/src/ACLDestinationIP.cc 12 Aug 2007 09:06:05 -0000 1.6.6.8 @@ -1,5 +1,5 @@ /* - * $Id: ACLDestinationIP.cc,v 1.6.6.7 2007/08/11 13:26:01 amosjeffries Exp $ + * $Id: ACLDestinationIP.cc,v 1.6.6.8 2007/08/12 09:06:05 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -58,10 +58,6 @@ } return 0; - } else if (checklist->request->GetHost()[0] == '[') { - /* wrapped IPA */ - return ACLIP::match(checklist->request->host_addr); - } else if (!checklist->request->flags.destinationIPLookedUp()) { /* No entry in cache, lookup not attempted */ debugs(28, 3, "aclMatchAcl: Can't yet compare '" << name << "' ACL for '" << checklist->request->GetHost() << "'"); Index: squid3/src/asn.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/asn.cc,v retrieving revision 1.16.6.22 retrieving revision 1.16.6.23 diff -u -r1.16.6.22 -r1.16.6.23 --- squid3/src/asn.cc 12 Aug 2007 07:34:05 -0000 1.16.6.22 +++ squid3/src/asn.cc 12 Aug 2007 09:06:05 -0000 1.16.6.23 @@ -1,6 +1,6 @@ /* - * $Id: asn.cc,v 1.16.6.22 2007/08/12 07:34:05 amosjeffries Exp $ + * $Id: asn.cc,v 1.16.6.23 2007/08/12 09:06:05 amosjeffries Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -648,10 +648,6 @@ return 0; - } else if ( checklist->request->GetHost()[0] == '[') { - /* Hostname was a wrapped IPA */ - return data->match(checklist->request->host_addr); - } else if (!checklist->request->flags.destinationIPLookedUp()) { /* No entry in cache, lookup not attempted */ /* XXX FIXME: allow accessing the acl name here */ Index: squid3/src/ipcache.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ipcache.cc,v retrieving revision 1.9.2.38 retrieving revision 1.9.2.39 diff -u -r1.9.2.38 -r1.9.2.39 --- squid3/src/ipcache.cc 6 Aug 2007 02:42:51 -0000 1.9.2.38 +++ squid3/src/ipcache.cc 12 Aug 2007 09:06:05 -0000 1.9.2.39 @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.9.2.38 2007/08/06 02:42:51 amosjeffries Exp $ + * $Id: ipcache.cc,v 1.9.2.39 2007/08/12 09:06:05 amosjeffries Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -595,6 +595,7 @@ } if ((addrs = ipcacheCheckNumeric(name))) { + debugs(14, 4, "ipcache_nbgethostbyname: BYPASS for '" << name << "' (already numeric)"); dns_error_message = NULL; handler(addrs, handlerData); return; @@ -930,9 +931,18 @@ IPAddress ip; /* check if it's already a IP address in text form. */ - if (!(ip = name)) + /* it may be IPv6-wrapped */ + if(name[0] == '[') { + char *tmp = xstrdup(&name[1]); + tmp[strlen(tmp)-1] = '\0'; + if (!(ip = tmp)) + return NULL; + } + else if (!(ip = name)) return NULL; + debugs(14, 4, "ipcache_nbgethostbyname: HIT_BYPASS for '" << name << "' == " << ip ); + static_addrs.count = 1; static_addrs.cur = 0; Index: squid3/src/net_db.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/net_db.cc,v retrieving revision 1.13.4.26 retrieving revision 1.13.4.27 diff -u -r1.13.4.26 -r1.13.4.27 --- squid3/src/net_db.cc 12 Aug 2007 07:34:06 -0000 1.13.4.26 +++ squid3/src/net_db.cc 12 Aug 2007 09:06:06 -0000 1.13.4.27 @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.13.4.26 2007/08/12 07:34:06 amosjeffries Exp $ + * $Id: net_db.cc,v 1.13.4.27 2007/08/12 09:06:06 amosjeffries Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -1376,16 +1376,10 @@ if (NULL == n) { /* try IP addr */ - if(request->GetHost()[0] == '[') { - /* was already an IPA in wrapped form. */ - n = netdbLookupAddr(request->host_addr); - } - else { - ia = ipcache_gethostbyname(request->GetHost(), 0); + ia = ipcache_gethostbyname(request->GetHost(), 0); - if (NULL != ia) - n = netdbLookupAddr(ia->in_addrs[ia->cur]); - } + if (NULL != ia) + n = netdbLookupAddr(ia->in_addrs[ia->cur]); } if (NULL == n)