]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/ijoin.cpp
m_operjoin Remove duplicated code
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / ijoin.cpp
index 2f71ffe27be546eb94a018d51c642d5d81805972..a579848c8321061add6f900862e7eed061ea5e82 100644 (file)
 #include "treeserver.h"
 #include "treesocket.h"
 
-CmdResult CommandIJoin::HandleRemote(const std::vector<std::string>& params, RemoteUser* user)
+CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>& params)
 {
        Channel* chan = ServerInstance->FindChan(params[0]);
        if (!chan)
        {
                // Desync detected, recover
                // Ignore the join and send RESYNC, this will result in the remote server sending all channel data to us
-               ServerInstance->Logs->Log("m_spanningtree", LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]);
+               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]);
 
-               parameterlist p;
-               p.push_back(params[0]);
-               SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils;
-               Utils->DoOneToOne(ServerInstance->Config->GetSID(), "RESYNC", p, user->server);
+               CmdBuilder("RESYNC").push(params[0]).Unicast(user);
 
                return CMD_FAILURE;
        }
@@ -46,13 +43,13 @@ CmdResult CommandIJoin::HandleRemote(const std::vector<std::string>& params, Rem
                time_t RemoteTS = ConvToInt(params[1]);
                if (!RemoteTS)
                {
-                       ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]);
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]);
                        return CMD_INVALID;
                }
 
                if (RemoteTS < chan->age)
                {
-                       ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Attempted to lower TS via IJOIN. Channel=" + params[0] + " RemoteTS=" + params[1] + " LocalTS=" + ConvToStr(chan->age));
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Attempted to lower TS via IJOIN. Channel=" + params[0] + " RemoteTS=" + params[1] + " LocalTS=" + ConvToStr(chan->age));
                        return CMD_INVALID;
                }
                apply_modes = ((params.size() > 2) && (RemoteTS == chan->age));
@@ -64,30 +61,24 @@ CmdResult CommandIJoin::HandleRemote(const std::vector<std::string>& params, Rem
        return CMD_SUCCESS;
 }
 
-CmdResult CommandResync::HandleServer(const std::vector<std::string>& params, FakeUser* user)
+CmdResult CommandResync::HandleServer(TreeServer* server, std::vector<std::string>& params)
 {
-       ServerInstance->Logs->Log("m_spanningtree", LOG_DEBUG, "Resyncing " + params[0]);
+       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Resyncing " + params[0]);
        Channel* chan = ServerInstance->FindChan(params[0]);
        if (!chan)
        {
                // This can happen for a number of reasons, safe to ignore
-               ServerInstance->Logs->Log("m_spanningtree", LOG_DEBUG, "Channel does not exist");
+               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Channel does not exist");
                return CMD_FAILURE;
        }
 
-       SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils;
-       TreeServer* server = Utils->FindServer(user->server);
-       if (!server)
-               return CMD_FAILURE;
-
-       TreeSocket* socket = server->GetSocket();
-       if (!socket)
+       if (!server->IsLocal())
        {
-               ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Received RESYNC with a source that is not directly connected: " + user->uuid);
+               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Received RESYNC with a source that is not directly connected: " + server->GetID());
                return CMD_INVALID;
        }
 
        // Send all known information about the channel
-       socket->SyncChannel(chan);
+       server->GetSocket()->SyncChannel(chan);
        return CMD_SUCCESS;
 }