]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove cache_peer_domain directive
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 23 Feb 2015 06:34:49 +0000 (22:34 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 23 Feb 2015 06:34:49 +0000 (22:34 -0800)
Identical functionality is provided through cache_peer_access.

While this check appears at face value to be simpler than ACLs, the
reality is that:
* the difference is simply the time it takes to initialize and destruct
  an on-stack Checklist,
* processing the checks may take longer than ACLs (linked-list of string
  comparisons vs single tree lookup),
* ACLs are the common case due to their extra flexibility, and
* extra work is being done per-transaction just to check which of the
  two features is in use.

By removing we gain less code and configuration directives to work
around in the long term.

doc/release-notes/release-3.6.sgml
src/CachePeer.cc
src/CachePeer.h
src/CachePeerDomainList.h [deleted file]
src/Makefile.am
src/cache_cf.cc
src/cf.data.pre
src/neighbors.cc

index 74815efdf1900d4b669da30291af98aa4ace0a31..5125809f9a05f3ebbf262663274b17914464d48f 100644 (file)
@@ -155,6 +155,10 @@ This section gives a thorough account of those changes in three categories:
 <sect1>Removed tags<label id="removedtags">
 <p>
 <descrip>
+       <tag>cache_peer_domain</tag>
+       <p>Superceded by <em>cache_peer_access</em>. Use dstdomain ACL
+          in the access control list to restrict domains requested.
+
        <tag>refresh_pattern</tag>
        <p>Option <em>ignore-auth</em> removed. Its original intent was
           to improve caching. HTTP/1.1 permits caching of authenticated
index 8632aab902bbda5f99178ad6eebdd1a3e6ed4167..0e8f237b98bbf75419ebbe94b40868ce33eeeda8 100644 (file)
@@ -9,7 +9,6 @@
 #include "squid.h"
 #include "acl/Gadgets.h"
 #include "CachePeer.h"
-#include "CachePeerDomainList.h"
 #include "defines.h"
 #include "NeighborTypeDomainList.h"
 #include "pconn.h"
@@ -23,7 +22,6 @@ CachePeer::CachePeer() :
     host(NULL),
     type(PEER_NONE),
     http_port(CACHE_HTTP_PORT),
-    peer_domain(NULL),
     typelist(NULL),
     access(NULL),
     weight(1),
@@ -88,12 +86,6 @@ CachePeer::~CachePeer()
     xfree(name);
     xfree(host);
 
-    while (CachePeerDomainList *l = peer_domain) {
-        peer_domain = l->next;
-        xfree(l->domain);
-        xfree(l);
-    }
-
     while (NeighborTypeDomainList *l = typelist) {
         typelist = l->next;
         xfree(l->domain);
index 1ab24517849cb888bfb948a5f15a1a6902b4c2b5..4cf63852dd127ddae986e723edee106fc9f32277 100644 (file)
@@ -22,7 +22,6 @@
 #include <openssl/ssl.h>
 #endif
 
-class CachePeerDomainList;
 class NeighborTypeDomainList;
 class PconnPool;
 class PeerDigest;
@@ -75,7 +74,6 @@ public:
 #endif
 
     unsigned short http_port;
-    CachePeerDomainList *peer_domain;
     NeighborTypeDomainList *typelist;
     acl_access *access;
 
diff --git a/src/CachePeerDomainList.h b/src/CachePeerDomainList.h
deleted file mode 100644 (file)
index 8de49c5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
- *
- * Squid software is distributed under GPLv2+ license and includes
- * contributions from numerous individuals and organizations.
- * Please see the COPYING and CONTRIBUTORS files for details.
- */
-
-#ifndef SQUID_CACHEPEERDOMAINLIST_H_
-#define SQUID_CACHEPEERDOMAINLIST_H_
-
-/// representation of the cache_peer_domain list. POD.
-class CachePeerDomainList
-{
-public:
-    char *domain;
-    bool do_ping;
-    CachePeerDomainList *next;
-};
-
-#endif /* SQUID_CACHEPEERDOMAINLIST_H_ */
-
index d5932d5ff2e0a9e924fb8b138a712c4c71995d14..dfbb3ccf07b3922844279133ac54d03305c2ea57 100644 (file)
@@ -285,7 +285,6 @@ squid_SOURCES = \
        CacheDigest.cc \
        cache_manager.cc \
        NeighborTypeDomainList.h \
-       CachePeerDomainList.h \
        CachePeer.cc \
        CachePeer.h \
        CacheManager.h \
index 4b0b45781d8fbbc22fc6a4589b0e6b6d589346a0..bfc1212cd3e4aff7e752e6e8ff1bb60c878cebac 100644 (file)
@@ -23,7 +23,6 @@
 #include "base/RunnersRegistry.h"
 #include "cache_cf.h"
 #include "CachePeer.h"
-#include "CachePeerDomainList.h"
 #include "ConfigParser.h"
 #include "CpuAffinityMap.h"
 #include "DiskIO/DiskIOModule.h"
@@ -1885,7 +1884,6 @@ peer_type_str(const peer_t type)
 static void
 dump_peer(StoreEntry * entry, const char *name, CachePeer * p)
 {
-    CachePeerDomainList *d;
     NeighborTypeDomainList *t;
     LOCAL_ARRAY(char, xname, 128);
 
@@ -1899,13 +1897,6 @@ dump_peer(StoreEntry * entry, const char *name, CachePeer * p)
                           p->name);
         dump_peer_options(entry, p);
 
-        for (d = p->peer_domain; d; d = d->next) {
-            storeAppendPrintf(entry, "cache_peer_domain %s %s%s\n",
-                              p->host,
-                              d->do_ping ? null_string : "!",
-                              d->domain);
-        }
-
         if (p->access) {
             snprintf(xname, 128, "cache_peer_access %s", p->name);
             dump_acl_access(entry, xname, p->access);
@@ -2400,40 +2391,6 @@ parse_peer_access(void)
     aclParseAccessLine(directive.c_str(), LegacyParser, &p->access);
 }
 
-static void
-parse_hostdomain(void)
-{
-    char *host = NULL;
-    char *domain = NULL;
-
-    if (!(host = ConfigParser::NextToken()))
-        self_destruct();
-
-    while ((domain = ConfigParser::NextToken())) {
-        CachePeerDomainList *l = NULL;
-        CachePeerDomainList **L = NULL;
-        CachePeer *p;
-
-        if ((p = peerFindByName(host)) == NULL) {
-            debugs(15, DBG_CRITICAL, "" << cfg_filename << ", line " << config_lineno << ": No cache_peer '" << host << "'");
-            continue;
-        }
-
-        l = static_cast<CachePeerDomainList *>(xcalloc(1, sizeof(CachePeerDomainList)));
-        l->do_ping = true;
-
-        if (*domain == '!') {   /* check for !.edu */
-            l->do_ping = false;
-            ++domain;
-        }
-
-        l->domain = xstrdup(domain);
-
-        for (L = &(p->peer_domain); *L; L = &((*L)->next));
-        *L = l;
-    }
-}
-
 static void
 parse_hostdomaintype(void)
 {
index 2ba9e26c79ed8c4e1aa82c9e66d187fbb0075373..7f5643ca59173c768d3523e7926bb34fd5d7bc3a 100644 (file)
@@ -148,6 +148,13 @@ DOC_START
        This option is not yet supported by Squid-3.
 DOC_END
 
+# Options removed in 3.6
+NAME: cache_peer_domain cache_host_domain
+TYPE: obsolete
+DOC_START
+       Replace with dstdomain ACLs and cache_peer_access.
+DOC_END
+
 # Options removed in 3.5
 NAME: hierarchy_stoplist
 TYPE: obsolete
@@ -3342,53 +3349,20 @@ DOC_START
        
 DOC_END
 
-NAME: cache_peer_domain cache_host_domain
-TYPE: hostdomain
-DEFAULT: none
-LOC: none
-DOC_START
-       Use to limit the domains for which a neighbor cache will be
-       queried.
-
-       Usage:
-               cache_peer_domain cache-host domain [domain ...]
-               cache_peer_domain cache-host !domain
-
-       For example, specifying
-
-               cache_peer_domain parent.foo.net        .edu
-
-       has the effect such that UDP query packets are sent to
-       'bigserver' only when the requested object exists on a
-       server in the .edu domain.  Prefixing the domainname
-       with '!' means the cache will be queried for objects
-       NOT in that domain.
-
-       NOTE:   * Any number of domains may be given for a cache-host,
-                 either on the same or separate lines.
-               * When multiple domains are given for a particular
-                 cache-host, the first matched domain is applied.
-               * Cache hosts with no domain restrictions are queried
-                 for all requests.
-               * There are no defaults.
-               * There is also a 'cache_peer_access' tag in the ACL
-                 section.
-DOC_END
-
 NAME: cache_peer_access
 TYPE: peer_access
 DEFAULT: none
 LOC: none
 DOC_START
-       Similar to 'cache_peer_domain' but provides more flexibility by
-       using ACL elements.
+       Use to limit the requests for which a neighbor proxy will be
+       queried. Peers with no restrictions are queried for all requests.
 
        Usage:
                cache_peer_access cache-host allow|deny [!]aclname ...
 
        The syntax is identical to 'http_access' and the other lists of
-       ACL elements.  See the comments for 'http_access' below, or
-       the Squid FAQ (http://wiki.squid-cache.org/SquidFaq/SquidAcl).
+       ACL elements.  See the comments for 'http_access', or the
+       Squid FAQ (http://wiki.squid-cache.org/SquidFaq/SquidAcl).
 DOC_END
 
 NAME: neighbor_type_domain
index 69b4ed2a573b4fc2d02bbb45c2d7b323b435a829..eeef85682fd3df1dc4aaa5b7774576c611edc9ca 100644 (file)
@@ -13,7 +13,6 @@
 #include "anyp/PortCfg.h"
 #include "CacheDigest.h"
 #include "CachePeer.h"
-#include "CachePeerDomainList.h"
 #include "comm/Connection.h"
 #include "comm/ConnOpener.h"
 #include "event.h"
@@ -137,7 +136,6 @@ bool
 peerAllowedToUse(const CachePeer * p, HttpRequest * request)
 {
 
-    const CachePeerDomainList *d = NULL;
     assert(request != NULL);
 
     if (neighborType(p, request) == PEER_SIBLING) {
@@ -164,24 +162,8 @@ peerAllowedToUse(const CachePeer * p, HttpRequest * request)
     if (p->options.originserver && request->method == Http::METHOD_CONNECT && request->port != p->in_addr.port())
         return false;
 
-    if (p->peer_domain == NULL && p->access == NULL)
-        return true;
-
-    bool do_ping = false;
-    for (d = p->peer_domain; d; d = d->next) {
-        if (0 == matchDomainName(request->GetHost(), d->domain)) {
-            do_ping = d->do_ping;
-            break;
-        }
-
-        do_ping = !d->do_ping;
-    }
-
-    if (p->peer_domain && !do_ping)
-        return false;
-
     if (p->access == NULL)
-        return do_ping;
+        return true;
 
     ACLFilledChecklist checklist(p->access, request, NULL);
 
@@ -1580,16 +1562,14 @@ dump_peer_options(StoreEntry * sentry, CachePeer * p)
 static void
 dump_peers(StoreEntry * sentry, CachePeer * peers)
 {
-    CachePeer *e = NULL;
     char ntoabuf[MAX_IPSTRLEN];
-    CachePeerDomainList *d = NULL;
     icp_opcode op;
     int i;
 
     if (peers == NULL)
         storeAppendPrintf(sentry, "There are no neighbors installed.\n");
 
-    for (e = peers; e; e = e->next) {
+    for (CachePeer *e = peers; e; e = e->next) {
         assert(e->host != NULL);
         storeAppendPrintf(sentry, "\n%-11.11s: %s\n",
                           neighborTypeStr(e),
@@ -1668,17 +1648,6 @@ dump_peers(StoreEntry * sentry, CachePeer * peers)
                               Time::FormatHttpd(e->stats.last_connect_failure));
         }
 
-        if (e->peer_domain != NULL) {
-            storeAppendPrintf(sentry, "DOMAIN LIST: ");
-
-            for (d = e->peer_domain; d; d = d->next) {
-                storeAppendPrintf(sentry, "%s%s ",
-                                  d->do_ping ? null_string : "!", d->domain);
-            }
-
-            storeAppendPrintf(sentry, "\n");
-        }
-
         storeAppendPrintf(sentry, "keep-alive ratio: %d%%\n", Math::intPercent(e->stats.n_keepalives_recv, e->stats.n_keepalives_sent));
     }
 }