]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Create an "implicit" SingleService group if an access rule refers to a service
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Apr 2008 23:11:40 +0000 (17:11 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 3 Apr 2008 23:11:40 +0000 (17:11 -0600)
rather than a service group.

src/adaptation/AccessRule.cc
src/adaptation/ServiceGroups.cc

index c62d81948e004914afd1b79936b11049acaad99a..2a2a27130cfcdb605f24e32b5bfe5d548812a07f 100644 (file)
@@ -29,10 +29,20 @@ Adaptation::AccessRule::parse(ConfigParser &parser)
 void
 Adaptation::AccessRule::finalize()
 {
+    if (!group()) { // no explicit group 
+        debugs(93,7, HERE << "no service group: " << groupId);
+        // try to add a one-service group
+        if (FindService(groupId) != NULL) {
+            ServiceGroup *g = new SingleService(groupId);
+            g->finalize(); // explicit groups were finalized before rules
+            AllGroups().push_back(g);
+        }
+    }
+
     if (!group()) {
         debugs(93,0, "ERROR: Unknown adaptation service or group name: '" <<
             groupId << "'"); // TODO: fail on failures
-       }
+    }
 }
 
 Adaptation::ServiceGroup *
index bbe11e760a3f48a321a4064170c5b3da0bbcaa69..5bd36aa01bfa794f1ab97370aa59df27fe691a7c 100644 (file)
@@ -37,6 +37,7 @@ Adaptation::ServiceGroup::finalize()
         if (!FindService(id))
             debugs(93,0, "ERROR: Unknown adaptation name: " << id);
        }
+    debugs(93,7, HERE << "finalized " << kind << ": " << id);
 }
 
 /* ServiceSet */
@@ -64,6 +65,25 @@ Adaptation::ServiceSet::finalize()
 }
 #endif
 
+
+/* SingleService */
+
+Adaptation::SingleService::SingleService(const String &aServiceId):
+    ServiceGroup("single-service group")
+{
+    id = aServiceId;
+    services.push_back(aServiceId);
+}
+
+Adaptation::ServiceGroup::Loop
+Adaptation::SingleService::initialServices()
+{
+    return Loop(services.begin(), services.end()); // there should be only one
+}
+
+
+/* globals */
+
 Adaptation::Groups &
 Adaptation::AllGroups()
 {