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 void TreeSocket::CompatAddModules(std::vector<std::string>& modlist)
32 if (proto_version < 1202)
34 // you MUST have chgident loaded in order to be able to translate FIDENT
35 modlist.push_back("m_chgident.so");
36 for(int i=0; i * sizeof(char*) < sizeof(forge_common_1201); i++)
38 if (ServerInstance->Modules->Find(forge_common_1201[i]))
39 modlist.push_back(forge_common_1201[i]);
44 void TreeSocket::WriteLine(std::string line)
46 if (LinkState == CONNECTED)
50 ServerInstance->Logs->Log("m_spanningtree", DEFAULT, "Sending line without server prefix!");
51 line = ":" + ServerInstance->Config->GetSID() + " " + line;
53 if (proto_version != ProtocolVersion)
55 std::string::size_type a = line.find(' ') + 1;
56 std::string::size_type b = line.find(' ', a);
57 std::string command = line.substr(a, b-a);
58 // now try to find a translation entry
59 // TODO a more efficient lookup method will be needed later
60 if (proto_version < 1202 && command == "FIDENT")
62 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Rewriting FIDENT for 1201-protocol server");
63 line = ":" + ServerInstance->Config->GetSID() + " CHGIDENT " + line.substr(1,a-2) + line.substr(b);
65 else if (proto_version < 1202 && command == "SAVE")
67 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Rewriting SAVE for 1201-protocol server");
68 std::string::size_type c = line.find(' ', b + 1);
69 std::string uid = line.substr(b, c - b);
70 line = ":" + ServerInstance->Config->GetSID() + " SVSNICK " + uid + line.substr(b);
72 else if (proto_version < 1202 && command == "AWAY")
74 if (b != std::string::npos)
76 std::string::size_type c = line.find(' ', b + 1);
83 ServerInstance->Logs->Log("m_spanningtree",DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());