]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpUpgradeProtocolAccess.cc
2 * Copyright (C) 1996-2023 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 const SBuf
HttpUpgradeProtocolAccess::ProtoOther("OTHER");
22 ProtocolView::ProtocolView(const char * const start
, const size_t len
):
23 ProtocolView(SBuf(start
, len
))
27 ProtocolView::ProtocolView(const SBuf
&proto
):
28 name(proto
.substr(0, proto
.find('/'))),
29 version(proto
.substr(name
.length()))
34 operator <<(std::ostream
&os
, const ProtocolView
&view
)
37 if (!view
.version
.isEmpty())
42 /* HttpUpgradeProtocolAccess */
44 HttpUpgradeProtocolAccess::~HttpUpgradeProtocolAccess()
46 aclDestroyAccessList(&other
);
50 HttpUpgradeProtocolAccess::configureGuard(ConfigParser
&parser
)
52 const auto rawProto
= parser
.NextToken();
54 throw TextException(ToSBuf("expected a protocol name or ", ProtoOther
), Here());
56 if (ProtoOther
.cmp(rawProto
) == 0) {
57 aclParseAccessLine(cfg_directive
, parser
, &other
);
61 // To preserve ACL rules checking order, to exclude inapplicable (i.e. wrong
62 // protocol version) rules, and to keep things simple, we merge no rules.
63 acl_access
*access
= nullptr;
64 aclParseAccessLine(cfg_directive
, parser
, &access
);
66 namedGuards
.emplace_back(rawProto
, access
);
69 /* HttpUpgradeProtocolAccess::NamedGuard */
71 HttpUpgradeProtocolAccess::NamedGuard::NamedGuard(const char *rawProtocol
, acl_access
*acls
):
72 protocol(rawProtocol
),
78 HttpUpgradeProtocolAccess::NamedGuard::~NamedGuard() {
79 aclDestroyAccessList(&guard
);