1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include "treesocket.h"
18 static const char* const forge_common_1201[] = {
30 static std::string wide_newline("\r\n");
32 void TreeSocket::CompatAddModules(std::vector<std::string>& modlist)
34 if (proto_version < 1202)
36 // you MUST have chgident loaded in order to be able to translate FIDENT
37 modlist.push_back("m_chgident.so");
38 for(int i=0; i * sizeof(char*) < sizeof(forge_common_1201); i++)
40 if (ServerInstance->Modules->Find(forge_common_1201[i]))
41 modlist.push_back(forge_common_1201[i]);
46 void TreeSocket::WriteLine(std::string line)
48 if (LinkState == CONNECTED)
52 ServerInstance->Logs->Log("m_spanningtree", DEFAULT, "Sending line without server prefix!");
53 line = ":" + ServerInstance->Config->GetSID() + " " + line;
55 if (proto_version != ProtocolVersion)
57 std::string::size_type a = line.find(' ') + 1;
58 std::string::size_type b = line.find(' ', a);
59 std::string command = line.substr(a, b-a);
60 // now try to find a translation entry
61 // TODO a more efficient lookup method will be needed later
62 if (proto_version < 1202 && command == "FIDENT")
64 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Rewriting FIDENT for 1201-protocol server");
65 line = ":" + ServerInstance->Config->GetSID() + " CHGIDENT " + line.substr(1,a-2) + line.substr(b);
67 else if (proto_version < 1202 && command == "SAVE")
69 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Rewriting SAVE for 1201-protocol server");
70 std::string::size_type c = line.find(' ', b + 1);
71 std::string uid = line.substr(b, c - b);
72 line = ":" + ServerInstance->Config->GetSID() + " SVSNICK " + uid + line.substr(b);
74 else if (proto_version < 1202 && command == "AWAY")
76 if (b != std::string::npos)
78 std::string::size_type c = line.find(' ', b + 1);
85 ServerInstance->Logs->Log("m_spanningtree",DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());
86 this->WriteData(line);
87 this->WriteData(wide_newline);