]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/compat.cpp
Fix Windows build and a few more problems
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / compat.cpp
index ad3a5fee8d63d874b5d0baa11193a2a38f0b6859..0fc837beb939cec4c8794ed71ad1d508a79bea77 100644 (file)
@@ -30,7 +30,7 @@ void TreeSocket::WriteLine(std::string line)
        {
                if (line[0] != ':')
                {
-                       ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Sending line without server prefix!");
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Sending line without server prefix!");
                        line = ":" + ServerInstance->Config->GetSID() + " " + line;
                }
                if (proto_version != ProtocolVersion)
@@ -93,7 +93,7 @@ void TreeSocket::WriteLine(std::string line)
                                        return;
                                else if (command == "METADATA")
                                {
-                                       // Drop TS for channel METADATA
+                                       // Drop TS for channel METADATA, translate METADATA operquit into an OPERQUIT command
                                        // :sid METADATA #target TS extname ...
                                        //     A        B       C  D
                                        if (b == std::string::npos)
@@ -103,15 +103,20 @@ void TreeSocket::WriteLine(std::string line)
                                        if (c == std::string::npos)
                                                return;
 
+                                       std::string::size_type d = line.find(' ', c + 1);
+                                       if (d == std::string::npos)
+                                               return;
+
                                        if (line[b + 1] == '#')
                                        {
                                                // We're sending channel metadata
-                                               std::string::size_type d = line.find(' ', c + 1);
-                                               if (d == std::string::npos)
-                                                       return;
-
                                                line.erase(c, d-c);
                                        }
+                                       else if (line.substr(c, d-c) == " operquit")
+                                       {
+                                               // ":22D METADATA 22DAAAAAX operquit :message" -> ":22DAAAAAX OPERQUIT :message"
+                                               line = ":" + line.substr(b+1, c-b) + "OPERQUIT" + line.substr(d);
+                                       }
                                }
                                else if (command == "FTOPIC")
                                {
@@ -157,7 +162,7 @@ void TreeSocket::WriteLine(std::string line)
                }
        }
 
-       ServerInstance->Logs->Log("m_spanningtree", LOG_RAWIO, "S[%d] O %s", this->GetFd(), line.c_str());
+       ServerInstance->Logs->Log(MODNAME, LOG_RAWIO, "S[%d] O %s", this->GetFd(), line.c_str());
        this->WriteData(line);
        this->WriteData(newline);
 }
@@ -212,7 +217,7 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, std:
                        if (!server)
                        {
                                // We've no idea what this is, log and stop processing
-                               ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Received a " + cmd + " with an unknown target: \"" + params[0] + "\", command dropped");
+                               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Received a " + cmd + " with an unknown target: \"" + params[0] + "\", command dropped");
                                return false;
                        }
 
@@ -246,6 +251,17 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, std:
        {
                cmd = "MODE";
        }
+       else if (cmd == "OPERQUIT")
+       {
+               // Translate OPERQUIT into METADATA
+               if (params.empty())
+                       return false;
+
+               cmd = "METADATA";
+               params.insert(params.begin(), who->uuid);
+               params.insert(params.begin()+1, "operquit");
+               who = MyRoot->ServerUser;
+       }
 
        return true; // Passthru
 }