summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-12-29 19:23:06 +0100
committerPeter Powell <petpow@saberuk.com>2019-12-29 19:41:56 +0100
commit953ee6d2d1118307884ccff4ca29cdde068ecf89 (patch)
treee6816dcee9d8293cf51b9e407bae07cc1cb64949
parent4cc992f6c20354eef88b7652f268591daccb1b20 (diff)
Mark messages from ulined clients with the inspircd.org/service tag.
-rw-r--r--src/modules/m_spanningtree/main.cpp1
-rw-r--r--src/modules/m_spanningtree/main.h4
-rw-r--r--src/modules/m_spanningtree/tags.cpp38
-rw-r--r--src/modules/m_spanningtree/tags.h33
4 files changed, 76 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index fbc6ad40c..59d349d39 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -49,6 +49,7 @@ ModuleSpanningTree::ModuleSpanningTree()
, messageeventprov(this, "event/server-message")
, synceventprov(this, "event/server-sync")
, sslapi(this)
+ , servicetag(this)
, DNS(this, "DNS")
, tagevprov(this, "event/messagetag")
, loopCall(false)
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 3a61927b4..bc5b5d926 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -33,6 +33,7 @@
#include "servercommand.h"
#include "commands.h"
#include "protocolinterface.h"
+#include "tags.h"
/** An enumeration of all known protocol versions.
*
@@ -109,6 +110,9 @@ class ModuleSpanningTree
/** API for accessing user SSL certificates. */
UserCertificateAPI sslapi;
+ /** Tag for marking services pseudoclients. */
+ ServiceTag servicetag;
+
public:
dynamic_reference<DNS::Manager> DNS;
diff --git a/src/modules/m_spanningtree/tags.cpp b/src/modules/m_spanningtree/tags.cpp
new file mode 100644
index 000000000..844300705
--- /dev/null
+++ b/src/modules/m_spanningtree/tags.cpp
@@ -0,0 +1,38 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "main.h"
+
+ServiceTag::ServiceTag(Module* mod)
+ : ClientProtocol::MessageTagProvider(mod)
+ , ctctagcap(mod, "message-tags")
+{
+}
+
+void ServiceTag::OnPopulateTags(ClientProtocol::Message& msg) CXX11_OVERRIDE
+{
+ User* const user = msg.GetSourceUser();
+ if (user && user->server->IsULine())
+ msg.AddTag("inspircd.org/service", this, "");
+}
+
+bool ServiceTag::ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) CXX11_OVERRIDE
+{
+ return ctctagcap.get(user);
+}
diff --git a/src/modules/m_spanningtree/tags.h b/src/modules/m_spanningtree/tags.h
new file mode 100644
index 000000000..7a40f0220
--- /dev/null
+++ b/src/modules/m_spanningtree/tags.h
@@ -0,0 +1,33 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2019 Peter Powell <petpow@saberuk.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include "modules/cap.h"
+
+class ServiceTag : public ClientProtocol::MessageTagProvider
+{
+ private:
+ Cap::Reference ctctagcap;
+
+ public:
+ ServiceTag(Module* mod);
+ void OnPopulateTags(ClientProtocol::Message& msg) CXX11_OVERRIDE;
+ bool ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) CXX11_OVERRIDE;
+};