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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors