1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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 * ---------------------------------------------------
19 #include "treesocket.h"
20 #include "treeserver.h"
21 #include "resolvers.h"
23 CmdResult CommandUID::Handle(const parameterlist ¶ms, User* serversrc)
25 SpanningTreeUtilities* Utils = ((ModuleSpanningTree*)(Module*)creator)->Utils;
26 /** Do we have enough parameters:
27 * 0 1 2 3 4 5 6 7 8 9 (n-1)
28 * UID uuid age nick host dhost ident ip.string signon +modes (modepara) :gecos
30 if (params.size() < 10)
33 time_t age_t = ConvToInt(params[1]);
34 time_t signon = ConvToInt(params[7]);
36 std::string modestr(params[8]);
38 TreeServer* remoteserver = Utils->FindServer(serversrc->server);
42 /* Check parameters for validity before introducing the client, discovered by dmb */
47 if (modestr[0] != '+')
49 TreeSocket* sock = remoteserver->GetRoute()->GetSocket();
51 /* check for collision */
52 user_hash::iterator iter = ServerInstance->Users->clientlist->find(params[2]);
54 if (iter != ServerInstance->Users->clientlist->end())
59 int collide = sock->DoCollision(iter->second, age_t, params[5], modestr, params[0]);
60 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"*** Collision on %s, collide=%d", params[2].c_str(), collide);
64 /* remote client changed, make sure we change their nick for the hash too */
65 const_cast<parameterlist&>(params)[2] = params[0];
69 /* IMPORTANT NOTE: For remote users, we pass the UUID in the constructor. This automatically
70 * sets it up in the UUID hash for us.
75 _new = new RemoteUser(params[0], remoteserver->GetName());
81 (*(ServerInstance->Users->clientlist))[params[2]] = _new;
82 _new->nick = params[2];
83 _new->host = params[3];
84 _new->dhost = params[4];
85 _new->ident = params[5];
86 _new->fullname = params[params.size() - 1];
87 _new->registered = REG_ALL;
88 _new->signon = signon;
91 /* we need to remove the + from the modestring, so we can do our stuff */
92 std::string::size_type pos_after_plus = modestr.find_first_not_of('+');
93 if (pos_after_plus != std::string::npos)
94 modestr = modestr.substr(pos_after_plus);
96 unsigned int paramptr = 9;
97 for (std::string::iterator v = modestr.begin(); v != modestr.end(); v++)
102 /* For each mode thats set, increase counter */
103 ModeHandler* mh = ServerInstance->Modes->FindMode(*v, MODETYPE_USER);
107 if (mh->GetNumParams(true))
109 if (paramptr >= params.size() - 1)
111 std::string mp = params[paramptr++];
113 * All modes are assumed to succeed here as they are being set by a remote server.
114 * Modes CANNOT FAIL here. If they DO fail, then the failure is ignored. This is important
115 * to note as all but one modules currently cannot ever fail in this situation, except for
116 * m_servprotect which specifically works this way to prevent the mode being set ANYWHERE
117 * but here, at client introduction. You may safely assume this behaviour is standard and
118 * will not change in future versions if you want to make use of this protective behaviour
121 mh->OnModeChange(_new, _new, NULL, mp, true);
124 mh->OnModeChange(_new, _new, NULL, empty, true);
125 _new->SetMode(*v, true);
129 /* now we've done with modes processing, put the + back for remote servers */
130 if (modestr[0] != '+')
131 modestr = "+" + modestr;
133 _new->SetClientIP(params[6].c_str());
135 ServerInstance->Users->AddGlobalClone(_new);
136 remoteserver->SetUserCount(1); // increment by 1
140 if ((Utils->quiet_bursts && remoteserver->bursting) || ServerInstance->SilentULine(_new->server))
144 ServerInstance->SNO->WriteToSnoMask('C',"Client connecting at %s: %s!%s@%s [%s] [%s]", _new->server.c_str(), _new->nick.c_str(), _new->ident.c_str(), _new->host.c_str(), _new->GetIPString(), _new->fullname.c_str());
146 FOREACH_MOD(I_OnPostConnect,OnPostConnect(_new));
151 CmdResult CommandFHost::Handle(const parameterlist ¶ms, User* src)
153 if (params.size() < 1)
157 src->ChangeDisplayedHost(params[0].c_str());
161 CmdResult CommandFIdent::Handle(const parameterlist ¶ms, User* src)
163 if (params.size() < 1)
167 src->ChangeIdent(params[0].c_str());
171 CmdResult CommandFName::Handle(const parameterlist ¶ms, User* src)
173 if (params.size() < 1)
177 src->ChangeName(params[0].c_str());