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