2 * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
10 #define SQUID_ADAPTATION__ACCESS_CHECK_H
12 #include "AccessLogEntry.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"
22 class ACLFilledChecklist
;
29 // checks adaptation_access rules to find a matching adaptation service
30 class AccessCheck
: public virtual AsyncJob
32 CBDATA_CLASS(AccessCheck
);
35 typedef void AccessCheckCallback(ServiceGroupPointer group
, void *data
);
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
);
42 // use Start to start adaptation checks
43 AccessCheck(const ServiceFilter
&aFilter
, Adaptation::Initiator
*);
47 const ServiceFilter filter
;
48 CbcPointer
<Adaptation::Initiator
> theInitiator
; ///< the job which ordered this access check
49 ACLFilledChecklist
*acl_checklist
;
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
57 void callBack(const ServiceGroupPointer
&g
);
58 bool isCandidate(AccessRule
&r
);
61 void checkCandidates();
62 static void AccessCheckCallbackWrapper(allow_t
, void*);
63 void noteAnswer(allow_t answer
);
68 virtual bool doneAll() const { return false; } /// not done until mustStop
70 bool usedDynamicRules();
74 } // namespace Adaptation
76 #endif /* SQUID_ADAPTATION__ACCESS_CHECK_H */