/* * InspIRCd -- Internet Relay Chat Daemon * * Copyright (C) 2012-2013 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, version 2. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "inspircd.h" #include "commands.h" #include "utils.h" #include "treeserver.h" #include "treesocket.h" 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(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) throw ProtocolException("Attempted to lower TS via IJOIN. LocalTS=" + ConvToStr(chan->age)); apply_modes = ((params.size() > 2) && (RemoteTS == chan->age)); } else apply_modes = false; chan->ForceJoin(user, apply_modes ? ¶ms[2] : NULL); return CMD_SUCCESS; } CmdResult CommandResync::HandleServer(TreeServer* server, std::vector& params) { 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(MODNAME, LOG_DEBUG, "Channel does not exist"); return CMD_FAILURE; } if (!server->IsLocal()) throw ProtocolException("RESYNC from a server that is not directly connected"); // Send all known information about the channel server->GetSocket()->SyncChannel(chan); return CMD_SUCCESS; }