]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessRule.cc
04dc165b868e6450eaabc1848aff924e7d28bb47
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "acl/Gadgets.h"
12 #include "adaptation/AccessRule.h"
13 #include "adaptation/Service.h"
14 #include "adaptation/ServiceGroups.h"
15 #include "ConfigParser.h"
18 int Adaptation::AccessRule::LastId
= 0;
20 Adaptation::AccessRule::AccessRule(const String
&aGroupId
): id(++LastId
), groupId(aGroupId
), acl(NULL
)
24 Adaptation::AccessRule::~AccessRule()
30 Adaptation::AccessRule::parse(ConfigParser
&parser
)
32 aclParseAccessLine("adaptation_access", parser
, &acl
);
36 Adaptation::AccessRule::finalize()
38 if (!group()) { // no explicit group
39 debugs(93,7, HERE
<< "no service group: " << groupId
);
40 // try to add a one-service group
41 if (FindService(groupId
) != NULL
) {
42 ServiceGroupPointer g
= new SingleService(groupId
);
43 g
->finalize(); // explicit groups were finalized before rules
44 AllGroups().push_back(g
);
49 debugs(93, DBG_CRITICAL
, "ERROR: Unknown adaptation service or group name: '" <<
50 groupId
<< "'"); // TODO: fail on failures
54 Adaptation::ServiceGroupPointer
55 Adaptation::AccessRule::group()
57 return FindGroup(groupId
);
60 Adaptation::AccessRules
&
61 Adaptation::AllRules()
63 static AccessRules
*TheRules
= new AccessRules
;
67 // TODO: make AccessRules::find work
68 Adaptation::AccessRule
*
69 Adaptation::FindRule(const AccessRule::Id
&id
)
71 typedef AccessRules::iterator ARI
;
72 for (ARI i
= AllRules().begin(); i
!= AllRules().end(); ++i
) {
80 Adaptation::AccessRule
*
81 Adaptation::FindRuleByGroupId(const String
&groupId
)
83 typedef AccessRules::iterator ARI
;
84 for (ARI i
= AllRules().begin(); i
!= AllRules().end(); ++i
) {
85 if ((*i
)->groupId
== groupId
)