X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fijoin.cpp;h=78e05db93fbb841090e5c18257bcdf9ecd42a2f7;hb=6fe1f4e1136f2ab95a88e68af1894bf6002d03f4;hp=c549149b30aa9095d2306c08a477d0c0e3d8edf2;hpb=d9d9cbe025f94523265daa72de7596467d71f5c8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/ijoin.cpp b/src/modules/m_spanningtree/ijoin.cpp index c549149b3..78e05db93 100644 --- a/src/modules/m_spanningtree/ijoin.cpp +++ b/src/modules/m_spanningtree/ijoin.cpp @@ -32,34 +32,28 @@ CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector& // 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]); - parameterlist p; - p.push_back(params[0]); - Utils->DoOneToOne(ServerInstance->Config->GetSID(), "RESYNC", p, user->server); + CmdBuilder("RESYNC").push(params[0]).Unicast(user); return CMD_FAILURE; } bool apply_modes; - if (params.size() > 1) + if (params.size() > 2) { - time_t RemoteTS = ConvToInt(params[1]); - if (!RemoteTS) - { - ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]); - return CMD_INVALID; - } - + time_t RemoteTS = ServerCommand::ExtractTS(params[2]); 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)); + throw ProtocolException("Attempted to lower TS via IJOIN. LocalTS=" + ConvToStr(chan->age)); + apply_modes = ((params.size() > 3) && (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; } @@ -75,10 +69,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);