X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fijoin.cpp;h=85838cc7fad65edf2242569820ea480e7401e79e;hb=a9989ac3978bd6e1f9e915aeed399d9db327c235;hp=a579848c8321061add6f900862e7eed061ea5e82;hpb=e244cb2c63b1ac1d85bdbb4691f7b1bd940ae804;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/ijoin.cpp b/src/modules/m_spanningtree/ijoin.cpp index a579848c8..85838cc7f 100644 --- a/src/modules/m_spanningtree/ijoin.cpp +++ b/src/modules/m_spanningtree/ijoin.cpp @@ -23,14 +23,14 @@ #include "treeserver.h" #include "treesocket.h" -CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector& params) +CmdResult CommandIJoin::HandleRemote(RemoteUser* user, Params& 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(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]); + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received IJOIN for nonexistent channel: " + params[0]); CmdBuilder("RESYNC").push(params[0]).Unicast(user); @@ -38,30 +38,24 @@ CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector& } bool apply_modes; - if (params.size() > 1) + if (params.size() > 3) { - time_t RemoteTS = ConvToInt(params[1]); - if (!RemoteTS) - { - ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]); - return CMD_INVALID; - } - - if (RemoteTS < 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)); + time_t RemoteTS = ServerCommand::ExtractTS(params[2]); + apply_modes = (RemoteTS <= chan->age); } else apply_modes = false; - chan->ForceJoin(user, apply_modes ? ¶ms[2] : NULL); + // Join the user and set the membership id to what they sent + Membership* memb = chan->ForceJoin(user, apply_modes ? ¶ms[3] : NULL); + if (!memb) + return CMD_FAILURE; + + memb->id = Membership::IdFromString(params[1]); return CMD_SUCCESS; } -CmdResult CommandResync::HandleServer(TreeServer* server, std::vector& params) +CmdResult CommandResync::HandleServer(TreeServer* server, CommandBase::Params& params) { ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Resyncing " + params[0]); Channel* chan = ServerInstance->FindChan(params[0]); @@ -73,10 +67,7 @@ CmdResult CommandResync::HandleServer(TreeServer* server, std::vectorIsLocal()) - { - ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Received RESYNC with a source that is not directly connected: " + server->GetID()); - return CMD_INVALID; - } + throw ProtocolException("RESYNC from a server that is not directly connected"); // Send all known information about the channel server->GetSocket()->SyncChannel(chan);