]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3239: Rename myip/myport as localip/localport
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 20 Jun 2011 08:51:32 +0000 (20:51 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 20 Jun 2011 08:51:32 +0000 (20:51 +1200)
There is no actual logic change to this patch.

 * Document what the myip/myport actually match and use the clearer
   names of localip / localport.

 * Cleanly upgrade the ACL types when old versions are seen.

 * Rename all relevant code symbols to match the new names.

doc/release-notes/release-3.2.sgml
src/AclRegs.cc
src/acl/Acl.cc
src/acl/LocalIp.cc [moved from src/acl/MyIp.cc with 90% similarity]
src/acl/LocalIp.h [moved from src/acl/MyIp.h with 86% similarity]
src/acl/LocalPort.cc [moved from src/acl/MyPort.cc with 87% similarity]
src/acl/LocalPort.h [moved from src/acl/MyPort.h with 82% similarity]
src/acl/Makefile.am
src/acl/Strategised.cc
src/cf.data.pre

index 8349149af9c239f56ad2a9b4800b22ef6f5558ae..0d67a127286b2970c91d42dc79403f1fa239f102 100644 (file)
@@ -448,8 +448,13 @@ This section gives a thorough account of those changes in three categories:
        <p>New format <em>referrer</em> to log with the format prevously used by referer_log directive.
        <p>New format <em>useragent</em> to log with the format prevously used by useragent_log directive.
 
-       <tag>acl random</tag>
+       <tag>acl : random, localip, localport</tag>
        <p>New type <em>random</em>. Pseudo-randomly match requests based on a configured probability.
+       <p>Renamed <em>myip</em> to <em>localip</em>. It matches the IP which the client connected to.
+       <p>Renamed <em>myport</em> to <em>localport</em>. It matches the port which the client connected to.
+       <p>The <em>localip</em>/<em>localport</em> differ from earlier releases where they matched a mix of
+          of an invalid IP and port 0, the client destination IP/port or the Squid listening IP/port.
+          This definition is now consistent across all modes of traffic received by Squid.
 
        <tag>auth_param</tag>
        <p>New options for Basic, Digest, NTLM, Negotiate <em>children</em> settings.
index 3f4a00789ba911a85c1c9968e2d4f3a07f93da6d..8301dfd56fbad036e2c9ccb989eae9ae4df6ea99 100644 (file)
 #include "acl/HttpStatus.h"
 #include "acl/IntRange.h"
 #include "acl/Ip.h"
+#include "acl/LocalIp.h"
+#include "acl/LocalPort.h"
 #include "acl/MaxConnection.h"
 #include "acl/MethodData.h"
 #include "acl/Method.h"
-#include "acl/MyIp.h"
-#include "acl/MyPort.h"
 #include "acl/MyPortName.h"
 #include "acl/PeerName.h"
 #include "acl/ProtocolData.h"
@@ -101,10 +101,10 @@ ACL::Prototype ACLMaxConnection::RegistryProtoype(&ACLMaxConnection::RegistryEnt
 ACLMaxConnection ACLMaxConnection::RegistryEntry_("maxconn");
 ACL::Prototype ACLMethod::RegistryProtoype(&ACLMethod::RegistryEntry_, "method");
 ACLStrategised<HttpRequestMethod> ACLMethod::RegistryEntry_(new ACLMethodData, ACLMethodStrategy::Instance(), "method");
-ACL::Prototype ACLMyIP::RegistryProtoype(&ACLMyIP::RegistryEntry_, "myip");
-ACLMyIP ACLMyIP::RegistryEntry_;
-ACL::Prototype ACLMyPort::RegistryProtoype(&ACLMyPort::RegistryEntry_, "myport");
-ACLStrategised<int> ACLMyPort::RegistryEntry_(new ACLIntRange, ACLMyPortStrategy::Instance(), "myport");
+ACL::Prototype ACLLocatIP::RegistryProtoype(&ACLLocalIP::RegistryEntry_, "localip");
+ACLLocalIP ACLLocalIP::RegistryEntry_;
+ACL::Prototype ACLLocalPort::RegistryProtoype(&ACLLocalPort::RegistryEntry_, "localport");
+ACLStrategised<int> ACLLocalPort::RegistryEntry_(new ACLIntRange, ACLLocalPortStrategy::Instance(), "localport");
 ACL::Prototype ACLMyPortName::RegistryProtoype(&ACLMyPortName::RegistryEntry_, "myportname");
 ACLStrategised<const char *> ACLMyPortName::RegistryEntry_(new ACLStringData, ACLMyPortNameStrategy::Instance(), "myportname");
 ACL::Prototype ACLPeerName::RegistryProtoype(&ACLPeerName::RegistryEntry_, "peername");
index 316fdbc6bc12d6423a92a50fc40ed063a23efb31..799377668e49d782ffd0f9a31b93d38dd95c1a43 100644 (file)
@@ -121,12 +121,6 @@ ACL::ParseAclLine(ConfigParser &parser, ACL ** head)
         return;
     }
 
-    if (!Prototype::Registered (theType)) {
-        debugs(28, 0, "aclParseAclLine: Invalid ACL type '" << theType << "'");
-        parser.destruct();
-        return;
-    }
-
     // Is this ACL going to work?
     if (strcmp(theType, "myip") != 0) {
         http_port_list *p = Config.Sockaddr.http;
@@ -136,6 +130,8 @@ ACL::ParseAclLine(ConfigParser &parser, ACL ** head)
                 debugs(28, DBG_CRITICAL, "WARNING: 'myip' ACL is not reliable for interception proxies. Please use 'myportname' instead.");
             p = p->next;
         }
+        debugs(28, DBG_WARNING, "UPGRADE: ACL 'myip' type is has been renamed to 'localip' and matches the IP the client connected to.");
+        theType = "localip";
     } else if (strcmp(theType, "myport") != 0) {
         http_port_list *p = Config.Sockaddr.http;
         while (p) {
@@ -145,6 +141,15 @@ ACL::ParseAclLine(ConfigParser &parser, ACL ** head)
                 debugs(28, DBG_CRITICAL, "WARNING: 'myport' ACL is not reliable for interception proxies. Please use 'myportname' instead.");
             p = p->next;
         }
+        theType = "localport";
+        debugs(28, DBG_WARNING, "UPGRADE: ACL 'myport' type is has been renamed to 'localport' and matches the port the client connected to.");
+    }
+
+    if (!Prototype::Registered(theType)) {
+        debugs(28, DBG_CRITICAL, "FATAL: Invalid ACL type '" << theType << "'");
+        // XXX: make this an ERROR and skip the ACL creation. We *may* die later when its use is attempted. Or may not.
+        parser.destruct();
+        return;
     }
 
     if ((A = FindByName(aclname)) == NULL) {
similarity index 90%
rename from src/acl/MyIp.cc
rename to src/acl/LocalIp.cc
index a94c636265d3562f970d3bb1ffa2db0cfe3b465b..bc5bcfd0e71e6038dbb18b7322a8abde2e50c240 100644 (file)
  */
 
 #include "squid.h"
-#include "acl/MyIp.h"
+#include "acl/LocalIp.h"
 #include "acl/FilledChecklist.h"
 
 char const *
-ACLMyIP::typeString() const
+ACLLocalIP::typeString() const
 {
-    return "myip";
+    return "localip";
 }
 
 int
-ACLMyIP::match(ACLChecklist *checklist)
+ACLLocalIP::match(ACLChecklist *checklist)
 {
     return ACLIP::match (Filled(checklist)->my_addr);
 }
@@ -53,7 +53,7 @@ ACLMyIP::match(ACLChecklist *checklist)
 
 
 ACL *
-ACLMyIP::clone() const
+ACLLocalIP::clone() const
 {
-    return new ACLMyIP(*this);
+    return new ACLocalIP(*this);
 }
similarity index 86%
rename from src/acl/MyIp.h
rename to src/acl/LocalIp.h
index b704eebb97899fc826d92c45b68c6152d125dd59..158c81fdca904acae02993f7b689009e0eef1226 100644 (file)
  * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
  */
 
-#ifndef SQUID_ACLMYIP_H
-#define SQUID_ACLMYIP_H
+#ifndef SQUID_ACLLOCALIP_H
+#define SQUID_ACLLOCALIP_H
 
 #include "acl/Ip.h"
 
 /// \ingroup ACLAPI
-class ACLMyIP : public ACLIP
+class ACLLocalIP : public ACLIP
 {
 
 public:
-    MEMPROXY_CLASS(ACLMyIP);
-    static ACLMyIP const &RegistryEntry();
+    MEMPROXY_CLASS(ACLLocalIP);
+    static ACLLocalIP const &RegistryEntry();
 
     virtual char const *typeString() const;
     virtual int match(ACLChecklist *checklist);
@@ -51,9 +51,9 @@ public:
 
 private:
     static Prototype RegistryProtoype;
-    static ACLMyIP RegistryEntry_;
+    static ACLLocalIP RegistryEntry_;
 };
 
-MEMPROXY_CLASS_INLINE(ACLMyIP);
+MEMPROXY_CLASS_INLINE(ACLLocalIP);
 
-#endif /* SQUID_ACLMYIP_H */
+#endif /* SQUID_ACLLOCALIP_H */
similarity index 87%
rename from src/acl/MyPort.cc
rename to src/acl/LocalPort.cc
index 10be8d0b4ceff0da072c51c0cf6886f28fc75af0..bf640cd9e02391e04f75c3ba5c4206a6d326fe30 100644 (file)
  */
 
 #include "squid.h"
-#include "acl/MyPort.h"
+#include "acl/LocalPort.h"
 #include "acl/IntRange.h"
 #include "acl/Checklist.h"
 
 int
-ACLMyPortStrategy::match (ACLData<MatchType> * &data, ACLFilledChecklist *checklist)
+ACLLocalPortStrategy::match (ACLData<MatchType> * &data, ACLFilledChecklist *checklist)
 {
     return data->match (checklist->my_addr.GetPort());
 }
 
-ACLMyPortStrategy *
-ACLMyPortStrategy::Instance()
+ACLLocalPortStrategy *
+ACLLocalPortStrategy::Instance()
 {
     return &Instance_;
 }
 
-ACLMyPortStrategy ACLMyPortStrategy::Instance_;
+ACLLocalPortStrategy ACLLocalPortStrategy::Instance_;
similarity index 82%
rename from src/acl/MyPort.h
rename to src/acl/LocalPort.h
index 2ebf30f6453abf605443361d45a70c6639f6a0f0..3fdebba8d77bf201eb5e417c5f8a7be0db6bc9fe 100644 (file)
  * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
  */
 
-#ifndef SQUID_ACLMYPORT_H
-#define SQUID_ACLMYPORT_H
+#ifndef SQUID_ACLLOCALPORT_H
+#define SQUID_ACLLOCALPORT_H
 
 #include "acl/Strategy.h"
 #include "acl/Strategised.h"
 
 /// \ingroup ACLAPI
-class ACLMyPortStrategy : public ACLStrategy<int>
+class ACLLocalPortStrategy : public ACLStrategy<int>
 {
 
 public:
     virtual int match (ACLData<MatchType> * &, ACLFilledChecklist *);
-    static ACLMyPortStrategy *Instance();
+    static ACLLocalPortStrategy *Instance();
     /**
      * Not implemented to prevent copies of the instance.
      \par
      * Not private to prevent brain dead g+++ warnings about
      * private constructors with no friends
      */
-    ACLMyPortStrategy(ACLMyPortStrategy const &);
+    ACLLocalPortStrategy(ACLLocalPortStrategy const &);
 
 private:
-    static ACLMyPortStrategy Instance_;
-    ACLMyPortStrategy() {}
+    static ACLLocalPortStrategy Instance_;
+    ACLLocalPortStrategy() {}
 
-    ACLMyPortStrategy&operator=(ACLMyPortStrategy const &);
+    ACLLocalPortStrategy&operator=(ACLLocalPortStrategy const &);
 };
 
 /// \ingroup ACLAPI
-class ACLMyPort
+class ACLLocalPort
 {
 
 private:
@@ -69,4 +69,4 @@ private:
     static ACLStrategised<int> RegistryEntry_;
 };
 
-#endif /* SQUID_ACLMYPORT_H */
+#endif /* SQUID_ACLLOCALPORT_H */
index 8b861e3d34ce652a69cab0ca4d00795d2d87fe50..112230036b8d726bd0b7c9444bce10b26c04ef05 100644 (file)
@@ -61,16 +61,16 @@ libacls_la_SOURCES = \
        HttpStatus.h \
        Ip.cc \
        Ip.h \
+       LocalIp.cc \
+       LocalIp.h \
+       LocalPort.cc \
+       LocalPort.h \
        MaxConnection.cc \
        MaxConnection.h \
        Method.cc \
        MethodData.cc \
        MethodData.h \
        Method.h \
-       MyIp.cc \
-       MyIp.h \
-       MyPort.cc \
-       MyPort.h \
        MyPortName.cc \
        MyPortName.h \
        PeerName.cc \
index d930a33eecc76a45fb22671e0eb6ddd6a3356802..278d8f2ec52483eb51dea3c850cf768e4890c8fd 100644 (file)
@@ -51,5 +51,5 @@ template class ACLStrategised<HttpHeader*>;
 /* ACLMyPortName + ACLMyPeerName + ACLBrowser */
 template class ACLStrategised<const char *>;
 
-/* ACLMyPort + ACLSslError */
+/* ACLLocalPort + ACLSslError */
 template class ACLStrategised<int>;
index 1e744ef308a5d0b62a9175958fbc12f38275aaad..cb4f0acb3cfae8326d3ae1297fbe4a2b408e7470 100644 (file)
@@ -657,10 +657,10 @@ DOC_START
 
        ***** ACL TYPES AVAILABLE *****
 
-       acl aclname src ip-address/netmask ...  # clients IP address [fast]
-       acl aclname src addr1-addr2/netmask ... # range of addresses [fast]
-       acl aclname dst ip-address/netmask ...  # URL host's IP address [slow]
-       acl aclname myip ip-address/netmask ... # local socket IP address [fast]
+       acl aclname src ip-address/mask ...     # clients IP address [fast]
+       acl aclname src addr1-addr2/mask ...    # range of addresses [fast]
+       acl aclname dst ip-address/mask ...     # URL host's IP address [slow]
+       acl aclname localip ip-address/mask ... # IP address the client connected to [fast]
 
        acl aclname arp      mac-address ... (xx:xx:xx:xx:xx:xx notation)
          # The arp ACL requires the special configure option --enable-arp-acl.
@@ -721,7 +721,9 @@ DOC_START
 
        acl aclname port 80 70 21 0-1024...   # destination TCP port [fast]
                                              # ranges are alloed
-       acl aclname myport 3128 ...               # local socket TCP port [fast]
+       acl aclname localport 3128 ...        # TCP port the client connected to [fast]
+                                             # NP: for interception mode this is usually '80'
+
        acl aclname myportname 3128 ...       # http(s)_port name [fast]
 
        acl aclname proto HTTP FTP ...        # request protocol [fast]