1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
15 #include "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
20 #include "transport.h"
22 #include "socketengine.h"
24 #include "m_spanningtree/main.h"
25 #include "m_spanningtree/utils.h"
26 #include "m_spanningtree/treeserver.h"
27 #include "m_spanningtree/link.h"
28 #include "m_spanningtree/treesocket.h"
29 #include "m_spanningtree/resolvers.h"
30 #include "m_spanningtree/handshaketimer.h"
32 /* $ModDep: m_spanningtree/timesynctimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h */
34 /** FMODE command - server mode with timestamp checks */
35 bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> ¶ms)
37 /* Chances are this is a 1.0 FMODE without TS */
38 if (params.size() < 3)
40 /* No modes were in the command, probably a channel with no modes set on it */
45 std::string sourceserv;
46 /* Are we dealing with an FMODE from a user, or from a server? */
47 User* who = this->Instance->FindNick(source);
50 /* FMODE from a user, set sourceserv to the users server name */
51 sourceserv = who->server;
55 /* FMODE from a server, use a fake user to receive mode feedback */
56 who = this->Instance->FakeClient;
57 smode = true; /* Setting this flag tells us we should free the User later */
58 sourceserv = source; /* Set sourceserv to the actual source string */
60 const char* modelist[64];
63 memset(&modelist,0,sizeof(modelist));
64 for (unsigned int q = 0; (q < params.size()) && (q < 64); q++)
68 /* The timestamp is in this position.
69 * We don't want to pass that up to the
70 * server->client protocol!
72 TS = atoi(params[q].c_str());
76 /* Everything else is fine to append to the modelist */
77 modelist[n++] = params[q].c_str();
81 /* Extract the TS value of the object, either User or Channel */
82 User* dst = this->Instance->FindNick(params[0]);
91 chan = this->Instance->FindChan(params[0]);
97 /* Oops, channel doesnt exist! */
103 Instance->Log(DEFAULT,"*** BUG? *** TS of 0 sent to FMODE. Are some services authors smoking craq, or is it 1970 again?. Dropped.");
104 Instance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending FMODE with a TS of zero. Total craq. Mode was dropped.", sourceserv.c_str());
108 /* TS is equal or less: Merge the mode changes into ours and pass on.
112 if ((TS < ourTS) && (!dst))
113 Instance->Log(DEFAULT,"*** BUG *** Channel TS sent in FMODE to %s is %lu which is not equal to %lu!", params[0].c_str(), TS, ourTS);
117 this->Instance->SendMode(modelist, n, who);
121 this->Instance->CallCommandHandler("MODE", modelist, n, who);
123 /* HOT POTATO! PASS IT ON! */
124 Utils->DoOneToAllButSender(source,"FMODE",params,sourceserv);
126 /* If the TS is greater than ours, we drop the mode and dont pass it anywhere.