]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/compat.cpp
m_spanningtree Replace #defines with references in DoCollision()
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / compat.cpp
index 9d3c52bd250e009fc94506199f330625ba4335e8..0f55793f1d722fde5ded68d82b736c94f6c453df 100644 (file)
@@ -244,6 +244,20 @@ void TreeSocket::WriteLine(const std::string& original_line)
                                                line.erase(d, e-d);
                                        }
                                }
+                               else if (command == "SINFO")
+                               {
+                                       // :22D SINFO version :InspIRCd-2.2
+                                       //     A     B       C
+                                       std::string::size_type c = line.find(' ', b + 1);
+                                       if (c == std::string::npos)
+                                               return;
+
+                                       // Only translating SINFO version, discard everything else
+                                       if (line.compare(b, 9, " version ", 9))
+                                               return;
+
+                                       line = line.substr(0, 5) + "VERSION" + line.substr(c);
+                               }
                        }
                        ServerInstance->Logs->Log(MODNAME, LOG_RAWIO, "S[%d] O %s", this->GetFd(), line.c_str());
                        this->WriteData(line);
@@ -379,6 +393,45 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, std:
                // Insert channel timestamp after the channel name; the 3rd parameter, if there, is the invite expiration time
                return InsertCurrentChannelTS(params, 1, 2);
        }
+       else if (cmd == "VERSION")
+       {
+               // :20D VERSION :InspIRCd-2.0
+               // change to
+               // :20D SINFO version :InspIRCd-2.0
+               cmd = "SINFO";
+               params.insert(params.begin(), "version");
+       }
+       else if (cmd == "JOIN")
+       {
+               // 2.0 allows and forwards legacy JOINs but we don't, so translate them to FJOINs before processing
+               if ((params.size() != 1) || (IS_SERVER(who)))
+                       return false; // Huh?
+
+               cmd = "FJOIN";
+               Channel* chan = ServerInstance->FindChan(params[0]);
+               params.push_back(ConvToStr(chan ? chan->age : ServerInstance->Time()));
+               params.push_back("+");
+               params.push_back(",");
+               params.back().append(who->uuid);
+               who = TreeServer::Get(who)->ServerUser;
+       }
+       else if ((cmd == "FMODE") && (params.size() >= 2))
+       {
+               // Translate user mode changes with timestamp to MODE
+               if (params[0][0] != '#')
+               {
+                       User* user = ServerInstance->FindUUID(params[0]);
+                       if (!user)
+                               return false;
+
+                       // Emulate the old nonsensical behavior
+                       if (user->age < ServerCommand::ExtractTS(params[1]))
+                               return false;
+
+                       cmd = "MODE";
+                       params.erase(params.begin()+1);
+               }
+       }
 
        return true; // Passthru
 }