ConnMark.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
20bool
22{
23 return false;
24}
25
26void
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
42int
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 " << asHex(connmark));
54 return 1;
55 }
56 debugs(28, 7, "skipped " << m << " mismatching " << asHex(connmark));
57 }
58 } else {
59 debugs(28, 7, "fails: no client connection");
60 }
61
62 return 0;
63}
64
67{
68 SBufList sl;
69 for (const auto &m : marks) {
70 sl.push_back(ToSBuf(m));
71 }
72 return sl;
73}
74
75char const *
77{
78 return "client_connection_mark";
79}
80
ACLFilledChecklist * Filled(ACLChecklist *checklist)
convenience and safety wrapper for dynamic_cast<ACLFilledChecklist*>
AsHex< Integer > asHex(const Integer n)
a helper to ease AsHex object creation
Definition: IoManip.h:99
#define TexcHere(msg)
legacy convenience macro; it is not difficult to type Here() now
Definition: TextException.h:63
int conn
the current server connection FD
Definition: Transport.cc:26
void parse() override
parses node representation in squid.conf; dies on failures
Definition: ConnMark.cc:27
SBufList dump() const override
Definition: ConnMark.cc:66
char const * typeString() const override
Definition: ConnMark.cc:76
bool empty() const override
Definition: ConnMark.cc:21
int match(ACLChecklist *checklist) override
Matches the actual data in checklist against this ACL.
Definition: ConnMark.cc:43
static char * strtokFile()
Definition: ConfigParser.cc:65
static NfMarkConfig Parse(const SBuf &token)
parses a token and returns an object, expects a "mark[/mask]" format
Definition: NfMarkConfig.cc:32
Definition: SBuf.h:94
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition: Stream.h:63
std::list< SBuf > SBufList
Definition: forward.h:23

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors