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(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]); CmdBuilder("RESYNC").push(params[0]).Unicast(user); return CMD_FAILURE; } bool apply_modes; if (params.size() > 2) { time_t RemoteTS = ServerCommand::ExtractTS(params[2]); if (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; // 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 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(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]); CmdBuilder("RESYNC").push(params[0]).Unicast(user); return CMD_FAILURE; } bool apply_modes; if (params.size() > 1) { 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)); } else apply_modes = false; chan->ForceJoin(user, apply_modes ? ¶ms[2] : NULL); return CMD_SUCCESS; }