]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessRule.cc
2 #include "acl/Gadgets.h"
3 #include "adaptation/AccessRule.h"
4 #include "adaptation/Service.h"
5 #include "adaptation/ServiceGroups.h"
6 #include "ConfigParser.h"
9 int Adaptation::AccessRule::LastId
= 0;
11 Adaptation::AccessRule::AccessRule(const String
&aGroupId
): id(++LastId
), groupId(aGroupId
), acl(NULL
)
15 Adaptation::AccessRule::~AccessRule()
17 // XXX: leaking acls here?
21 Adaptation::AccessRule::parse(ConfigParser
&parser
)
23 aclParseAccessLine("adaptation_access", parser
, &acl
);
27 Adaptation::AccessRule::finalize()
29 if (!group()) { // no explicit group
30 debugs(93,7, HERE
<< "no service group: " << groupId
);
31 // try to add a one-service group
32 if (FindService(groupId
) != NULL
) {
33 ServiceGroupPointer g
= new SingleService(groupId
);
34 g
->finalize(); // explicit groups were finalized before rules
35 AllGroups().push_back(g
);
40 debugs(93, DBG_CRITICAL
, "ERROR: Unknown adaptation service or group name: '" <<
41 groupId
<< "'"); // TODO: fail on failures
45 Adaptation::ServiceGroupPointer
46 Adaptation::AccessRule::group()
48 return FindGroup(groupId
);
51 Adaptation::AccessRules
&
52 Adaptation::AllRules()
54 static AccessRules
*TheRules
= new AccessRules
;
58 // TODO: make AccessRules::find work
59 Adaptation::AccessRule
*
60 Adaptation::FindRule(const AccessRule::Id
&id
)
62 typedef AccessRules::iterator ARI
;
63 for (ARI i
= AllRules().begin(); i
!= AllRules().end(); ++i
) {
71 Adaptation::AccessRule
*
72 Adaptation::FindRuleByGroupId(const String
&groupId
)
74 typedef AccessRules::iterator ARI
;
75 for (ARI i
= AllRules().begin(); i
!= AllRules().end(); ++i
) {
76 if ((*i
)->groupId
== groupId
)