From be83c66fedc502bbc26d14f0674eaa675060d63c Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 28 Aug 2006 15:55:21 +0000 Subject: Module list diffing git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5046 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index a839960f6..e705e5c4d 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -861,6 +861,38 @@ class TreeSocket : public InspSocket this->WriteLine("CAPAB END"); } + /* Check a comma seperated list for an item */ + bool HasItem(const std::string &list, const std::string &item) + { + irc::commasepstream seplist(list); + + std::string item2 = "*"; + while ((item2 = seplist.GetToken()) != "") + { + if (item2 == item) + return true; + } + + return false; + } + + /* Isolate and return the elements that are different between two comma seperated lists */ + std::string ListDifference(const std::string &one, const std::string &two) + { + irc::commasepstream list_one(one); + std::string item = "*"; + std::string result = ""; + while ((item = list_one.GetToken()) != "") + { + if (!HasItem(two, item)) + { + result.append(" "); + result.append(item); + } + } + return result; + } + bool Capab(std::deque params) { if (params.size() < 1) @@ -885,7 +917,18 @@ class TreeSocket : public InspSocket * Maybe this could be tidier? -- Brain */ if ((this->ModuleList != this->MyCapabilities()) && (this->ModuleList.length())) - reason = "Modules loaded on these servers are not correctly matched"; + { + std::string diff = ListDifference(this->ModuleList, this->MyCapabilities()); + if (!diff.length()) + { + diff = "this server:" + ListDifference(this->MyCapabilities(), this->ModuleList); + } + else + { + diff = "your server:" + diff; + } + reason = "Modules loaded on these servers are not correctly matched, these modules are not loaded on " + diff; + } if (((this->CapKeys.find("IP6SUPPORT") == this->CapKeys.end()) && (ip6support)) || ((this->CapKeys.find("IP6SUPPORT") != this->CapKeys.end()) && (this->CapKeys.find("IP6SUPPORT")->second != ConvToStr(ip6support)))) reason = "We don't both support linking to IPV6 servers"; -- cgit v1.2.3