]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpUpgradeProtocolAccess.cc
168076c74830da331781842e6e6a4fe83d236d93
2 * Copyright (C) 1996-2025 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.
11 #include "acl/Gadgets.h"
13 #include "ConfigParser.h"
15 #include "HttpUpgradeProtocolAccess.h"
16 #include "sbuf/Stream.h"
20 ProtocolView::ProtocolView(const char * const start
, const size_t len
):
21 ProtocolView(SBuf(start
, len
))
25 ProtocolView::ProtocolView(const SBuf
&proto
):
26 name(proto
.substr(0, proto
.find('/'))),
27 version(proto
.substr(name
.length()))
32 operator <<(std::ostream
&os
, const ProtocolView
&view
)
35 if (!view
.version
.isEmpty())
40 /* HttpUpgradeProtocolAccess */
42 HttpUpgradeProtocolAccess::~HttpUpgradeProtocolAccess()
44 aclDestroyAccessList(&other
);
48 HttpUpgradeProtocolAccess::configureGuard(ConfigParser
&parser
)
50 const auto rawProto
= parser
.NextToken();
52 throw TextException(ToSBuf("expected a protocol name or ", ProtoOther()), Here());
54 if (ProtoOther().cmp(rawProto
) == 0) {
55 aclParseAccessLine(cfg_directive
, parser
, &other
);
59 // To preserve ACL rules checking order, to exclude inapplicable (i.e. wrong
60 // protocol version) rules, and to keep things simple, we merge no rules.
61 acl_access
*access
= nullptr;
62 aclParseAccessLine(cfg_directive
, parser
, &access
);
64 namedGuards
.emplace_back(rawProto
, access
);
67 /* HttpUpgradeProtocolAccess::NamedGuard */
69 HttpUpgradeProtocolAccess::NamedGuard::NamedGuard(const char *rawProtocol
, acl_access
*acls
):
70 protocol(rawProtocol
),
76 HttpUpgradeProtocolAccess::NamedGuard::~NamedGuard() {
77 aclDestroyAccessList(&guard
);