From: Alex Rousskov Date: Thu, 3 Apr 2008 23:11:40 +0000 (-0600) Subject: Create an "implicit" SingleService group if an access rule refers to a service X-Git-Tag: SQUID_3_1_0_1~49^2~302^2~13^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bed1aa51813fdd2f5ed62c2cbdcd7738ada5a823;p=thirdparty%2Fsquid.git Create an "implicit" SingleService group if an access rule refers to a service rather than a service group. --- diff --git a/src/adaptation/AccessRule.cc b/src/adaptation/AccessRule.cc index c62d81948e..2a2a27130c 100644 --- a/src/adaptation/AccessRule.cc +++ b/src/adaptation/AccessRule.cc @@ -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 * diff --git a/src/adaptation/ServiceGroups.cc b/src/adaptation/ServiceGroups.cc index bbe11e760a..5bd36aa01b 100644 --- a/src/adaptation/ServiceGroups.cc +++ b/src/adaptation/ServiceGroups.cc @@ -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() {