]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 1996-2025 The Squid Software Foundation and contributors | |
3 | * | |
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. | |
7 | */ | |
8 | ||
9 | /* DEBUG: section 28 Access Control */ | |
10 | ||
11 | #include "squid.h" | |
12 | #include "acl/Checklist.h" | |
13 | #include "acl/ProtocolData.h" | |
14 | #include "ConfigParser.h" | |
15 | #include "debug/Stream.h" | |
16 | #include "wordlist.h" | |
17 | ||
18 | ACLProtocolData::~ACLProtocolData() | |
19 | { | |
20 | values.clear(); | |
21 | } | |
22 | ||
23 | bool | |
24 | ACLProtocolData::match(AnyP::ProtocolType toFind) | |
25 | { | |
26 | for (auto itr = values.begin(); itr != values.end(); ++itr) { | |
27 | if (*itr == toFind) { | |
28 | // tune the list for LRU ordering | |
29 | values.erase(itr); | |
30 | values.push_front(toFind); | |
31 | return true; | |
32 | } | |
33 | } | |
34 | return false; | |
35 | } | |
36 | ||
37 | SBufList | |
38 | ACLProtocolData::dump() const | |
39 | { | |
40 | SBufList sl; | |
41 | for (std::list<AnyP::ProtocolType>::const_iterator itr = values.begin(); itr != values.end(); ++itr) { | |
42 | sl.push_back(SBuf(AnyP::ProtocolType_str[*itr])); | |
43 | } | |
44 | ||
45 | return sl; | |
46 | } | |
47 | ||
48 | void | |
49 | ACLProtocolData::parse() | |
50 | { | |
51 | while (char *t = ConfigParser::strtokFile()) { | |
52 | int p = AnyP::PROTO_NONE; | |
53 | for (; p < AnyP::PROTO_UNKNOWN; ++p) { | |
54 | if (strcasecmp(t, AnyP::ProtocolType_str[p]) == 0) { | |
55 | values.push_back(static_cast<AnyP::ProtocolType>(p)); | |
56 | break; | |
57 | } | |
58 | } | |
59 | if (p == AnyP::PROTO_UNKNOWN) { | |
60 | debugs(28, DBG_IMPORTANT, "WARNING: Ignoring unknown protocol '" << t << "' in the ACL"); | |
61 | // XXX: store the text pattern of this protocol name for live comparisons | |
62 | } | |
63 | } | |
64 | } | |
65 |