2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2012-2013 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "treeserver.h"
24 #include "treesocket.h"
26 CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>& params)
28 Channel* chan = ServerInstance->FindChan(params[0]);
31 // Desync detected, recover
32 // Ignore the join and send RESYNC, this will result in the remote server sending all channel data to us
33 ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]);
35 CmdBuilder("RESYNC").push(params[0]).Unicast(user);
41 if (params.size() > 1)
43 time_t RemoteTS = ConvToInt(params[1]);
46 ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]);
50 if (RemoteTS < chan->age)
52 ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Attempted to lower TS via IJOIN. Channel=" + params[0] + " RemoteTS=" + params[1] + " LocalTS=" + ConvToStr(chan->age));
55 apply_modes = ((params.size() > 2) && (RemoteTS == chan->age));
60 chan->ForceJoin(user, apply_modes ? ¶ms[2] : NULL);
64 CmdResult CommandResync::HandleServer(TreeServer* server, std::vector<std::string>& params)
66 ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Resyncing " + params[0]);
67 Channel* chan = ServerInstance->FindChan(params[0]);
70 // This can happen for a number of reasons, safe to ignore
71 ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Channel does not exist");
75 if (!server->IsLocal())
77 ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Received RESYNC with a source that is not directly connected: " + server->GetID());
81 // Send all known information about the channel
82 server->GetSocket()->SyncChannel(chan);