summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-28 15:55:21 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-28 15:55:21 +0000
commitbe83c66fedc502bbc26d14f0674eaa675060d63c (patch)
treec94f4ef9e8402a049976b58334612602c45d6b0b /src/modules/m_spanningtree.cpp
parent92b531482ed910c4980cf612135c7bb3f3eb4bbf (diff)
Module list diffing
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5046 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree.cpp')
-rw-r--r--src/modules/m_spanningtree.cpp45
1 files changed, 44 insertions, 1 deletions
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<std::string> 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";