]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessRule.cc
4 #include "ConfigParser.h"
5 #include "acl/Gadgets.h"
6 #include "adaptation/AccessRule.h"
7 #include "adaptation/Service.h"
8 #include "adaptation/ServiceGroups.h"
11 int Adaptation::AccessRule::LastId
= 0;
13 Adaptation::AccessRule::AccessRule(const String
&aGroupId
): id(++LastId
), groupId(aGroupId
), acl(NULL
)
17 Adaptation::AccessRule::~AccessRule()
19 // XXX: leaking acls here?
23 Adaptation::AccessRule::parse(ConfigParser
&parser
)
25 aclParseAccessLine(parser
, &acl
);
29 Adaptation::AccessRule::finalize()
31 if (!group()) { // no explicit group
32 debugs(93,7, HERE
<< "no service group: " << groupId
);
33 // try to add a one-service group
34 if (FindService(groupId
) != NULL
) {
35 ServiceGroupPointer g
= new SingleService(groupId
);
36 g
->finalize(); // explicit groups were finalized before rules
37 AllGroups().push_back(g
);
42 debugs(93, DBG_CRITICAL
, "ERROR: Unknown adaptation service or group name: '" <<
43 groupId
<< "'"); // TODO: fail on failures
47 Adaptation::ServiceGroupPointer
48 Adaptation::AccessRule::group()
50 return FindGroup(groupId
);
54 Adaptation::AccessRules
&
55 Adaptation::AllRules()
57 static AccessRules TheRules
;
61 // TODO: make AccessRules::find work
62 Adaptation::AccessRule
*
63 Adaptation::FindRule(const AccessRule::Id
&id
)
65 typedef AccessRules::iterator ARI
;
66 for (ARI i
= AllRules().begin(); i
!= AllRules().end(); ++i
) {
74 Adaptation::AccessRule
*
75 Adaptation::FindRuleByGroupId(const String
&groupId
)
77 typedef AccessRules::iterator ARI
;
78 for (ARI i
= AllRules().begin(); i
!= AllRules().end(); ++i
) {
79 if ((*i
)->groupId
== groupId
)