From 1f4ffdfee959614e3afe7e7daab06a040ca1ac41 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 13 Jan 2023 20:43:13 +0000 Subject: Various improvements to the cloak system. - Only rewrite cloak => cloaking if the cloak_md5 module is also loaded. - Include the cloak method in the link data. - If 1206 servers are using different cloak methods then ignore the other data when telling operators about the link failure. - Clean up the code in a few places. --- src/modules/m_cloak.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/modules/m_cloak.cpp') diff --git a/src/modules/m_cloak.cpp b/src/modules/m_cloak.cpp index f7ef8fdb8..f6e0c2e98 100644 --- a/src/modules/m_cloak.cpp +++ b/src/modules/m_cloak.cpp @@ -21,6 +21,7 @@ #include "clientprotocolevent.h" #include "modules/cloak.h" #include "modules/ircv3_replies.h" +#include "utility/map.h" typedef std::vector CloakMethodList; @@ -233,10 +234,30 @@ class ModuleCloakSHA256 final cloakmethods.swap(newcloakmethods); } - void GetLinkData(Module::LinkData& data, std::string& compatdata) override + void CompareLinkData(const LinkData& otherdata, LinkDataDiff& diffs) { - if (!cloakmethods.empty()) - cloakmethods.front()->GetLinkData(data, compatdata); + std::string unused; + LinkData data; + this->GetLinkData(data, unused); + + // If the only difference is the method then just include that. + insp::map::difference(data, otherdata, diffs); + auto it = diffs.find("method"); + if (it != diffs.end()) + diffs = { *it }; + } + + void GetLinkData(LinkData& data, std::string& compatdata) override + { + if (cloakmethods.empty()) + return; + + auto& cloakmethod = cloakmethods.front(); + cloakmethod->GetLinkData(data, compatdata); + + data["method"] = cloakmethod->GetName(); + if (compatdata.empty()) + compatdata.assign(cloakmethod->GetName()); } void Prioritize() override -- cgit v1.3.1-10-gc9f91