]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Config.h
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / adaptation / Config.h
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_ADAPTATION__CONFIG_H
10 #define SQUID_ADAPTATION__CONFIG_H
11
12 #include "acl/forward.h"
13 #include "adaptation/Elements.h"
14 #include "adaptation/forward.h"
15 #include "base/AsyncCall.h"
16 #include "event.h"
17 #include "Notes.h"
18 #include "SquidString.h"
19
20 class ConfigParser;
21 class HttpRequest;
22 class HttpReply;
23
24 namespace Adaptation
25 {
26
27 class Config
28 {
29 public:
30 static void Finalize(bool enable);
31
32 static void ParseServiceSet(void);
33 static void ParseServiceChain(void);
34
35 static void ParseAccess(ConfigParser &parser);
36 static void FreeAccess(void);
37 static void DumpAccess(StoreEntry *, const char *);
38
39 friend class AccessCheck;
40
41 public:
42 static bool Enabled; // true if at least one adaptation mechanism is
43
44 // these are global squid.conf options, documented elsewhere
45 static char *masterx_shared_name; // global TODO: do we need TheConfig?
46 static int service_iteration_limit;
47 static int send_client_ip;
48 static int send_username;
49 static int use_indirect_client;
50
51 // Options below are accessed via Icap::TheConfig or Ecap::TheConfig
52 // TODO: move ICAP-specific options to Icap::Config and add TheConfig
53 int onoff;
54 int service_failure_limit;
55 time_t oldest_service_failure;
56 int service_revival_delay;
57
58 static Notes metaHeaders; ///< The list of configured meta headers
59
60 static bool needHistory; ///< HttpRequest adaptation history should recorded
61
62 typedef std::vector<ServiceConfigPointer> ServiceConfigs;
63 ServiceConfigs serviceConfigs;
64
65 Config();
66 virtual ~Config();
67
68 void parseService(void);
69 void freeService(void);
70 void dumpService(StoreEntry *, const char *) const;
71 ServiceConfigPointer findServiceConfig(const String&);
72
73 /**
74 * Creates and starts the adaptation services. In the case the adaptation
75 * mechanism is disabled then removes any reference to the services from
76 * access rules and service groups, and returns false.
77 * \return true if the services are ready and running, false otherwise
78 */
79 virtual bool finalize();
80
81 protected:
82 /// Removes any reference to the services from configuration
83 virtual void clear();
84
85 /// creates service configuration object that will parse and keep cfg info
86 virtual ServiceConfig *newServiceConfig() const;
87
88 /// Removes the given service from all service groups.
89 void removeService(const String& service);
90
91 /// Removes access rules of the given service or group
92 void removeRule(const String& id);
93
94 private:
95 Config(const Config &); // unsupported
96 Config &operator =(const Config &); // unsupported
97
98 virtual ServicePointer createService(const ServiceConfigPointer &cfg) = 0;
99
100 static void ParseServiceGroup(ServiceGroupPointer group);
101 static void FreeServiceGroups(void);
102 static void DumpServiceGroups(StoreEntry *, const char *);
103 };
104
105 } // namespace Adaptation
106
107 #endif /* SQUID_ADAPTATION__CONFIG_H */
108