1 #ifndef SQUID_ADAPTATION__CONFIG_H
2 #define SQUID_ADAPTATION__CONFIG_H
5 #include "acl/Gadgets.h"
6 #include "base/AsyncCall.h"
7 #include "adaptation/forward.h"
8 #include "adaptation/Elements.h"
19 static void Finalize(bool enable
);
21 static void ParseServiceSet(void);
22 static void ParseServiceChain(void);
23 static void ParseMetaHeader(ConfigParser
&parser
);
24 static void FreeMetaHeader();
25 static void DumpMetaHeader(StoreEntry
*, const char *);
27 static void ParseAccess(ConfigParser
&parser
);
28 static void FreeAccess(void);
29 static void DumpAccess(StoreEntry
*, const char *);
31 friend class AccessCheck
;
34 static bool Enabled
; // true if at least one adaptation mechanism is
36 // these are global squid.conf options, documented elsewhere
37 static char *masterx_shared_name
; // global TODO: do we need TheConfig?
38 static int service_iteration_limit
;
39 static int send_client_ip
;
40 static int send_username
;
41 static int use_indirect_client
;
43 // Options below are accessed via Icap::TheConfig or Ecap::TheConfig
44 // TODO: move ICAP-specific options to Icap::Config and add TheConfig
46 int service_failure_limit
;
47 time_t oldest_service_failure
;
48 int service_revival_delay
;
51 * Used to store meta headers. The meta headers are custom
52 * ICAP request headers or ECAP options used to pass custom
53 * transaction-state related meta information to a service.
55 class MetaHeader
: public RefCountable
{
57 typedef RefCount
<MetaHeader
> Pointer
;
58 /// Stores a value for the meta header.
59 class Value
: public RefCountable
{
61 typedef RefCount
<Value
> Pointer
;
62 String value
; ///< a header value
63 ACLList
*aclList
; ///< The access list used to determine if this value is valid for a request
64 explicit Value(const String
&aVal
) : value(aVal
), aclList(NULL
) {}
67 typedef Vector
<Value::Pointer
> Values
;
69 explicit MetaHeader(const String
&aName
): name(aName
) {}
72 * Adds a value to the meta header and returns a pointer to the
73 * related Value object.
75 Value::Pointer
addValue(const String
&value
);
78 * Walks through the possible values list of the meta and selects
79 * the first value which matches the given HttpRequest and HttpReply
80 * or NULL if none matches.
82 const char *match(HttpRequest
*request
, HttpReply
*reply
);
83 String name
; ///< The meta header name
84 Values values
; ///< The possible values list for the meta header
86 typedef Vector
<MetaHeader::Pointer
> MetaHeaders
;
87 static MetaHeaders metaHeaders
; ///< The list of configured meta headers
90 * Adds a header to the meta headers list and returns a pointer to the
91 * related metaHeaders object. If the header name already exists in list,
92 * returns a pointer to the existing object.
94 static MetaHeader::Pointer
addMetaHeader(const String
&header
);
96 typedef Vector
<ServiceConfigPointer
> ServiceConfigs
;
97 ServiceConfigs serviceConfigs
;
102 void parseService(void);
103 void freeService(void);
104 void dumpService(StoreEntry
*, const char *) const;
105 ServicePointer
findService(const String
&);
108 * Creates and starts the adaptation services. In the case the adaptation
109 * mechanism is disabled then removes any reference to the services from
110 * access rules and service groups, and returns false.
111 * \return true if the services are ready and running, false otherwise
113 virtual bool finalize();
116 /// Removes any reference to the services from configuration
117 virtual void clear();
119 /// creates service configuration object that will parse and keep cfg info
120 virtual ServiceConfig
*newServiceConfig() const;
122 /// Removes the given service from all service groups.
123 void removeService(const String
& service
);
125 /// Removes access rules of the given service or group
126 void removeRule(const String
& id
);
129 Config(const Config
&); // unsupported
130 Config
&operator =(const Config
&); // unsupported
132 virtual ServicePointer
createService(const ServiceConfigPointer
&cfg
) = 0;
134 static void ParseServiceGroup(ServiceGroupPointer group
);
135 static void FreeServiceGroups(void);
136 static void DumpServiceGroups(StoreEntry
*, const char *);
139 } // namespace Adaptation
141 #endif /* SQUID_ADAPTATION__CONFIG_H */