does not get linked in, because nobody is using these classes by name.
*/
+#if USE_ADAPTATION
+#include "acl/AdaptationService.h"
+#include "acl/AdaptationServiceData.h"
+#endif
#include "acl/AllOf.h"
#include "acl/AnyOf.h"
#if USE_SQUID_EUI
ACL::Prototype ACLNote::RegistryProtoype(&ACLNote::RegistryEntry_, "note");
ACLStrategised<HttpRequest *> ACLNote::RegistryEntry_(new ACLNoteData, ACLNoteStrategy::Instance(), "note");
+
+#if USE_ADAPTATION
+ACL::Prototype ACLAdaptationService::RegistryProtoype(&ACLAdaptationService::RegistryEntry_, "adaptation_service");
+ACLStrategised<const char *> ACLAdaptationService::RegistryEntry_(new ACLAdaptationServiceData, ACLAdaptationServiceStrategy::Instance(), "adaptation_service");
+#endif
--- /dev/null
+#include "squid.h"
+#include "acl/Checklist.h"
+#include "acl/IntRange.h"
+#include "acl/AdaptationService.h"
+#include "adaptation/Config.h"
+#include "adaptation/History.h"
+#include "HttpRequest.h"
+
+int
+ACLAdaptationServiceStrategy::match (ACLData<MatchType> * &data, ACLFilledChecklist *checklist, ACLFlags &)
+{
+ HttpRequest::Pointer request = checklist->request;
+ if (request == NULL)
+ return 0;
+ Adaptation::History::Pointer ah = request->adaptHistory();
+ if (ah == NULL)
+ return 0;
+
+ Adaptation::History::AdaptationServices::iterator it;
+ for (it = ah->theAdaptationServices.begin(); it != ah->theAdaptationServices.end(); ++it) {
+ if (data->match(it->c_str()))
+ return 1;
+ }
+
+ return 0;
+}
+
+ACLAdaptationServiceStrategy *
+ACLAdaptationServiceStrategy::Instance()
+{
+ return &Instance_;
+}
+
+ACLAdaptationServiceStrategy ACLAdaptationServiceStrategy::Instance_;
--- /dev/null
+#ifndef SQUID_ACLADAPTATIONSERVICE_H
+#define SQUID_ACLADAPTATIONSERVICE_H
+
+#include "acl/Strategised.h"
+#include "acl/Strategy.h"
+
+/// \ingroup ACLAPI
+class ACLAdaptationServiceStrategy : public ACLStrategy<const char *>
+{
+
+public:
+ virtual int match (ACLData<MatchType> * &, ACLFilledChecklist *, ACLFlags &);
+ static ACLAdaptationServiceStrategy *Instance();
+ /**
+ * Not implemented to prevent copies of the instance.
+ */
+ ACLAdaptationServiceStrategy(ACLAdaptationServiceStrategy const &);
+
+private:
+ static ACLAdaptationServiceStrategy Instance_;
+ ACLAdaptationServiceStrategy() {}
+
+ ACLAdaptationServiceStrategy &operator = (ACLAdaptationServiceStrategy const &);
+};
+
+/// \ingroup ACLAPI
+class ACLAdaptationService
+{
+
+private:
+ static ACL::Prototype RegistryProtoype;
+ static ACLStrategised<const char *> RegistryEntry_;
+};
+
+#endif /* SQUID_ACLADAPTATIONSERVICE_H */
--- /dev/null
+#include "squid.h"
+#include "acl/AdaptationServiceData.h"
+#include "acl/Checklist.h"
+#include "adaptation/Config.h"
+#include "adaptation/ecap/Config.h"
+#include "adaptation/icap/Config.h"
+#include "adaptation/Service.h"
+#include "adaptation/ServiceGroups.h"
+#include "cache_cf.h"
+#include "ConfigParser.h"
+#include "Debug.h"
+#include "wordlist.h"
+
+void
+ACLAdaptationServiceData::parse()
+{
+ Adaptation::Config::needHistory = true;
+ while (char *t = ConfigParser::strtokFile()) {
+ if (
+#if USE_ECAP
+ Adaptation::Ecap::TheConfig.findServiceConfig(t) == NULL &&
+#endif
+#if ICAP_CLIENT
+ Adaptation::Icap::TheConfig.findServiceConfig(t) == NULL &&
+#endif
+ Adaptation::FindGroup(t) == NULL) {
+ debugs(28, DBG_CRITICAL, "FATAL: Adaptation service/group " << t << " in adaptation_service acl is not defined");
+ self_destruct();
+ }
+ insert(t);
+ }
+}
+
+ACLData<char const *> *
+ACLAdaptationServiceData::clone() const
+{
+ return new ACLAdaptationServiceData(*this);
+}
+
--- /dev/null
+
+#ifndef SQUID_ADAPTATIONSERVICEDATA_H
+#define SQUID_ADAPTATIONSERVICEDATA_H
+
+#include "acl/Acl.h"
+#include "acl/Data.h"
+#include "acl/StringData.h"
+
+/// \ingroup ACLAPI
+class ACLAdaptationServiceData : public ACLStringData
+{
+public:
+ ACLAdaptationServiceData() : ACLStringData() {}
+ ACLAdaptationServiceData(ACLAdaptationServiceData const &old) : ACLStringData(old) {};
+ // Not implemented
+ ACLAdaptationServiceData &operator= (ACLAdaptationServiceData const &);
+ virtual void parse();
+ virtual ACLData<char const *> *clone() const;
+};
+
+#endif /* SQUID_ADAPTATIONSERVICEDATA_H */
libacls_la_SOURCES += $(SSL_ACLS)
endif
+if USE_ADAPTATION
+libacls_la_SOURCES += AdaptationService.h \
+ AdaptationService.cc \
+ AdaptationServiceData.h \
+ AdaptationServiceData.cc
+endif
+
+
EXTRA_libacls_la_SOURCES += $(SSL_ACLS)
virtual ~ACLStringData();
bool match(char const *);
wordlist *dump();
- void parse();
+ virtual void parse();
bool empty() const;
virtual ACLData<char const *> *clone() const;
/// Insert a string data value
NULL
};
Notes Adaptation::Config::metaHeaders("ICAP header", metasBlacklist);
+bool Adaptation::Config::needHistory = false;
Adaptation::ServiceConfig*
Adaptation::Config::newServiceConfig() const
}
}
+Adaptation::ServiceConfigPointer
+Adaptation::Config::findServiceConfig(const String &service)
+{
+ typedef ServiceConfigs::const_iterator SCI;
+ const ServiceConfigs& configs = serviceConfigs;
+ for (SCI cfg = configs.begin(); cfg != configs.end(); ++cfg) {
+ if ((*cfg)->key == service)
+ return *cfg;
+ }
+ return NULL;
+}
+
void
Adaptation::Config::removeRule(const String& id)
{
static Notes metaHeaders; ///< The list of configured meta headers
+ static bool needHistory; ///< HttpRequest adaptation history should recorded
+
typedef Vector<ServiceConfigPointer> ServiceConfigs;
ServiceConfigs serviceConfigs;
void parseService(void);
void freeService(void);
void dumpService(StoreEntry *, const char *) const;
- ServicePointer findService(const String&);
+ ServiceConfigPointer findServiceConfig(const String&);
/**
* Creates and starts the adaptation services. In the case the adaptation
allMeta.compact();
}
+void
+Adaptation::History::recordAdaptationService(SBuf &srvId)
+{
+ theAdaptationServices.push_back(srvId);
+}
+
void
Adaptation::History::setFutureServices(const DynamicGroupCfg &services)
{
#include "base/Vector.h"
#include "HttpHeader.h"
#include "Notes.h"
+#include "SBuf.h"
#include "SquidString.h"
namespace Adaptation
/// store the last meta header fields received from the adaptation service
void recordMeta(const HttpHeader *lm);
+ void recordAdaptationService(SBuf &srvId);
public:
/// Last received meta header (REQMOD or RESPMOD, whichever comes last).
HttpHeader lastMeta;
/// AccessLogEntry::notes when ALE becomes available
NotePairs::Pointer metaHeaders;
+ typedef Vector<SBuf> AdaptationServices;
+ AdaptationServices theAdaptationServices; ///< The service groups used
+
/// sets future services for the Adaptation::AccessCheck to notice
void setFutureServices(const DynamicGroupCfg &services);
Adaptation::Initiate::start();
thePlan = ServicePlan(theGroup, filter());
+
+ // Add adaptation group name once and now, before
+ // dynamic groups change it at step() time.
+ if (Adaptation::Config::needHistory && !thePlan.exhausted() && (dynamic_cast<ServiceSet *>(theGroup.getRaw()) || dynamic_cast<ServiceChain *>(theGroup.getRaw()))) {
+ HttpRequest *request = dynamic_cast<HttpRequest*>(theMsg);
+ if (!request)
+ request = theCause;
+ Must(request);
+ Adaptation::History::Pointer ah = request->adaptHistory(true);
+ SBuf gid(theGroup->id);
+ ah->recordAdaptationService(gid);
+ }
+
step();
}
Must(service != NULL);
debugs(93,5, HERE << "using adaptation service: " << service->cfg().key);
+ if (Adaptation::Config::needHistory) {
+ Adaptation::History::Pointer ah = request->adaptHistory(true);
+ SBuf uid(thePlan.current()->cfg().key);
+ ah->recordAdaptationService(uid);
+ }
+
theLauncher = initiateAdaptation(
service->makeXactLauncher(theMsg, theCause));
Must(initiated(theLauncher));
# Annotation sources include note and adaptation_meta directives
# as well as helper and eCAP responses.
+ acl aclname adaptation_service service ...
+ # Matches the name of any icap_service, ecap_service,
+ # adaptation_service_set, or adaptation_service_chain that Squid
+ # has used (or attempted to use) for the master transaction.
+ # This ACL must be defined after the corresponding adaptation
+ # service is named in squid.conf. This ACL is usable with
+ # adaptation_meta because it starts matching immediately after
+ # the service has been selected for adaptation.
+
IF USE_SSL
acl aclname ssl_error errorname
# match against SSL certificate validation error [fast]