1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 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"
21 #include "socketengine.h"
23 #include "m_spanningtree/main.h"
24 #include "m_spanningtree/utils.h"
25 #include "m_spanningtree/treeserver.h"
26 #include "m_spanningtree/link.h"
27 #include "m_spanningtree/treesocket.h"
28 #include "m_spanningtree/resolvers.h"
29 #include "m_spanningtree/handshaketimer.h"
31 /* $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 */
33 static std::map<std::string, std::string> warned; /* Server names that have had protocol violation warnings displayed for them */
35 int TreeSocket::WriteLine(std::string line)
37 Instance->Log(DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());
39 return this->Write(line);
43 /* Handle ERROR command */
44 bool TreeSocket::Error(std::deque<std::string> ¶ms)
46 if (params.size() < 1)
48 this->Instance->SNO->WriteToSnoMask('l',"ERROR from %s: %s",(!InboundServerName.empty() ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
49 /* we will return false to cause the socket to close. */
53 bool TreeSocket::Modules(const std::string &prefix, std::deque<std::string> ¶ms)
58 if (!this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
60 /* Pass it on, not for us */
61 Utils->DoOneToOne(prefix, "MODULES", params, params[0]);
66 std::deque<std::string> par;
67 par.push_back(prefix);
70 User* source = this->Instance->FindNick(prefix);
74 std::vector<std::string> module_names = Instance->Modules->GetAllModuleNames(0);
76 for (unsigned int i = 0; i < module_names.size(); i++)
78 Module* m = Instance->Modules->Find(module_names[i]);
79 Version V = m->GetVersion();
80 char modulename[MAXBUF];
81 char flagstate[MAXBUF];
83 if (V.Flags & VF_STATIC)
84 strlcat(flagstate,", static",MAXBUF);
85 if (V.Flags & VF_VENDOR)
86 strlcat(flagstate,", vendor",MAXBUF);
87 if (V.Flags & VF_COMMON)
88 strlcat(flagstate,", common",MAXBUF);
89 if (V.Flags & VF_SERVICEPROVIDER)
90 strlcat(flagstate,", service provider",MAXBUF);
92 strcpy(flagstate," <no flags>");
93 strlcpy(modulename,module_names[i].c_str(),256);
96 snprintf(strbuf, MAXBUF, "::%s 900 %s :0x%08lx %d.%d.%d.%d %s (%s)",Instance->Config->ServerName,source->nick,(unsigned long)m,
97 V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
101 snprintf(strbuf, MAXBUF, "::%s 900 %s :%s",Instance->Config->ServerName,source->nick,ServerConfig::CleanFilename(modulename));
104 Utils->DoOneToOne(Instance->Config->GetSID(), "PUSH", par, source->server);
106 snprintf(strbuf, MAXBUF, "::%s 901 %s :End of MODULES list", Instance->Config->ServerName, source->nick);
108 Utils->DoOneToOne(Instance->Config->GetSID(), "PUSH", par, source->server);
112 /** remote MOTD. leet, huh? */
113 bool TreeSocket::Motd(const std::string &prefix, std::deque<std::string> ¶ms)
115 if (params.size() > 0)
117 if (this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
119 /* It's for our server */
121 User* source = this->Instance->FindNick(prefix);
125 std::deque<std::string> par;
126 par.push_back(prefix);
129 if (!Instance->Config->MOTD.size())
131 par[1] = std::string("::")+Instance->Config->ServerName+" 422 "+source->nick+" :Message of the day file is missing.";
132 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
136 par[1] = std::string("::")+Instance->Config->ServerName+" 375 "+source->nick+" :"+Instance->Config->ServerName+" message of the day";
137 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
139 for (unsigned int i = 0; i < Instance->Config->MOTD.size(); i++)
141 par[1] = std::string("::")+Instance->Config->ServerName+" 372 "+source->nick+" :- "+Instance->Config->MOTD[i];
142 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
145 par[1] = std::string("::")+Instance->Config->ServerName+" 376 "+source->nick+" :End of message of the day.";
146 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
152 User* source = this->Instance->FindNick(prefix);
154 Utils->DoOneToOne(prefix, "MOTD", params, params[0]);
160 /** remote ADMIN. leet, huh? */
161 bool TreeSocket::Admin(const std::string &prefix, std::deque<std::string> ¶ms)
163 if (params.size() > 0)
165 if (this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
167 /* It's for our server */
169 User* source = this->Instance->FindNick(prefix);
172 std::deque<std::string> par;
173 par.push_back(prefix);
175 par[1] = std::string("::")+Instance->Config->ServerName+" 256 "+source->nick+" :Administrative info for "+Instance->Config->ServerName;
176 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
177 par[1] = std::string("::")+Instance->Config->ServerName+" 257 "+source->nick+" :Name - "+Instance->Config->AdminName;
178 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
179 par[1] = std::string("::")+Instance->Config->ServerName+" 258 "+source->nick+" :Nickname - "+Instance->Config->AdminNick;
180 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
181 par[1] = std::string("::")+Instance->Config->ServerName+" 258 "+source->nick+" :E-Mail - "+Instance->Config->AdminEmail;
182 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
188 User* source = this->Instance->FindNick(prefix);
190 Utils->DoOneToOne(prefix, "ADMIN", params, params[0]);
196 bool TreeSocket::Stats(const std::string &prefix, std::deque<std::string> ¶ms)
198 /* Get the reply to a STATS query if it matches this servername,
199 * and send it back as a load of PUSH queries
201 if (params.size() > 1)
203 if (this->Instance->MatchText(this->Instance->Config->ServerName, params[1]))
205 /* It's for our server */
207 User* source = this->Instance->FindNick(prefix);
210 std::deque<std::string> par;
211 par.push_back(prefix);
213 DoStats(this->Instance, *(params[0].c_str()), source, results);
214 for (size_t i = 0; i < results.size(); i++)
216 par[1] = "::" + results[i];
217 Utils->DoOneToOne(this->Instance->Config->GetSID(), "PUSH",par, source->server);
224 User* source = this->Instance->FindNick(prefix);
226 Utils->DoOneToOne(source->uuid, "STATS", params, params[1]);
233 /** Because the core won't let users or even SERVERS set +o,
234 * we use the OPERTYPE command to do this.
236 bool TreeSocket::OperType(const std::string &prefix, std::deque<std::string> ¶ms)
238 if (params.size() != 1)
240 std::string opertype = params[0];
241 User* u = this->Instance->FindNick(prefix);
244 if (!u->IsModeSet('o'))
245 this->Instance->all_opers.push_back(u);
246 u->modes[UM_OPERATOR] = 1;
247 strlcpy(u->oper,opertype.c_str(),NICKMAX-1);
248 Utils->DoOneToAllButSender(u->nick,"OPERTYPE",params,u->server);
250 TreeServer* remoteserver = Utils->FindServer(u->server);
253 if (this->Utils->quiet_bursts)
256 * If quiet bursts are enabled, and server is bursting or silent uline (i.e. services),
257 * then do nothing. -- w00t
261 Utils->FindRemoteBurstServer(remoteserver) ||
262 this->Instance->SilentULine(this->Instance->FindServerNamePtr(u->server))
270 this->Instance->SNO->WriteToSnoMask('o',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server, u->nick,u->ident,u->host,irc::Spacify(opertype.c_str()));
275 /** Because Andy insists that services-compatible servers must
276 * implement SVSNICK and SVSJOIN, that's exactly what we do :p
278 bool TreeSocket::ForceNick(const std::string &prefix, std::deque<std::string> ¶ms)
280 if (params.size() < 3)
283 User* u = this->Instance->FindNick(params[0]);
287 Utils->DoOneToAllButSender(prefix,"SVSNICK",params,prefix);
291 std::deque<std::string> par;
292 par.push_back(params[1]);
294 if (!u->ForceNickChange(params[1].c_str()))
297 if (!u->ForceNickChange(u->uuid))
299 User::QuitUser(this->Instance, u, "Nickname collision");
304 u->age = atoi(params[2].c_str());
311 bool TreeSocket::OperQuit(const std::string &prefix, std::deque<std::string> ¶ms)
313 if (params.size() < 1)
316 User* u = this->Instance->FindNick(prefix);
320 u->SetOperQuit(params[0]);
321 params[0] = ":" + params[0];
322 Utils->DoOneToAllButSender(prefix,"OPERQUIT",params,prefix);
327 bool TreeSocket::ServiceJoin(const std::string &prefix, std::deque<std::string> ¶ms)
329 if (params.size() < 2)
332 if (!this->Instance->IsChannel(params[1].c_str()))
335 User* u = this->Instance->FindNick(params[0]);
339 /* only join if it's local, otherwise just pass it on! */
341 Channel::JoinUser(this->Instance, u, params[1].c_str(), false, "", false, Instance->Time());
342 Utils->DoOneToAllButSender(prefix,"SVSJOIN",params,prefix);
347 bool TreeSocket::ServicePart(const std::string &prefix, std::deque<std::string> ¶ms)
349 if (params.size() < 2)
352 if (!this->Instance->IsChannel(params[1].c_str()))
355 User* u = this->Instance->FindNick(params[0]);
356 Channel* c = this->Instance->FindChan(params[1]);
360 /* only part if it's local, otherwise just pass it on! */
362 if (!c->PartUser(u, "Services forced part"))
364 Utils->DoOneToAllButSender(prefix,"SVSPART",params,prefix);
370 bool TreeSocket::RemoteRehash(const std::string &prefix, std::deque<std::string> ¶ms)
372 if (params.size() < 1)
375 std::string servermask = params[0];
377 if (this->Instance->MatchText(this->Instance->Config->ServerName,servermask))
379 this->Instance->SNO->WriteToSnoMask('l',"Remote rehash initiated by \002"+prefix+"\002.");
380 this->Instance->RehashServer();
381 Utils->ReadConfiguration(true);
382 InitializeDisabledCommands(Instance->Config->DisabledCommands, Instance);
384 Utils->DoOneToAllButSender(prefix,"REHASH",params,prefix);
388 bool TreeSocket::RemoteKill(const std::string &prefix, std::deque<std::string> ¶ms)
390 if (params.size() != 2)
393 User* who = this->Instance->FindNick(params[0]);
397 /* Prepend kill source, if we don't have one */
398 if (*(params[1].c_str()) != '[')
400 params[1] = "[" + prefix + "] Killed (" + params[1] +")";
402 std::string reason = params[1];
403 params[1] = ":" + params[1];
404 Utils->DoOneToAllButSender(prefix,"KILL",params,prefix);
405 // NOTE: This is safe with kill hiding on, as RemoteKill is only reached if we have a server prefix.
406 // in short this is not executed for USERS.
407 who->Write(":%s KILL %s :%s (%s)", prefix.c_str(), who->nick, prefix.c_str(), reason.c_str());
408 User::QuitUser(this->Instance,who,reason);
413 bool TreeSocket::LocalPong(const std::string &prefix, std::deque<std::string> ¶ms)
415 if (params.size() < 1)
418 if (params.size() == 1)
420 TreeServer* ServerSource = Utils->FindServer(prefix);
423 ServerSource->SetPingFlag();
425 gettimeofday(&t, NULL);
426 long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000);
427 ServerSource->rtt = ts - ServerSource->LastPingMsec;
432 std::string forwardto = params[1];
433 if (forwardto == Instance->Config->GetSID() || forwardto == Instance->Config->ServerName)
436 * this is a PONG for us
437 * if the prefix is a user, check theyre local, and if they are,
438 * dump the PONG reply back to their fd. If its a server, do nowt.
439 * Services might want to send these s->s, but we dont need to yet.
441 User* u = this->Instance->FindNick(prefix);
444 u->WriteServ("PONG %s %s",params[0].c_str(),params[1].c_str());
449 // not for us, pass it on :)
450 Utils->DoOneToOne(prefix,"PONG",params,forwardto);
457 bool TreeSocket::MetaData(const std::string &prefix, std::deque<std::string> ¶ms)
459 if (params.size() < 2)
461 else if (params.size() < 3)
462 params.push_back("");
463 TreeServer* ServerSource = Utils->FindServer(prefix);
466 Utils->SetRemoteBursting(ServerSource, false);
468 if (params[0] == "*")
470 FOREACH_MOD_I(this->Instance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_OTHER,NULL,params[1],params[2]));
472 else if (*(params[0].c_str()) == '#')
474 Channel* c = this->Instance->FindChan(params[0]);
477 FOREACH_MOD_I(this->Instance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_CHANNEL,c,params[1],params[2]));
480 else if (*(params[0].c_str()) != '#')
482 User* u = this->Instance->FindNick(params[0]);
485 FOREACH_MOD_I(this->Instance,I_OnDecodeMetaData,OnDecodeMetaData(TYPE_USER,u,params[1],params[2]));
490 params[2] = ":" + params[2];
491 Utils->DoOneToAllButSender(prefix,"METADATA",params,prefix);
495 bool TreeSocket::ServerVersion(const std::string &prefix, std::deque<std::string> ¶ms)
497 if (params.size() < 1)
500 TreeServer* ServerSource = Utils->FindServer(prefix);
504 ServerSource->SetVersion(params[0]);
506 params[0] = ":" + params[0];
507 Utils->DoOneToAllButSender(prefix,"VERSION",params,prefix);
511 bool TreeSocket::ChangeHost(const std::string &prefix, std::deque<std::string> ¶ms)
513 if (params.size() < 1)
515 User* u = this->Instance->FindNick(prefix);
519 u->ChangeDisplayedHost(params[0].c_str());
520 Utils->DoOneToAllButSender(prefix,"FHOST",params,u->server);
525 bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> ¶ms)
527 if (params.size() < 6)
529 this->Instance->SNO->WriteToSnoMask('x',"%s sent me a malformed ADDLINE of type %s.",prefix.c_str(),params[0].c_str());
533 XLineFactory* xlf = Instance->XLines->GetFactory(params[0]);
537 this->Instance->SNO->WriteToSnoMask('x',"%s sent me an unknown ADDLINE type (%s).",prefix.c_str(),params[0].c_str());
541 XLine* xl = xlf->Generate(Instance->Time(), atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
542 xl->SetCreateTime(atoi(params[3].c_str()));
543 if (Instance->XLines->AddLine(xl,NULL))
547 this->Instance->SNO->WriteToSnoMask('x',"%s added %s%s on %s to expire on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
548 params[1].c_str(),Instance->TimeString(xl->expiry).c_str(),params[5].c_str());
552 this->Instance->SNO->WriteToSnoMask('x',"%s added permanent %s%s on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
553 params[1].c_str(),params[5].c_str());
555 params[5] = ":" + params[5];
557 User* u = Instance->FindNick(prefix);
558 Utils->DoOneToAllButSender(prefix, "ADDLINE", params, u ? u->server : prefix);
565 Instance->XLines->ApplyLines();
571 bool TreeSocket::DelLine(const std::string &prefix, std::deque<std::string> ¶ms)
573 if (params.size() < 2)
576 User* user = Instance->FindNick(prefix);
578 /* NOTE: No check needed on 'user', this function safely handles NULL */
579 if (Instance->XLines->DelLine(params[0].c_str(), params[1], user))
581 this->Instance->SNO->WriteToSnoMask('x',"%s removed %s%s on %s.", prefix.c_str(),
582 params[0].c_str(), params[0].length() == 1 ? "LINE" : "", params[1].c_str());
583 Utils->DoOneToAllButSender(prefix,"DELLINE", params, prefix);
588 bool TreeSocket::ChangeName(const std::string &prefix, std::deque<std::string> ¶ms)
590 if (params.size() < 1)
592 User* u = this->Instance->FindNick(prefix);
595 u->ChangeName(params[0].c_str());
596 params[0] = ":" + params[0];
597 Utils->DoOneToAllButSender(prefix,"FNAME",params,u->server);
602 bool TreeSocket::Whois(const std::string &prefix, std::deque<std::string> ¶ms)
604 if (params.size() < 1)
606 User* u = this->Instance->FindNick(prefix);
609 // an incoming request
610 if (params.size() == 1)
612 User* x = this->Instance->FindNick(params[0]);
613 if ((x) && (IS_LOCAL(x)))
615 User* x = this->Instance->FindNick(params[0]);
618 snprintf(signon, MAXBUF, "%lu", (unsigned long)x->signon);
619 snprintf(idle, MAXBUF, "%lu", (unsigned long)abs((x->idle_lastmsg) - Instance->Time(true)));
620 std::deque<std::string> par;
621 par.push_back(prefix);
622 par.push_back(signon);
624 // ours, we're done, pass it BACK
625 Utils->DoOneToOne(params[0], "IDLE", par, u->server);
629 // not ours pass it on
631 Utils->DoOneToOne(prefix, "IDLE", params, x->server);
634 else if (params.size() == 3)
636 std::string who_did_the_whois = params[0];
637 User* who_to_send_to = this->Instance->FindNick(who_did_the_whois);
638 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
640 // an incoming reply to a whois we sent out
641 std::string nick_whoised = prefix;
642 unsigned long signon = atoi(params[1].c_str());
643 unsigned long idle = atoi(params[2].c_str());
644 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
646 do_whois(this->Instance, who_to_send_to, u, signon, idle, nick_whoised.c_str());
651 // not ours, pass it on
653 Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server);
660 bool TreeSocket::Push(const std::string &prefix, std::deque<std::string> ¶ms)
662 if (params.size() < 2)
664 User* u = this->Instance->FindNick(params[0]);
673 // continue the raw onwards
674 params[1] = ":" + params[1];
675 Utils->DoOneToOne(prefix,"PUSH",params,u->server);
680 bool TreeSocket::HandleSetTime(const std::string &prefix, std::deque<std::string> ¶ms)
682 if (!params.size() || !Utils->EnableTimeSync)
687 if ((params.size() == 2) && (params[1] == "FORCE"))
690 time_t them = atoi(params[0].c_str());
691 time_t us = Instance->Time(false);
693 time_t diff = them - us;
695 Utils->DoOneToAllButSender(prefix, "TIMESET", params, prefix);
697 if (force || (them != us))
699 time_t old = Instance->SetTimeDelta(diff);
700 Instance->Log(DEBUG, "TS (diff %d) from %s applied (old delta was %d)", diff, prefix.c_str(), old);
706 bool TreeSocket::Time(const std::string &prefix, std::deque<std::string> ¶ms)
708 // :source.server TIME remote.server sendernick
709 // :remote.server TIME source.server sendernick TS
710 if (params.size() == 2)
712 // someone querying our time?
713 if (this->Instance->Config->ServerName == params[0] || this->Instance->Config->GetSID() == params[0])
715 User* u = this->Instance->FindNick(params[1]);
718 params.push_back(ConvToStr(Instance->Time(false)));
720 Utils->DoOneToOne(this->Instance->Config->GetSID(),"TIME",params,params[0]);
725 // not us, pass it on
726 User* u = this->Instance->FindNick(params[1]);
728 Utils->DoOneToOne(prefix,"TIME",params,params[0]);
731 else if (params.size() == 3)
733 // a response to a previous TIME
734 User* u = this->Instance->FindNick(params[1]);
735 if ((u) && (IS_LOCAL(u)))
737 time_t rawtime = atol(params[2].c_str());
738 struct tm * timeinfo;
739 timeinfo = localtime(&rawtime);
741 snprintf(tms,26,"%s",asctime(timeinfo));
743 u->WriteServ("391 %s %s :%s",u->nick,prefix.c_str(),tms);
748 Utils->DoOneToOne(prefix,"TIME",params,u->server);
754 bool TreeSocket::LocalPing(const std::string &prefix, std::deque<std::string> ¶ms)
756 if (params.size() < 1)
758 if (params.size() == 1)
760 std::string stufftobounce = params[0];
761 this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" PONG "+stufftobounce);
766 std::string forwardto = params[1];
767 if (forwardto == this->Instance->Config->ServerName || forwardto == this->Instance->Config->GetSID())
769 // this is a ping for us, send back PONG to the requesting server
770 params[1] = params[0];
771 params[0] = forwardto;
772 Utils->DoOneToOne(forwardto,"PONG",params,params[1]);
776 // not for us, pass it on :)
777 Utils->DoOneToOne(prefix,"PING",params,forwardto);
783 /** TODO: This creates a total mess of output and needs to really use irc::modestacker.
785 bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque<std::string> ¶ms)
787 if (params.size() < 1)
789 Channel* c = Instance->FindChan(params[0]);
792 for (char modeletter = 'A'; modeletter <= 'z'; modeletter++)
794 ModeHandler* mh = Instance->Modes->FindMode(modeletter, MODETYPE_CHANNEL);
802 bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string> ¶ms)
804 if (params.size() < 5)
806 SendError("Protocol error - Missing SID");
810 std::string servername = params[0];
811 std::string password = params[1];
812 // hopcount is not used for a remote server, we calculate this ourselves
813 std::string sid = params[3];
814 std::string description = params[4];
815 TreeServer* ParentOfThis = Utils->FindServer(prefix);
818 this->SendError("Protocol error - Introduced remote server from unknown server "+prefix);
821 if (!Utils->IsSID(sid))
823 this->SendError("Invalid format server ID: "+sid+"!");
826 TreeServer* CheckDupe = Utils->FindServer(servername);
829 this->SendError("Server "+servername+" already exists!");
830 this->Instance->SNO->WriteToSnoMask('l',"Server \2"+servername+"\2 being introduced from \2" + prefix + "\2 denied, already exists. Closing link with " + prefix);
834 Link* lnk = Utils->FindLink(servername);
836 TreeServer *Node = new TreeServer(this->Utils, this->Instance, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false);
838 if (Node->DuplicateID())
840 this->SendError("Server ID "+sid+" already exists on the network!");
841 this->Instance->SNO->WriteToSnoMask('l',"Server \2"+servername+"\2 being introduced from \2" + prefix + "\2 denied, server ID already exists on the network. Closing link with " + prefix);
845 ParentOfThis->AddChild(Node);
846 params[4] = ":" + params[4];
847 Utils->SetRemoteBursting(Node, true);
848 Utils->DoOneToAllButSender(prefix,"SERVER",params,prefix);
849 this->Instance->SNO->WriteToSnoMask('l',"Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
853 bool TreeSocket::ComparePass(const std::string &ours, const std::string &theirs)
855 if ((!strncmp(ours.c_str(), "HMAC-SHA256:", 12)) || (!strncmp(theirs.c_str(), "HMAC-SHA256:", 12)))
857 /* One or both of us specified hmac sha256, but we don't have sha256 module loaded!
858 * We can't allow this password as valid.
860 if (!Instance->Modules->Find("m_sha256.so") || !Utils->ChallengeResponse)
863 /* Straight string compare of hashes */
864 return ours == theirs;
867 /* Straight string compare of plaintext */
868 return ours == theirs;
871 bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> ¶ms)
873 if (params.size() < 5)
875 SendError("Protocol error - Missing SID");
879 irc::string servername = params[0].c_str();
880 std::string sname = params[0];
881 std::string password = params[1];
882 std::string sid = params[3];
883 std::string description = params[4];
884 int hops = atoi(params[2].c_str());
886 this->InboundServerName = sname;
887 this->InboundDescription = description;
888 this->InboundSID = sid;
891 this->SendCapabilities();
895 this->SendError("Server too far away for authentication");
896 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
900 if (!Utils->IsSID(sid))
902 this->SendError("Invalid format server ID: "+sid+"!");
906 for (std::vector<Link>::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++)
908 if ((x->Name == servername) && ((ComparePass(this->MakePass(x->RecvPass,this->GetOurChallenge()),password)) || (x->RecvPass == password && (this->GetTheirChallenge().empty()))))
910 TreeServer* CheckDupe = Utils->FindServer(sname);
913 this->SendError("Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
914 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
917 // Begin the sync here. this kickstarts the
918 // other side, waiting in WAIT_AUTH_2 state,
919 // into starting their burst, as it shows
921 this->LinkState = CONNECTED;
922 // we should add the details of this server now
923 // to the servers tree, as a child of the root
926 TreeServer *Node = new TreeServer(this->Utils, this->Instance, sname, description, sid, Utils->TreeRoot, this, x->Hidden);
928 if (Node->DuplicateID())
930 this->SendError("Server ID "+sid+" already exists on the network!");
931 this->Instance->SNO->WriteToSnoMask('l',"Server \2"+assign(servername)+"\2 being introduced denied, server ID already exists on the network. Closing link.");
935 Utils->TreeRoot->AddChild(Node);
936 params[4] = ":" + params[4];
937 Utils->DoOneToAllButSender(Instance->Config->GetSID(),"SERVER",params,sname);
938 this->bursting = true;
943 this->SendError("Invalid credentials");
944 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, invalid link credentials");
948 bool TreeSocket::Inbound_Server(std::deque<std::string> ¶ms)
950 if (params.size() < 5)
952 SendError("Protocol error - Missing SID");
956 irc::string servername = params[0].c_str();
957 std::string sname = params[0];
958 std::string password = params[1];
959 std::string sid = params[3];
960 std::string description = params[4];
961 int hops = atoi(params[2].c_str());
963 this->InboundServerName = sname;
964 this->InboundDescription = description;
965 this->InboundSID = sid;
968 this->SendCapabilities();
972 this->SendError("Server too far away for authentication");
973 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
977 if (!Utils->IsSID(sid))
979 this->SendError("Invalid format server ID: "+sid+"!");
983 for (std::vector<Link>::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++)
985 if ((x->Name == servername) && ((ComparePass(this->MakePass(x->RecvPass,this->GetOurChallenge()),password) || x->RecvPass == password && (this->GetTheirChallenge().empty()))))
987 /* First check for instances of the server that are waiting between the inbound and outbound SERVER command */
988 TreeSocket* CheckDupeSocket = Utils->FindBurstingServer(sname);
991 /* If we find one, we abort the link to prevent a race condition */
992 this->SendError("Negotiation collision");
993 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, already exists in a negotiating state.");
994 CheckDupeSocket->SendError("Negotiation collision");
995 Instance->SE->DelFd(CheckDupeSocket);
996 CheckDupeSocket->Close();
999 /* Check for fully initialized instances of the server by id */
1000 Instance->Log(DEBUG,"Looking for dupe SID %s", sid.c_str());
1001 TreeServer* CheckDupeSID = Utils->FindServerID(sid);
1004 this->SendError("Server ID "+CheckDupeSID->GetID()+" already exists on server "+CheckDupeSID->GetName()+"!");
1005 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, server ID '"+CheckDupeSID->GetID()+
1006 "' already exists on server "+CheckDupeSID->GetName());
1009 /* Now check for fully initialized instances of the server by name */
1010 TreeServer* CheckDupe = Utils->FindServer(sname);
1013 this->SendError("Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
1014 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
1017 this->Instance->SNO->WriteToSnoMask('l',"Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] ("+description+")");
1020 std::string name = BufferedSocketNameRequest((Module*)Utils->Creator, this->Hook).Send();
1021 this->Instance->SNO->WriteToSnoMask('l',"Connection from \2"+sname+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] using transport \2"+name+"\2");
1024 Utils->AddBurstingServer(sname,this);
1026 // this is good. Send our details: Our server name and description and hopcount of 0,
1027 // along with the sendpass from this block.
1028 this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+Instance->Config->GetSID()+" :"+this->Instance->Config->ServerDesc);
1029 // move to the next state, we are now waiting for THEM.
1030 this->LinkState = WAIT_AUTH_2;
1034 this->SendError("Invalid credentials");
1035 this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, invalid link credentials");
1039 void TreeSocket::Split(const std::string &line, std::deque<std::string> &n)
1042 irc::tokenstream tokens(line);
1044 while (tokens.GetToken(param))
1051 bool TreeSocket::ProcessLine(std::string &line)
1053 std::deque<std::string> params;
1054 irc::string command;
1057 line = line.substr(0, line.find_first_of("\r\n"));
1062 Instance->Log(DEBUG, "S[%d] I %s", this->GetFd(), line.c_str());
1064 this->Split(line.c_str(),params);
1069 if ((params[0][0] == ':') && (params.size() > 1))
1071 prefix = params[0].substr(1);
1074 command = params[0].c_str();
1076 switch (this->LinkState)
1081 // Waiting for SERVER command from remote server. Server initiating
1082 // the connection sends the first SERVER command, listening server
1083 // replies with theirs if its happy, then if the initiator is happy,
1084 // it starts to send its net sync, which starts the merge, otherwise
1085 // it sends an ERROR.
1086 if (command == "PASS")
1088 /* Silently ignored */
1090 else if (command == "SERVER")
1092 return this->Inbound_Server(params);
1094 else if (command == "ERROR")
1096 return this->Error(params);
1098 else if (command == "USER")
1100 this->SendError("Client connections to this port are prohibited.");
1103 else if (command == "CAPAB")
1105 return this->Capab(params);
1109 irc::string error = "Invalid command in negotiation phase: " + command;
1110 this->SendError(assign(error));
1115 // Waiting for start of other side's netmerge to say they liked our
1117 if (command == "SERVER")
1119 // cant do this, they sent it to us in the WAIT_AUTH_1 state!
1123 else if (command == "BURST")
1125 if (params.size() && Utils->EnableTimeSync)
1127 bool we_have_delta = (Instance->Time(false) != Instance->Time(true));
1128 time_t them = atoi(params[0].c_str());
1129 time_t delta = them - Instance->Time(false);
1130 if ((delta < -600) || (delta > 600))
1132 Instance->SNO->WriteToSnoMask('l',"\2ERROR\2: Your clocks are out by %d seconds (this is more than five minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta));
1133 SendError("Your clocks are out by "+ConvToStr(abs(delta))+" seconds (this is more than five minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
1136 else if ((delta < -30) || (delta > 30))
1138 Instance->SNO->WriteToSnoMask('l',"\2WARNING\2: Your clocks are out by %d seconds. Please consider synching your clocks.", abs(delta));
1141 if (!Utils->MasterTime && !we_have_delta)
1143 this->Instance->SetTimeDelta(delta);
1144 // Send this new timestamp to any other servers
1145 Utils->DoOneToMany(Instance->Config->GetSID(), "TIMESET", params);
1148 this->LinkState = CONNECTED;
1149 Link* lnk = Utils->FindLink(InboundServerName);
1151 Node = new TreeServer(this->Utils, this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false);
1153 if (Node->DuplicateID())
1155 this->SendError("Server ID "+InboundSID+" already exists on the network!");
1156 this->Instance->SNO->WriteToSnoMask('l',"Server \2"+InboundServerName+"\2 being introduced from \2" + prefix + "\2 denied, server ID already exists on the network. Closing link.");
1159 Utils->DelBurstingServer(this);
1160 Utils->TreeRoot->AddChild(Node);
1162 params.push_back(InboundServerName);
1163 params.push_back("*");
1164 params.push_back("1");
1165 params.push_back(InboundSID);
1166 params.push_back(":"+InboundDescription);
1167 Utils->DoOneToAllButSender(Instance->Config->GetSID(),"SERVER",params,InboundServerName);
1168 this->bursting = true;
1169 this->DoBurst(Node);
1171 else if (command == "ERROR")
1173 return this->Error(params);
1175 else if (command == "CAPAB")
1177 return this->Capab(params);
1182 this->SendError("Internal error -- listening socket accepted its own descriptor!!!");
1186 if (command == "SERVER")
1188 // another server we connected to, which was in WAIT_AUTH_1 state,
1189 // has just sent us their credentials. If we get this far, theyre
1190 // happy with OUR credentials, and they are now in WAIT_AUTH_2 state.
1191 // if we're happy with this, we should send our netburst which
1192 // kickstarts the merge.
1193 return this->Outbound_Reply_Server(params);
1195 else if (command == "ERROR")
1197 return this->Error(params);
1199 else if (command == "CAPAB")
1201 return this->Capab(params);
1205 // This is the 'authenticated' state, when all passwords
1206 // have been exchanged and anything past this point is taken
1209 if (!prefix.empty())
1211 std::string direction = prefix;
1213 User *t = this->Instance->FindUUID(prefix);
1216 direction = t->server;
1219 TreeServer* route_back_again = Utils->BestRouteTo(direction);
1220 if ((!route_back_again) || (route_back_again->GetSocket() != this))
1222 if (route_back_again)
1223 Instance->Log(DEBUG,"Protocol violation: Fake direction in command '%s' from connection '%s'",line.c_str(),this->GetName().c_str());
1227 * When there is activity on the socket, reset the ping counter so
1228 * that we're not wasting bandwidth pinging an active server.
1230 route_back_again->SetNextPingTime(time(NULL) + Utils->PingFreq);
1231 route_back_again->SetPingFlag();
1235 TreeServer* n = Utils->FindServer(GetName());
1237 prefix = n->GetID();
1242 if ((command == "MODE") && (params.size() >= 2))
1244 Channel* channel = Instance->FindChan(params[0]);
1247 User* x = Instance->FindNick(prefix);
1250 if (warned.find(x->server) == warned.end())
1252 Instance->Log(DEFAULT,"WARNING: I revceived modes '%s' from another server '%s'. This is not compliant with InspIRCd. Please check that server for bugs.", params[1].c_str(), x->server);
1253 Instance->SNO->WriteToSnoMask('d', "WARNING: The server %s is sending nonstandard modes: '%s MODE %s' where FMODE should be used, and may cause desyncs.", x->server, x->nick, params[1].c_str());
1254 warned[x->server] = x->nick;
1260 if (command == "SVSMODE")
1262 /* Services expects us to implement
1263 * SVSMODE. In inspircd its the same as
1269 /* Yes, know, this is a mess. Its reasonably fast though as we're
1270 * working with std::string here.
1272 if (command == "UID")
1274 return this->ParseUID(prefix, params);
1276 else if (command == "FJOIN")
1278 TreeServer* ServerSource = Utils->FindServer(prefix);
1280 Utils->SetRemoteBursting(ServerSource, false);
1281 return this->ForceJoin(prefix,params);
1283 else if (command == "STATS")
1285 return this->Stats(prefix, params);
1287 else if (command == "MOTD")
1289 return this->Motd(prefix, params);
1291 else if (command == "KILL" && Utils->IsServer(prefix))
1293 return this->RemoteKill(prefix,params);
1295 else if (command == "MODULES")
1297 return this->Modules(prefix, params);
1299 else if (command == "ADMIN")
1301 return this->Admin(prefix, params);
1303 else if (command == "SERVER")
1305 return this->RemoteServer(prefix,params);
1307 else if (command == "ERROR")
1309 return this->Error(params);
1311 else if (command == "OPERTYPE")
1313 return this->OperType(prefix,params);
1315 else if (command == "FMODE")
1317 TreeServer* ServerSource = Utils->FindServer(prefix);
1319 Utils->SetRemoteBursting(ServerSource, false);
1320 return this->ForceMode(prefix,params);
1322 else if (command == "FTOPIC")
1324 return this->ForceTopic(prefix,params);
1326 else if (command == "REHASH")
1328 return this->RemoteRehash(prefix,params);
1330 else if (command == "METADATA")
1332 return this->MetaData(prefix,params);
1334 else if (command == "REMSTATUS")
1336 return this->RemoveStatus(prefix,params);
1338 else if (command == "PING")
1341 * We just got a ping from a server that's bursting.
1342 * This can't be right, so set them to not bursting, and
1343 * apply their lines.
1345 TreeServer* ServerSource = Utils->FindServer(prefix);
1347 Utils->SetRemoteBursting(ServerSource, false);
1351 this->bursting = false;
1352 Instance->XLines->ApplyLines();
1355 return this->LocalPing(prefix,params);
1357 else if (command == "PONG")
1360 * We just got a pong from a server that's bursting.
1361 * This can't be right, so set them to not bursting, and
1362 * apply their lines.
1364 TreeServer* ServerSource = Utils->FindServer(prefix);
1366 Utils->SetRemoteBursting(ServerSource, false);
1370 this->bursting = false;
1371 Instance->XLines->ApplyLines();
1374 return this->LocalPong(prefix,params);
1376 else if (command == "VERSION")
1378 return this->ServerVersion(prefix,params);
1380 else if (command == "FHOST")
1382 return this->ChangeHost(prefix,params);
1384 else if (command == "FNAME")
1386 return this->ChangeName(prefix,params);
1388 else if (command == "ADDLINE")
1390 TreeServer* ServerSource = Utils->FindServer(prefix);
1392 Utils->SetRemoteBursting(ServerSource, false);
1393 return this->AddLine(prefix,params);
1395 else if (command == "DELLINE")
1397 return this->DelLine(prefix,params);
1399 else if (command == "SVSNICK")
1401 return this->ForceNick(prefix,params);
1403 else if (command == "OPERQUIT")
1405 return this->OperQuit(prefix,params);
1407 else if (command == "IDLE")
1409 return this->Whois(prefix,params);
1411 else if (command == "PUSH")
1413 return this->Push(prefix,params);
1415 else if (command == "TIMESET")
1417 return this->HandleSetTime(prefix, params);
1419 else if (command == "TIME")
1421 return this->Time(prefix,params);
1423 else if ((command == "KICK") && (Utils->IsServer(prefix)))
1425 std::string sourceserv = this->myhost;
1426 if (params.size() == 3)
1428 User* user = this->Instance->FindNick(params[1]);
1429 Channel* chan = this->Instance->FindChan(params[0]);
1432 if (!chan->ServerKickUser(user, params[2].c_str(), false))
1433 /* Yikes, the channels gone! */
1437 if (!this->InboundServerName.empty())
1439 sourceserv = this->InboundServerName;
1441 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
1443 else if (command == "SVSJOIN")
1445 return this->ServiceJoin(prefix,params);
1447 else if (command == "SVSPART")
1449 return this->ServicePart(prefix,params);
1451 else if (command == "SQUIT")
1453 if (params.size() == 2)
1455 this->Squit(Utils->FindServer(params[0]),params[1]);
1459 else if (command == "OPERNOTICE")
1461 std::string sourceserv = this->myhost;
1462 if (!this->InboundServerName.empty())
1463 sourceserv = this->InboundServerName;
1464 if (params.size() >= 1)
1465 Instance->WriteOpers("*** From " + prefix + ": " + params[0]);
1466 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
1468 else if (command == "MODENOTICE")
1470 std::string sourceserv = this->myhost;
1471 if (!this->InboundServerName.empty())
1472 sourceserv = this->InboundServerName;
1473 if (params.size() >= 2)
1475 Instance->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", prefix.c_str(), params[1].c_str());
1477 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
1479 else if (command == "SNONOTICE")
1481 std::string sourceserv = this->myhost;
1482 if (!this->InboundServerName.empty())
1483 sourceserv = this->InboundServerName;
1484 if (params.size() >= 2)
1486 Instance->SNO->WriteToSnoMask(*(params[0].c_str()), "From " + prefix + ": "+ params[1]);
1488 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
1490 else if (command == "ENDBURST")
1492 this->bursting = false;
1493 Instance->XLines->ApplyLines();
1494 std::string sourceserv = this->myhost;
1495 if (!this->InboundServerName.empty())
1496 sourceserv = this->InboundServerName;
1497 this->Instance->SNO->WriteToSnoMask('l',"Received end of netburst from \2%s\2",sourceserv.c_str());
1499 Event rmode((char*)sourceserv.c_str(), (Module*)Utils->Creator, "new_server");
1500 rmode.Send(Instance);
1507 * Not a special s2s command. Emulate the user doing it.
1508 * This saves us having a huge ugly command parser again.
1510 User *who = this->Instance->FindUUID(prefix);
1512 std::string sourceserv = this->myhost;
1513 if (!this->InboundServerName.empty())
1515 sourceserv = this->InboundServerName;
1517 if ((!who) && (command == "MODE"))
1519 if (Utils->IsServer(prefix))
1521 const char* modelist[MAXPARAMETERS];
1522 for (size_t i = 0; i < params.size(); i++)
1523 modelist[i] = params[i].c_str();
1524 this->Instance->SendMode(modelist, params.size(), this->Instance->FakeClient);
1525 /* Hot potato! pass it on! */
1526 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
1531 if (command == "NICK")
1533 if (params.size() != 2)
1535 SendError("Protocol violation: NICK message without TS - :"+std::string(who->uuid)+" NICK "+params[0]);
1538 /* Update timestamp on user when they change nicks */
1539 who->age = atoi(params[1].c_str());
1541 /* On nick messages, check that the nick doesnt
1542 * already exist here. If it does, kill their copy,
1545 User* x = this->Instance->FindNickOnly(params[0]);
1546 if ((x) && (x != who))
1549 /* x is local, who is remote */
1550 collideret = this->DoCollision(x, who->age, who->ident, who->GetIPString(), who->uuid);
1551 if (collideret != 1)
1554 * Remote client lost, or both lost,
1555 * parsing this nickchange would be
1556 * pointless, as the incoming client's
1557 * server will soon recieve SVSNICK to
1558 * change its nick to its UID. :)
1564 Old nickname collision logic..
1565 std::deque<std::string> p;
1566 p.push_back(params[0]);
1567 p.push_back(":Nickname collision ("+prefix+" -> "+params[0]+")");
1568 Utils->DoOneToMany(this->Instance->Config->ServerName,"KILL",p);
1570 p.push_back(prefix);
1571 p.push_back(":Nickname collision");
1572 Utils->DoOneToMany(this->Instance->Config->ServerName,"KILL",p);
1573 User::QuitUser(this->Instance,x,"Nickname collision ("+prefix+" -> "+params[0]+")");
1574 User* y = this->Instance->FindNick(prefix);
1577 User::QuitUser(this->Instance,y,"Nickname collision");
1579 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
1584 target = who->server;
1585 const char* strparams[127];
1586 for (unsigned int q = 0; q < params.size(); q++)
1588 strparams[q] = params[q].c_str();
1590 switch (this->Instance->CallCommandHandler(command.c_str(), strparams, params.size(), who))
1593 this->SendError("Unrecognised or malformed command '"+std::string(command.c_str())+"' -- possibly loaded mismatched modules");
1600 /* CMD_SUCCESS and CMD_USER_DELETED fall through here */
1606 // its not a user. Its either a server, or somethings screwed up.
1607 if (Utils->IsServer(prefix))
1608 target = this->Instance->Config->GetSID();
1612 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
1621 std::string TreeSocket::GetName()
1623 std::string sourceserv = this->myhost;
1624 if (!this->InboundServerName.empty())
1626 sourceserv = this->InboundServerName;
1631 void TreeSocket::OnTimeout()
1633 if (this->LinkState == CONNECTING)
1635 Utils->Creator->RemoteMessage(NULL, "CONNECT: Connection to \002%s\002 timed out.", myhost.c_str());
1636 Link* MyLink = Utils->FindLink(myhost);
1638 Utils->DoFailOver(MyLink);
1642 void TreeSocket::OnClose()
1644 // Test fix for big fuckup
1645 if (this->LinkState != CONNECTED)
1648 // Connection closed.
1649 // If the connection is fully up (state CONNECTED)
1650 // then propogate a netsplit to all peers.
1651 std::string quitserver = this->myhost;
1652 if (!this->InboundServerName.empty())
1654 quitserver = this->InboundServerName;
1656 TreeServer* s = Utils->FindServer(quitserver);
1659 Squit(s,"Remote host closed the connection");
1662 if (!quitserver.empty())
1664 Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' failed.",quitserver.c_str());
1665 time_t server_uptime = Instance->Time() - this->age;
1667 Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
1671 int TreeSocket::OnIncomingConnection(int newsock, char* ip)
1673 /* To prevent anyone from attempting to flood opers/DDoS by connecting to the server port,
1674 * or discovering if this port is the server port, we don't allow connections from any
1675 * IPs for which we don't have a link block.
1679 found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), ip) != Utils->ValidIPs.end());
1682 for (vector<std::string>::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++)
1683 if (irc::sockets::MatchCIDR(ip, (*i).c_str()))
1688 Utils->Creator->RemoteMessage(NULL,"Server connection from %s denied (no link blocks with that IP address)", ip);
1689 Instance->SE->Close(newsock);
1694 TreeSocket* s = new TreeSocket(this->Utils, this->Instance, newsock, ip, this->Hook);
1695 s = s; /* Whinge whinge whinge, thats all GCC ever does. */