X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fijoin.cpp;h=34bd44a9b2cfd885f13569673972b6d8cbd90655;hb=c8f92d97c2cd92a07bbb76b96a67cd089c7e3407;hp=2f71ffe27be546eb94a018d51c642d5d81805972;hpb=d9d99cd02dadf34bfcc220734ba0c422f0acb3e6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/ijoin.cpp b/src/modules/m_spanningtree/ijoin.cpp index 2f71ffe27..34bd44a9b 100644 --- a/src/modules/m_spanningtree/ijoin.cpp +++ b/src/modules/m_spanningtree/ijoin.cpp @@ -23,19 +23,16 @@ #include "treeserver.h" #include "treesocket.h" -CmdResult CommandIJoin::HandleRemote(const std::vector& params, RemoteUser* user) +CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector& 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; } @@ -43,18 +40,9 @@ CmdResult CommandIJoin::HandleRemote(const std::vector& params, Rem bool apply_modes; if (params.size() > 1) { - time_t RemoteTS = ConvToInt(params[1]); - if (!RemoteTS) - { - ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]); - return CMD_INVALID; - } - + time_t RemoteTS = ServerCommand::ExtractTS(params[1]); 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)); - return CMD_INVALID; - } + throw ProtocolException("Attempted to lower TS via IJOIN. LocalTS=" + ConvToStr(chan->age)); apply_modes = ((params.size() > 2) && (RemoteTS == chan->age)); } else @@ -64,30 +52,21 @@ CmdResult CommandIJoin::HandleRemote(const std::vector& params, Rem return CMD_SUCCESS; } -CmdResult CommandResync::HandleServer(const std::vector& params, FakeUser* user) +CmdResult CommandResync::HandleServer(TreeServer* server, std::vector& 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) - { - ServerInstance->Logs->Log("m_spanningtree", LOG_DEFAULT, "Received RESYNC with a source that is not directly connected: " + user->uuid); - return CMD_INVALID; - } + if (!server->IsLocal()) + throw ProtocolException("RESYNC from a server that is not directly connected"); // Send all known information about the channel - socket->SyncChannel(chan); + server->GetSocket()->SyncChannel(chan); return CMD_SUCCESS; }