]> git.ipfire.org Git - thirdparty/squid.git/blob - src/acl/Note.cc
Crypto-NG: initial GnuTLS support for encrypted server connections
[thirdparty/squid.git] / src / acl / Note.cc
1 /*
2 * Copyright (C) 1996-2017 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 #include "squid.h"
10 #include "acl/Checklist.h"
11 #include "acl/HttpHeaderData.h"
12 #include "acl/Note.h"
13 #include "acl/NoteData.h"
14 #include "HttpRequest.h"
15 #include "Notes.h"
16 #include "parser/Tokenizer.h"
17 #include "sbuf/StringConvert.h"
18
19 int
20 ACLNoteStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *checklist, ACLFlags &flags)
21 {
22 if (const auto request = checklist->request) {
23 if (request->hasNotes() && matchNotes(data, request->notes().getRaw(), flags.delimiters()))
24 return 1;
25 #if USE_ADAPTATION
26 const Adaptation::History::Pointer ah = request->adaptLogHistory();
27 if (ah != NULL && ah->metaHeaders != NULL && matchNotes(data, ah->metaHeaders.getRaw(), flags.delimiters()))
28 return 1;
29 #endif
30 }
31 return 0;
32 }
33
34 bool
35 ACLNoteStrategy::matchNotes(ACLData<MatchType> *noteData, const NotePairs *note, const CharacterSet *delimiters) const
36 {
37 const NotePairs::Entries &entries = note->expandListEntries(delimiters);
38 for (auto e: entries)
39 if (noteData->match(e.getRaw()))
40 return true;
41 return false;
42 }
43
44 ACLNoteStrategy *
45 ACLNoteStrategy::Instance()
46 {
47 return &Instance_;
48 }
49
50 ACLNoteStrategy ACLNoteStrategy::Instance_;
51