summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:52:46 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:52:46 +0000
commite62516014fdbc13a0baf9b869b747300bfdccbc7 (patch)
treed16b926b9d7bd05f93c4ab90f9ea80cd2b78cc6e
parentfe7ce903b838912a34de9e1530dd9ca45af5aed3 (diff)
Add s2s backward compatability for protocol changes
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11656 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_spanningtree/capab.cpp6
-rw-r--r--src/modules/m_spanningtree/compat.cpp46
-rw-r--r--src/modules/m_spanningtree/main.h2
-rw-r--r--src/modules/m_spanningtree/treesocket.h1
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp8
5 files changed, 51 insertions, 12 deletions
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp
index ac97674f5..5b68ab4f9 100644
--- a/src/modules/m_spanningtree/capab.cpp
+++ b/src/modules/m_spanningtree/capab.cpp
@@ -217,10 +217,10 @@ bool TreeSocket::Capab(const parameterlist &params)
}
else
{
- int otherProto = atoi(CapKeys.find("PROTOCOL")->second.c_str());
- if (otherProto < MinCompatProtocol)
+ proto_version = atoi(CapKeys.find("PROTOCOL")->second.c_str());
+ if (proto_version < MinCompatProtocol)
{
- reason = "Server is using protocol version " + ConvToStr(otherProto) +
+ reason = "Server is using protocol version " + ConvToStr(proto_version) +
" which is too old to link with this server (version " + ConvToStr(ProtocolVersion)
+ (ProtocolVersion != MinCompatProtocol ? ", links with " + ConvToStr(MinCompatProtocol) + " and above)" : ")");
}
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
new file mode 100644
index 000000000..345215031
--- /dev/null
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -0,0 +1,46 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include "inspircd.h"
+#include "main.h"
+#include "treesocket.h"
+
+void TreeSocket::WriteLine(std::string line)
+{
+ if (line[0] != ':' && LinkState == CONNECTED)
+ {
+ ServerInstance->Logs->Log("m_spanningtree", DEFAULT, "Sending line without server prefix!");
+ line = ":" + ServerInstance->Config->GetSID() + " " + line;
+ }
+ if (proto_version != ProtocolVersion)
+ {
+ std::string::size_type a = line.find(' ');
+ std::string::size_type b = line.find(' ', a);
+ std::string command = line.substr(a,b);
+ // now try to find a translation entry
+ // TODO a more efficient lookup method will be needed later
+ if (proto_version < 1202 && command == "FIDENT")
+ {
+ // a more aggressive method would be to translate to CHGIDENT
+ ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Dropping FIDENT to 1201-protocol server");
+ return;
+ }
+ }
+
+ ServerInstance->Logs->Log("m_spanningtree",DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());
+ line.append("\r\n");
+ this->Write(line);
+}
+
+
+
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 06b66a5cf..2a7248f48 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -26,7 +26,7 @@
* Failure to document your protocol changes will result in a painfully
* painful death by pain. You have been warned.
*/
-const long ProtocolVersion = 1201;
+const long ProtocolVersion = 1202;
const long MinCompatProtocol = 1201;
/** Forward declarations
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 77934bc07..93016126b 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -92,6 +92,7 @@ class TreeSocket : public BufferedSocket
bool sentcapab; /* Have sent CAPAB already */
bool auth_fingerprint; /* Did we auth using SSL fingerprint */
bool auth_challenge; /* Did we auth using challenge/response */
+ int proto_version; /* Remote protocol version */
public:
HandshakeTimer* hstimer; /* Handshake timer, needed to work around I/O hook buffering */
time_t age;
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index b5482e42e..085f14117 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -29,14 +29,6 @@
/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/handshaketimer.h */
-void TreeSocket::WriteLine(std::string line)
-{
- ServerInstance->Logs->Log("m_spanningtree",DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());
- line.append("\r\n");
- this->Write(line);
-}
-
-
/* Handle ERROR command */
bool TreeSocket::Error(parameterlist &params)
{