Squid Web Cache
master
Loading...
Searching...
No Matches
ConnMark.cc
Go to the documentation of this file.
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/ConnMark.h
"
13
#include "
acl/FilledChecklist.h
"
14
#include "
base/IoManip.h
"
15
#include "
client_side.h
"
16
#include "
debug/Stream.h
"
17
#include "
http/Stream.h
"
18
#include "
sbuf/Stream.h
"
19
20
bool
21
Acl::ConnMark::empty
()
const
22
{
23
return
false
;
24
}
25
26
void
27
Acl::ConnMark::parse
()
28
{
29
while
(
const
char
*t =
ConfigParser::strtokFile
()) {
30
SBuf
token(t);
31
Parser::Tokenizer
tokenizer(token);
32
const
auto
mc =
Ip::NfMarkConfig::Parse
(token);
33
marks.push_back(mc);
34
debugs
(28, 7,
"added "
<< mc);
35
}
36
37
if
(marks.empty()) {
38
throw
TexcHere
(
ToSBuf
(
"acl "
, typeString(),
" requires at least one mark"
));
39
}
40
}
41
42
int
43
Acl::ConnMark::match
(
ACLChecklist
*cl)
44
{
45
const
auto
*checklist =
Filled
(cl);
46
const
auto
conn = checklist->conn();
47
48
if
(conn && conn->clientConnection) {
49
const
auto
connmark = conn->clientConnection->nfConnmark;
50
51
for
(
const
auto
&m : marks) {
52
if
(m.matches(connmark)) {
53
debugs
(28, 5,
"found "
<< m <<
" matching 0x"
<<
asHex
(connmark));
54
return
1;
55
}
56
debugs
(28, 7,
"skipped "
<< m <<
" mismatching 0x"
<<
asHex
(connmark));
57
}
58
}
else
{
59
debugs
(28, 7,
"fails: no client connection"
);
60
}
61
62
return
0;
63
}
64
65
SBufList
66
Acl::ConnMark::dump
()
const
67
{
68
SBufList
sl;
69
for
(
const
auto
&m : marks) {
70
sl.push_back(
ToSBuf
(m));
71
}
72
return
sl;
73
}
74
75
char
const
*
76
Acl::ConnMark::typeString
()
const
77
{
78
return
"client_connection_mark"
;
79
}
80
ConnMark.h
FilledChecklist.h
Filled
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
Definition
FilledChecklist.h:146
IoManip.h
asHex
AsHex< Integer > asHex(const Integer n)
a helper to ease AsHex object creation
Definition
IoManip.h:169
TexcHere
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition
TextException.h:63
ACLChecklist
Definition
Checklist.h:31
Acl::ConnMark::parse
void parse() override
parses node representation in squid.conf; dies on failures
Definition
ConnMark.cc:27
Acl::ConnMark::dump
SBufList dump() const override
Definition
ConnMark.cc:66
Acl::ConnMark::typeString
char const * typeString() const override
Definition
ConnMark.cc:76
Acl::ConnMark::empty
bool empty() const override
Definition
ConnMark.cc:21
Acl::ConnMark::match
int match(ACLChecklist *checklist) override
Matches the actual data in checklist against this Acl::Node.
Definition
ConnMark.cc:43
ConfigParser::strtokFile
static char * strtokFile()
Definition
ConfigParser.cc:65
Ip::NfMarkConfig::Parse
static NfMarkConfig Parse(const SBuf &token)
parses a token and returns an object, expects a "mark[/mask]" format
Definition
NfMarkConfig.cc:32
Parser::Tokenizer
Definition
Tokenizer.h:30
SBuf
Definition
SBuf.h:94
client_side.h
Stream.h
debugs
#define debugs(SECTION, LEVEL, CONTENT)
Definition
Stream.h:192
Stream.h
Stream.h
ToSBuf
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition
Stream.h:63
SBufList
std::list< SBuf > SBufList
Definition
forward.h:23
squid.h
squid
src
acl
ConnMark.cc
Generated by
1.9.8