1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 #include "m_spanningtree/treesocket.h"
18 #include "m_spanningtree/treeserver.h"
19 #include "m_spanningtree/utils.h"
21 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
24 /** FMODE command - server mode with timestamp checks */
25 bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> ¶ms)
27 /* Chances are this is a 1.0 FMODE without TS */
28 if (params.size() < 3)
30 /* No modes were in the command, probably a channel with no modes set on it */
35 std::string sourceserv;
37 /* Are we dealing with an FMODE from a user, or from a server? */
38 User* who = this->ServerInstance->FindNick(source);
41 /* FMODE from a user, set sourceserv to the users server name */
42 sourceserv = who->server;
46 /* FMODE from a server, use a fake user to receive mode feedback */
47 who = this->ServerInstance->FakeClient;
48 smode = true; /* Setting this flag tells us it is a server mode*/
49 sourceserv = source; /* Set sourceserv to the actual source string */
51 std::vector<std::string> modelist;
53 for (unsigned int q = 0; (q < params.size()) && (q < 64); q++)
57 /* The timestamp is in this position.
58 * We don't want to pass that up to the
59 * server->client protocol!
61 TS = atoi(params[q].c_str());
65 /* Everything else is fine to append to the modelist */
66 modelist.push_back(params[q]);
70 /* Extract the TS value of the object, either User or Channel */
71 User* dst = this->ServerInstance->FindNick(params[0]);
81 chan = this->ServerInstance->FindChan(params[0]);
87 /* Oops, channel doesnt exist! */
93 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG? *** TS of 0 sent to FMODE. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
94 ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FMODE with a TS of zero. Total craq. Mode was dropped.", sourceserv.c_str());
98 /* TS is equal or less: Merge the mode changes into ours and pass on.
104 this->ServerInstance->SendMode(modelist, who);
108 this->ServerInstance->CallCommandHandler("MODE", modelist, who);
110 /* HOT POTATO! PASS IT ON! */
111 Utils->DoOneToAllButSender(source,"FMODE",params,sourceserv);
113 /* If the TS is greater than ours, we drop the mode and dont pass it anywhere.