AccessCheck.h
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 #ifndef SQUID_SRC_ADAPTATION_ACCESSCHECK_H
10 #define SQUID_SRC_ADAPTATION_ACCESSCHECK_H
11 
12 #include "acl/Acl.h"
13 #include "adaptation/Elements.h"
14 #include "adaptation/forward.h"
15 #include "adaptation/Initiator.h"
17 #include "base/AsyncJob.h"
18 #include "log/forward.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 {
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,
40 
41 protected:
42  // use Start to start adaptation checks
44  ~AccessCheck() override;
45 
46 private:
49 
50  typedef int Candidate;
51  typedef std::vector<Candidate> Candidates;
53  Candidate topCandidate() const { return *candidates.begin(); }
54  ServiceGroupPointer topGroup() const; // may return nil
55 
56  void callBack(const ServiceGroupPointer &g);
57  bool isCandidate(AccessRule &r);
58 
59 public:
60  void checkCandidates();
61  static void AccessCheckCallbackWrapper(Acl::Answer, void*);
62  void noteAnswer(Acl::Answer answer);
63 
64 protected:
65  // AsyncJob API
66  void start() override;
67  bool doneAll() const override { return false; }
68 
69  bool usedDynamicRules();
70  void check();
71 };
72 
73 } // namespace Adaptation
74 
75 #endif /* SQUID_SRC_ADAPTATION_ACCESSCHECK_H */
76 
CBDATA_CHILD(AccessCheck)
void start() override
called by AsyncStart; do not call directly
Definition: AccessCheck.cc:70
void check()
Walk the access rules list to find rules with applicable service groups.
Definition: AccessCheck.cc:102
Candidate topCandidate() const
Definition: AccessCheck.h:53
information used to search for adaptation services
Definition: ServiceFilter.h:22
ServiceGroupPointer topGroup() const
Definition: AccessCheck.cc:200
AccessCheck(const ServiceFilter &aFilter, Adaptation::Initiator *)
Definition: AccessCheck.cc:46
bool doneAll() const override
whether positive goal has been reached
Definition: AccessCheck.h:67
void callBack(const ServiceGroupPointer &g)
Definition: AccessCheck.cc:191
CbcPointer< Adaptation::Initiator > theInitiator
the job which ordered this access check
Definition: AccessCheck.h:48
static void AccessCheckCallbackWrapper(Acl::Answer, void *)
Definition: AccessCheck.cc:148
const ServiceFilter filter
Definition: AccessCheck.h:47
void noteAnswer(Acl::Answer answer)
process the results of the ACL check
Definition: AccessCheck.cc:169
bool usedDynamicRules()
not done until mustStop
Definition: AccessCheck.cc:80
bool isCandidate(AccessRule &r)
Definition: AccessCheck.cc:220
std::vector< Candidate > Candidates
Definition: AccessCheck.h:51
void AccessCheckCallback(ServiceGroupPointer group, void *data)
Definition: AccessCheck.h:35
static bool Start(Method method, VectPoint vp, HttpRequest *req, HttpReply *, const AccessLogEntryPointer &, Adaptation::Initiator *)
Definition: AccessCheck.cc:30

 

Introduction

Documentation

Support

Miscellaneous