1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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 */
34 std::string sourceserv;
36 /* Are we dealing with an FMODE from a user, or from a server? */
37 User* who = this->ServerInstance->FindNick(source);
40 /* FMODE from a user, set sourceserv to the users server name */
41 sourceserv = who->server;
45 /* FMODE from a server, use a fake user to receive mode feedback */
46 who = Utils->ServerUser;
47 sourceserv = source; /* Set sourceserv to the actual source string */
49 std::vector<std::string> modelist;
51 for (unsigned int q = 0; (q < params.size()) && (q < 64); q++)
55 /* The timestamp is in this position.
56 * We don't want to pass that up to the
57 * server->client protocol!
59 TS = atoi(params[q].c_str());
63 /* Everything else is fine to append to the modelist */
64 modelist.push_back(params[q]);
68 /* Extract the TS value of the object, either User or Channel */
69 User* dst = this->ServerInstance->FindNick(params[0]);
79 chan = this->ServerInstance->FindChan(params[0]);
85 /* Oops, channel doesnt exist! */
91 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.");
92 ServerInstance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FMODE with a TS of zero. Total craq. Mode was dropped.", sourceserv.c_str());
96 /* TS is equal or less: Merge the mode changes into ours and pass on.
100 ServerInstance->Modes->Process(modelist, who, (who == Utils->ServerUser));
102 /* HOT POTATO! PASS IT ON! */
103 Utils->DoOneToAllButSender(source,"FMODE",params,sourceserv);
105 /* If the TS is greater than ours, we drop the mode and dont pass it anywhere.