]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/AccessCheck.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / adaptation / AccessCheck.h
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 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
10 #define SQUID_ADAPTATION__ACCESS_CHECK_H
11
12 #include "AccessLogEntry.h"
13 #include "acl/Acl.h"
14 #include "adaptation/Elements.h"
15 #include "adaptation/forward.h"
16 #include "adaptation/Initiator.h"
17 #include "adaptation/ServiceFilter.h"
18 #include "base/AsyncJob.h"
19
20 class HttpRequest;
21 class HttpReply;
22 class ACLFilledChecklist;
23
24 namespace Adaptation
25 {
26
27 class AccessRule;
28
29 // checks adaptation_access rules to find a matching adaptation service
30 class AccessCheck: public virtual AsyncJob
31 {
32 CBDATA_CLASS(AccessCheck);
33
34 public:
35 typedef void AccessCheckCallback(ServiceGroupPointer group, void *data);
36
37 // use this to start async ACL checks; returns true if started
38 static bool Start(Method method, VectPoint vp, HttpRequest *req,
39 HttpReply *rep, AccessLogEntry::Pointer &al, Adaptation::Initiator *initiator);
40
41 protected:
42 // use Start to start adaptation checks
43 AccessCheck(const ServiceFilter &aFilter, Adaptation::Initiator *);
44 ~AccessCheck();
45
46 private:
47 const ServiceFilter filter;
48 CbcPointer<Adaptation::Initiator> theInitiator; ///< the job which ordered this access check
49 ACLFilledChecklist *acl_checklist;
50
51 typedef int Candidate;
52 typedef std::vector<Candidate> Candidates;
53 Candidates candidates;
54 Candidate topCandidate() const { return *candidates.begin(); }
55 ServiceGroupPointer topGroup() const; // may return nil
56
57 void callBack(const ServiceGroupPointer &g);
58 bool isCandidate(AccessRule &r);
59
60 public:
61 void checkCandidates();
62 static void AccessCheckCallbackWrapper(allow_t, void*);
63 void noteAnswer(allow_t answer);
64
65 protected:
66 // AsyncJob API
67 virtual void start();
68 virtual bool doneAll() const { return false; } /// not done until mustStop
69
70 bool usedDynamicRules();
71 void check();
72 };
73
74 } // namespace Adaptation
75
76 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */
77