--- /dev/null
+/*
+ * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+#include "acl/AnnotateClient.h"
+#include "acl/AnnotationData.h"
+#include "client_side.h"
+#include "http/Stream.h"
+#include "Notes.h"
+
+int
+ACLAnnotateClientStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *checklist, ACLFlags &flags)
+{
+ if (const auto conn = checklist->conn()) {
+ ACLAnnotationData *tdata = dynamic_cast<ACLAnnotationData*>(data);
+ assert(tdata);
+ tdata->annotate(conn->notes(), flags.delimiters(), checklist->al);
+ if (const auto request = checklist->request)
+ tdata->annotate(request->notes(), flags.delimiters(), checklist->al);
+ return 1;
+ }
+ return 0;
+}
+
+ACLAnnotateClientStrategy *
+ACLAnnotateClientStrategy::Instance()
+{
+ return &Instance_;
+}
+
+ACLAnnotateClientStrategy ACLAnnotateClientStrategy::Instance_;
+
--- /dev/null
+/*
+ * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID_ACLANNOTATECLIENT
+#define SQUID_ACLANNOTATECLIENT
+
+#include "acl/Strategised.h"
+#include "acl/Strategy.h"
+
+/// \ingroup ACLAPI
+class ACLAnnotateClientStrategy : public ACLStrategy<NotePairs::Entry *>
+{
+public:
+ static ACLAnnotateClientStrategy *Instance();
+ ACLAnnotateClientStrategy(ACLAnnotateClientStrategy const &) = delete;
+ ACLAnnotateClientStrategy& operator=(ACLAnnotateClientStrategy const &) = delete;
+
+ virtual bool requiresRequest() const { return true; }
+ virtual int match(ACLData<MatchType> * &, ACLFilledChecklist *, ACLFlags &);
+
+private:
+ static ACLAnnotateClientStrategy Instance_;
+ ACLAnnotateClientStrategy() { }
+};
+
+/// \ingroup ACLAPI
+class ACLAnnotateClient
+{
+private:
+ static ACL::Prototype RegistryProtoype;
+ static ACLStrategised<NotePairs::Entry *> RegistryEntry_;
+};
+
+#endif /* SQUID_ACLANNOTATECLIENT */
+
--- /dev/null
+/*
+ * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+#include "acl/AnnotateTransaction.h"
+#include "acl/AnnotationData.h"
+#include "acl/Checklist.h"
+#include "HttpRequest.h"
+#include "Notes.h"
+
+int
+ACLAnnotateTransactionStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *checklist, ACLFlags &flags)
+{
+ if (const auto request = checklist->request) {
+ ACLAnnotationData *tdata = dynamic_cast<ACLAnnotationData*>(data);
+ assert(tdata);
+ tdata->annotate(request->notes(), flags.delimiters(), checklist->al);
+ return 1;
+ }
+ return 0;
+}
+
+ACLAnnotateTransactionStrategy *
+ACLAnnotateTransactionStrategy::Instance()
+{
+ return &Instance_;
+}
+
+ACLAnnotateTransactionStrategy ACLAnnotateTransactionStrategy::Instance_;
+
--- /dev/null
+/*
+ * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID_ACLANNOTATETRANSACTION
+#define SQUID_ACLANNOTATETRANSACTION
+
+#include "acl/Strategised.h"
+#include "acl/Strategy.h"
+
+/// \ingroup ACLAPI
+class ACLAnnotateTransactionStrategy : public ACLStrategy<NotePairs::Entry *>
+{
+public:
+ virtual int match(ACLData<MatchType> * &, ACLFilledChecklist *, ACLFlags &);
+ virtual bool requiresRequest() const { return true; }
+
+ static ACLAnnotateTransactionStrategy *Instance();
+ ACLAnnotateTransactionStrategy(ACLAnnotateTransactionStrategy const &) = delete;
+ ACLAnnotateTransactionStrategy& operator=(ACLAnnotateTransactionStrategy const &) = delete;
+
+private:
+ static ACLAnnotateTransactionStrategy Instance_;
+ ACLAnnotateTransactionStrategy() {}
+};
+
+/// \ingroup ACLAPI
+class ACLAnnotateTransaction
+{
+private:
+ static ACL::Prototype RegistryProtoype;
+ static ACLStrategised<NotePairs::Entry *> RegistryEntry_;
+};
+
+#endif /* SQUID_ACLANNOTATETRANSACTION */
+
--- /dev/null
+/*
+ * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
+#include "acl/Acl.h"
+#include "acl/AnnotationData.h"
+#include "acl/Checklist.h"
+#include "cache_cf.h"
+#include "ConfigParser.h"
+#include "Debug.h"
+#include "format/Format.h"
+#include "sbuf/Algorithms.h"
+
+const char *AnnotationBlackList[] = {
+ "user",
+ "group",
+ "password",
+ "status",
+ "message",
+ "log",
+ "tag",
+ "ttl",
+ "ha1",
+ "rewrite-url",
+ "url",
+ nullptr
+};
+
+ACLAnnotationData::ACLAnnotationData()
+ : notes(new Notes("annotation_data", AnnotationBlackList)) {}
+
+SBufList
+ACLAnnotationData::dump() const
+{
+ SBufList sl;
+ if (const char *strNotes = notes->toString())
+ sl.push_back(SBuf(strNotes));
+ return sl;
+}
+
+void
+ACLAnnotationData::parse()
+{
+ notes->parseKvPair();
+ if (char *t = ConfigParser::PeekAtToken()) {
+ debugs(29, DBG_CRITICAL, "FATAL: Unexpected argument '" << t << "' after annotation specification");
+ self_destruct();
+ return;
+ }
+}
+
+void
+ACLAnnotationData::annotate(NotePairs::Pointer pairs, const CharacterSet *delimiters, const AccessLogEntry::Pointer &al)
+{
+ notes->updateNotePairs(pairs, delimiters, al);
+}
+
+ACLData<NotePairs::Entry *> *
+ACLAnnotationData::clone() const
+{
+ return new ACLAnnotationData;
+}
+
--- /dev/null
+/*
+ * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID_ACLANNOTATIONDATA_H
+#define SQUID_ACLANNOTATIONDATA_H
+
+#include "AccessLogEntry.h"
+#include "acl/Data.h"
+#include "Notes.h"
+
+/// \ingroup ACLAPI
+class ACLAnnotationData : public ACLData<NotePairs::Entry *>
+{
+ MEMPROXY_CLASS(ACLAnnotationData);
+
+public:
+ ACLAnnotationData();
+
+ /* ACLData<M> API */
+ virtual bool match(NotePairs::Entry *) { return true; }
+ virtual SBufList dump() const;
+ virtual void parse();
+ virtual bool empty() const { return notes->empty(); }
+ virtual ACLData<NotePairs::Entry *> *clone() const;
+
+ /// Stores annotations into pairs.
+ void annotate(NotePairs::Pointer pairs, const CharacterSet *delimiters, const AccessLogEntry::Pointer &al);
+
+private:
+ Notes::Pointer notes;
+};
+
+#endif /* SQUID_ACLANNOTATIONDATA_H */
+