]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/treesocket2.cpp
f2679518eb42124287b19d501a86b1f83ca25a26
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket2.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "xline.h"
19 #include "transport.h"
20 #include "socketengine.h"
21
22 #include "m_spanningtree/main.h"
23 #include "m_spanningtree/utils.h"
24 #include "m_spanningtree/treeserver.h"
25 #include "m_spanningtree/link.h"
26 #include "m_spanningtree/treesocket.h"
27 #include "m_spanningtree/resolvers.h"
28 #include "m_spanningtree/handshaketimer.h"
29
30 /* $ModDep: 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_spanningtree/handshaketimer.h */
31
32 void TreeSocket::WriteLine(std::string line)
33 {
34         Instance->Logs->Log("m_spanningtree",DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());
35         line.append("\r\n");
36         this->Write(line);
37 }
38
39
40 /* Handle ERROR command */
41 bool TreeSocket::Error(std::deque<std::string> &params)
42 {
43         if (params.size() < 1)
44                 return false;
45         this->Instance->SNO->WriteToSnoMask('l',"ERROR from %s: %s",(!InboundServerName.empty() ? InboundServerName.c_str() : myhost.c_str()),params[0].c_str());
46         /* we will return false to cause the socket to close. */
47         return false;
48 }
49
50 void TreeSocket::Split(const std::string &line, std::deque<std::string> &n)
51 {
52         n.clear();
53         irc::tokenstream tokens(line);
54         std::string param;
55         while (tokens.GetToken(param))
56         {
57                 n.push_back(param);
58         }
59         return;
60 }
61
62 bool TreeSocket::ProcessLine(std::string &line)
63 {
64         std::deque<std::string> params;
65         irc::string command;
66         std::string prefix;
67
68         line = line.substr(0, line.find_first_of("\r\n"));
69
70         if (line.empty())
71                 return true;
72
73         Instance->Logs->Log("m_spanningtree",DEBUG, "S[%d] I %s", this->GetFd(), line.c_str());
74
75         this->Split(line.c_str(),params);
76
77         if (params.empty())
78                 return true;
79
80         if ((params[0][0] == ':') && (params.size() > 1))
81         {
82                 prefix = params[0].substr(1);
83                 params.pop_front();
84
85                 if (prefix.empty())
86                 {
87                         this->SendError("BUG (?) Empty prefix recieved.");
88                         return false;
89                 }
90         }
91
92         command = params[0].c_str();
93         params.pop_front();
94
95         switch (this->LinkState)
96         {
97                 TreeServer* Node;
98
99                 case WAIT_AUTH_1:
100                         /*
101                          * State WAIT_AUTH_1:
102                          *  Waiting for SERVER command from remote server. Server initiating
103                          *  the connection sends the first SERVER command, listening server
104                          *  replies with theirs if its happy, then if the initiator is happy,
105                          *  it starts to send its net sync, which starts the merge, otherwise
106                          *  it sends an ERROR.
107                          */
108                         if (command == "PASS")
109                         {
110                                 /*
111                                  * Ignore this silently. Some services packages insist on sending PASS, even
112                                  * when it is not required (i.e. by us). We have to ignore this here, otherwise
113                                  * as it's an unknown command (effectively), it will cause the connection to be
114                                  * closed, which probably isn't what people want. -- w00t
115                                  */
116                         }
117                         else if (command == "SERVER")
118                         {
119                                 return this->Inbound_Server(params);
120                         }
121                         else if (command == "ERROR")
122                         {
123                                 return this->Error(params);
124                         }
125                         else if (command == "USER")
126                         {
127                                 this->SendError("Client connections to this port are prohibited.");
128                                 return false;
129                         }
130                         else if (command == "CAPAB")
131                         {
132                                 return this->Capab(params);
133                         }
134                         else
135                         {
136                                 // XXX ...wtf.
137                                 irc::string error = "Invalid command in negotiation phase: " + command;
138                                 this->SendError(assign(error));
139                                 return false;
140                         }
141                 break;
142                 case WAIT_AUTH_2:
143                         /*
144                          * State WAIT_AUTH_2:
145                          *  We have sent SERVER to the other side of the connection. Now we're waiting for them to start BURST.
146                          *  The other option at this stage of things, of course, is for them to close our connection thanks
147                          *  to invalid credentials.. -- w
148                          */
149                         if (command == "SERVER")
150                         {
151                                 /*
152                                  * Connection is either attempting to re-auth itself (stupid) or sending netburst without sending BURST.
153                                  * Both of these aren't allowable, so block them here. -- w
154                                  */
155                                 this->SendError("You may not re-authenticate or commence netburst without sending BURST.");
156                                 return true;
157                         }
158                         else if (command == "BURST")
159                         {
160                                 if (params.size())
161                                 {
162                                         time_t them = atoi(params[0].c_str());
163                                         time_t delta = them - Instance->Time();
164                                         if ((delta < -600) || (delta > 600))
165                                         {
166                                                 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((long)delta));
167                                                 SendError("Your clocks are out by "+ConvToStr(abs((long)delta))+" seconds (this is more than five minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
168                                                 return false;
169                                         }
170                                         else if ((delta < -30) || (delta > 30))
171                                         {
172                                                 Instance->SNO->WriteToSnoMask('l',"\2WARNING\2: Your clocks are out by %d seconds. Please consider synching your clocks.", abs((long)delta));
173                                         }
174                                 }
175                                 this->LinkState = CONNECTED;
176                                 Link* lnk = Utils->FindLink(InboundServerName);
177
178                                 Node = new TreeServer(this->Utils, this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false);
179
180                                 if (Node->DuplicateID())
181                                 {
182                                         this->SendError("Server ID "+InboundSID+" already exists on the network!");
183                                         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.");
184                                         return false;
185                                 }
186
187                                 Utils->TreeRoot->AddChild(Node);
188                                 params.clear();
189                                 params.push_back(InboundServerName);
190                                 params.push_back("*");
191                                 params.push_back("1");
192                                 params.push_back(InboundSID);
193                                 params.push_back(":"+InboundDescription);
194                                 Utils->DoOneToAllButSender(Instance->Config->GetSID(),"SERVER",params,InboundServerName);
195                                 Node->bursting = true;
196                                 this->DoBurst(Node);
197                         }
198                         else if (command == "ERROR")
199                         {
200                                 return this->Error(params);
201                         }
202                         else if (command == "CAPAB")
203                         {
204                                 return this->Capab(params);
205                         }
206
207                 break;
208                 case LISTENER:
209                         /*
210                          * This really shouldn't happen.
211                          */
212                         this->SendError("Internal error -- listening socket accepted its own descriptor!!!");
213                         return false;
214                 break;
215                 case CONNECTING:
216                         /*
217                          * State CONNECTING:
218                          *  We're connecting (OUTGOING) to another server. They are in state WAIT_AUTH_1 until they verify
219                          *  our credentials, when they proceed into WAIT_AUTH_2 and send SERVER to us. We then send BURST
220                          *  + our netburst, which will put them into CONNECTED state. -- w
221                          */
222                         if (command == "SERVER")
223                         {
224                                 // Our credentials have been accepted, send netburst. (this puts US into the CONNECTED state)
225                                 return this->Outbound_Reply_Server(params);
226                         }
227                         else if (command == "ERROR")
228                         {
229                                 return this->Error(params);
230                         }
231                         else if (command == "CAPAB")
232                         {
233                                 return this->Capab(params);
234                         }
235                 break;
236                 case CONNECTED:
237                         /*
238                         * State CONNECTED:
239                          *  Credentials have been exchanged, we've gotten their 'BURST' (or sent ours).
240                          *  Anything from here on should be accepted a little more reasonably.
241                          */
242                         if (!prefix.empty())
243                         {
244                                 /*
245                                  * Check for fake direction here, and drop any instances that are found.
246                                  * What is fake direction? Imagine the following server setup:
247                                  *    0AA <-> 0AB <-> 0AC
248                                  * Fake direction would be 0AC sending a message to 0AB claiming to be from
249                                  * 0AA, or something similar. Basically, a message taking a path that *cannot*
250                                  * be correct.
251                                  *
252                                  * When would this be seen?
253                                  * Well, hopefully never. It could be caused by race conditions, bugs, or
254                                  * "miscreant" servers, though, so let's check anyway. -- w
255                                  */
256                                 std::string direction = prefix;
257
258                                 User *t = this->Instance->FindUUID(prefix);
259                                 if (t)
260                                 {
261                                         direction = t->server;
262                                 }
263
264                                 TreeServer* route_back_again = Utils->BestRouteTo(direction);
265                                 if ((!route_back_again) || (route_back_again->GetSocket() != this))
266                                 {
267                                         if (route_back_again)
268                                                 Instance->Logs->Log("m_spanningtree",DEBUG,"Protocol violation: Fake direction in command '%s' from connection '%s'",line.c_str(),this->GetName().c_str());
269                                         return true;
270                                 }
271                                 /* Fix by brain:
272                                  * When there is activity on the socket, reset the ping counter so
273                                  * that we're not wasting bandwidth pinging an active server.
274                                  */
275                                 route_back_again->SetNextPingTime(Instance->Time() + Utils->PingFreq);
276                                 route_back_again->SetPingFlag();
277                         }
278                         else
279                         {
280                                 /*
281                                  * Empty prefix from a server to server link:
282                                  *  This is somewhat bad/naughty, so let's set the prefix
283                                  *  to be the link that we got it from, so we don't break anything. -- w
284                                  */
285                                 TreeServer* n = Utils->FindServer(GetName());
286                                 if (n)
287                                         prefix = n->GetID();
288                                 else
289                                         prefix = GetName();
290                         }
291
292                         /*
293                          * First up, check for any malformed commands (e.g. MODE without a timestamp)
294                          * and rewrite commands where necessary (SVSMODE -> MODE for services). -- w
295                          */
296                         if (command == "SVSMODE") // This isn't in an "else if" so we still force FMODE for changes on channels.
297                                 command = "MODE";
298
299                         if (command == "MODE")
300                         {
301                                 if (params.size() >= 2)
302                                 {
303                                         Channel* channel = Instance->FindChan(params[0]);
304                                         if (channel)
305                                         {
306                                                 this->SendError("MODE may no longer be used on channels. Please use FMODE, with correct timestamp rules.");
307                                                 return false;
308                                         }
309                                 }
310                         }
311
312
313                         /*
314                          * Now, check for (and parse) commands as appropriate. -- w
315                          */
316
317                         /* Find the server that this command originated from, used in the handlers below */
318                         TreeServer *ServerSource = Utils->FindServer(prefix);
319
320                         /* Find the link we just got this from so we don't bounce it back incorrectly */
321                         std::string sourceserv = this->myhost;
322                         if (!this->InboundServerName.empty())
323                         {
324                                 sourceserv = this->InboundServerName;
325                         }
326
327                         /*
328                          * XXX one of these days, this needs to be moved into class Commands.
329                          */
330                         if (command == "UID")
331                         {
332                                 return this->ParseUID(prefix, params);
333                         }
334                         else if (command == "FJOIN")
335                         {
336                                 return this->ForceJoin(prefix,params);
337                         }
338                         else if ((command == "NOTICE" || command == "PRIVMSG") && (Utils->IsServer(prefix)))
339                         {
340                                 return this->ServerMessage(assign(command), prefix, params, sourceserv);
341                         }
342                         else if (command == "STATS")
343                         {
344                                 return this->Stats(prefix, params);
345                         }
346                         else if (command == "MOTD")
347                         {
348                                 return this->Motd(prefix, params);
349                         }
350                         else if (command == "KILL" && ServerSource)
351                         {
352                                 // Kill from a server
353                                 return this->RemoteKill(prefix,params);
354                         }
355                         else if (command == "MODULES")
356                         {
357                                 return this->Modules(prefix, params);
358                         }
359                         else if (command == "ADMIN")
360                         {
361                                 return this->Admin(prefix, params);
362                         }
363                         else if (command == "MAP")
364                         {
365                                 User* user = Instance->FindNick(prefix);
366                                 if (user)
367                                 {
368                                         std::vector<std::string> p(params.begin(), params.end());
369                                         return Utils->Creator->HandleMap(p, user);
370                                 }
371                         }
372                         else if (command == "SERVER")
373                         {
374                                 return this->RemoteServer(prefix,params);
375                         }
376                         else if (command == "ERROR")
377                         {
378                                 return this->Error(params);
379                         }
380                         else if (command == "OPERTYPE")
381                         {
382                                 return this->OperType(prefix,params);
383                         }
384                         else if (command == "FMODE")
385                         {
386                                 return this->ForceMode(prefix,params);
387                         }
388                         else if (command == "FTOPIC")
389                         {
390                                 return this->ForceTopic(prefix,params);
391                         }
392                         else if (command == "METADATA")
393                         {
394                                 return this->MetaData(prefix,params);
395                         }
396                         else if (command == "PING")
397                         {
398                                 return this->LocalPing(prefix,params);
399                         }
400                         else if (command == "PONG")
401                         {
402                                 TreeServer *s = Utils->FindServer(prefix);
403                                 if (s && s->bursting)
404                                 {
405                                         Instance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not finished burst, forcing end of burst (send ENDBURST!)", prefix.c_str());
406                                         s->FinishBurst();
407                                 }
408                                 return this->LocalPong(prefix,params);
409                         }
410                         else if (command == "VERSION")
411                         {
412                                 return this->ServerVersion(prefix,params);
413                         }
414                         else if (command == "FHOST")
415                         {
416                                 return this->ChangeHost(prefix,params);
417                         }
418                         else if (command == "FNAME")
419                         {
420                                 return this->ChangeName(prefix,params);
421                         }
422                         else if (command == "ADDLINE")
423                         {
424                                 return this->AddLine(prefix,params);
425                         }
426                         else if (command == "DELLINE")
427                         {
428                                 return this->DelLine(prefix,params);
429                         }
430                         else if (command == "SVSNICK")
431                         {
432                                 return this->ForceNick(prefix,params);
433                         }
434                         else if (command == "OPERQUIT")
435                         {
436                                 return this->OperQuit(prefix,params);
437                         }
438                         else if (command == "IDLE")
439                         {
440                                 return this->Whois(prefix,params);
441                         }
442                         else if (command == "PUSH")
443                         {
444                                 return this->Push(prefix,params);
445                         }
446                         else if (command == "TIME")
447                         {
448                                 return this->Time(prefix,params);
449                         }
450                         else if ((command == "KICK") && (Utils->IsServer(prefix)))
451                         {
452                                 if (params.size() == 3)
453                                 {
454                                         TreeServer* pf = Utils->FindServer(prefix);
455                                         User* user = this->Instance->FindNick(params[1]);
456                                         Channel* chan = this->Instance->FindChan(params[0]);
457                                         if (pf && user && chan)
458                                         {
459                                                 if (!chan->ServerKickUser(user, params[2].c_str(), false, pf->GetName().c_str()))
460                                                         /* Yikes, the channels gone! */
461                                                         delete chan;
462                                         }
463                                 }
464
465                                 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
466                         }
467                         else if (command == "SVSJOIN")
468                         {
469                                 return this->ServiceJoin(prefix,params);
470                         }
471                         else if (command == "SVSPART")
472                         {
473                                 return this->ServicePart(prefix,params);
474                         }
475                         else if (command == "SQUIT")
476                         {
477                                 if (params.size() == 2)
478                                 {
479                                         this->Squit(Utils->FindServer(params[0]),params[1]);
480                                 }
481                                 return true;
482                         }
483                         else if (command == "MODENOTICE")
484                         {
485                                 if (params.size() >= 2)
486                                 {
487                                         if (ServerSource)
488                                                 Instance->Users->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()), params[1].c_str());
489                                 }
490                                 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
491                         }
492                         else if (command == "SNONOTICE")
493                         {
494                                 if (params.size() >= 2)
495                                 {
496                                         Instance->SNO->WriteToSnoMask(*(params[0].c_str()), "From " + (ServerSource ? ServerSource->GetName().c_str() : prefix) + ": "+ params[1]);
497                                         return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
498                                 }
499
500                         }
501                         else if (command == "BURST")
502                         {
503                                 // Set prefix server as bursting
504                                 if (!ServerSource)
505                                 {
506                                         this->Instance->SNO->WriteToSnoMask('l', "WTF: Got BURST from a nonexistant server(?): %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()));
507                                         return false;
508                                 }
509
510                                 ServerSource->bursting = true;
511                                 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
512                         }
513                         else if (command == "ENDBURST")
514                         {
515                                 if (!ServerSource)
516                                 {
517                                         this->Instance->SNO->WriteToSnoMask('l', "WTF: Got ENDBURST from a nonexistant server(?): %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()));
518                                         return false;
519                                 }
520
521                                 ServerSource->FinishBurst();
522                                 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
523                         }
524                         else if (command == "ENCAP")
525                         {
526                                 return this->Encap(prefix, params);
527                         }
528                         else if (command == "MODE")
529                         {
530                                 // Server-prefix MODE.
531                                 std::vector<std::string> modelist(params.begin(), params.end());
532
533                                 /* We don't support this for channel mode changes any more! */
534                                 if (params.size() >= 1)
535                                 {
536                                         if (Instance->FindChan(params[0]))
537                                         {
538                                                 this->SendError("Protocol violation by '"+(ServerSource ? ServerSource->GetName().c_str() : prefix)+"'! MODE for channel mode changes is not supported by the InspIRCd 1.2 protocol. You must use FMODE to preserve channel timestamps.");
539                                                 return false;
540                                         }
541                                 }
542
543                                 // Insert into the parser
544                                 this->Instance->SendMode(modelist, this->Instance->FakeClient);
545
546                                 // Pass out to the network
547                                 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
548                         }
549                         else
550                         {
551                                 /*
552                                  * Not a special s2s command. Emulate the user doing it.
553                                  * This saves us having a huge ugly command parser again.
554                                  */
555                                 User *who = this->Instance->FindUUID(prefix);
556
557                                 if (!who)
558                                 {
559                                         // this looks ugly because command is an irc::string
560                                         this->SendError("Command (" + std::string(command.c_str()) + ") from unknown prefix (" + prefix + ")! Dropping link.");
561                                         return false;
562                                 }
563
564                                 if (command == "NICK")
565                                 {
566                                         if (params.size() != 2)
567                                         {
568                                                 SendError("Protocol violation: NICK message without TS - :"+std::string(who->uuid)+" NICK "+params[0]);
569                                                 return false;
570                                         }
571                                         /* Update timestamp on user when they change nicks */
572                                         who->age = atoi(params[1].c_str());
573
574                                         /*
575                                          * On nick messages, check that the nick doesnt already exist here.
576                                          * If it does, perform collision logic.
577                                          */
578                                         User* x = this->Instance->FindNickOnly(params[0]);
579                                         if ((x) && (x != who))
580                                         {
581                                                 int collideret = 0;
582                                                 /* x is local, who is remote */
583                                                 collideret = this->DoCollision(x, who->age, who->ident, who->GetIPString(), who->uuid);
584                                                 if (collideret != 1)
585                                                 {
586                                                         /*
587                                                          * Remote client lost, or both lost, parsing this nickchange would be
588                                                          * pointless, as the incoming client's server will soon recieve SVSNICK to
589                                                          * change its nick to its UID. :) -- w00t
590                                                          */
591                                                         return true;
592                                                 }
593                                         }
594                                 }
595
596                                 // its a user
597                                 std::vector<std::string> strparams(params.begin(), params.end());
598
599                                 switch (this->Instance->CallCommandHandler(command.c_str(), strparams, who))
600                                 {
601                                         case CMD_INVALID:
602                                                 /*
603                                                  * XXX: command is irc::string, hence ugliness
604                                                  */
605                                                 this->SendError("Unrecognised or malformed command '" + std::string(command.c_str()) + "' -- possibly loaded mismatched modules");
606                                                 return false;
607                                                 break;
608                                         case CMD_FAILURE:
609                                                 /*
610                                                  * CMD_LOCALONLY is aliased to CMD_FAILURE, so this won't go out onto the network.
611                                                  */
612                                                 return true;
613                                                 break;
614                                         default:
615                                                 /* CMD_SUCCESS falls through here */
616                                                 break;
617                                 }
618
619                                 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
620
621                         }
622                         return true;
623                         break; // end of state CONNECTED (phew).
624         }
625         return true;
626 }
627
628 std::string TreeSocket::GetName()
629 {
630         std::string sourceserv = this->myhost;
631         if (!this->InboundServerName.empty())
632         {
633                 sourceserv = this->InboundServerName;
634         }
635         return sourceserv;
636 }
637
638 void TreeSocket::OnTimeout()
639 {
640         if (this->LinkState == CONNECTING)
641         {
642                 Utils->Creator->RemoteMessage(NULL, "CONNECT: Connection to \002%s\002 timed out.", myhost.c_str());
643                 Link* MyLink = Utils->FindLink(myhost);
644                 if (MyLink)
645                         Utils->DoFailOver(MyLink);
646         }
647 }
648
649 void TreeSocket::OnClose()
650 {
651         // Test fix for big fuckup
652         if (this->LinkState != CONNECTED)
653                 return;
654
655         // Connection closed.
656         // If the connection is fully up (state CONNECTED)
657         // then propogate a netsplit to all peers.
658         std::string quitserver = this->myhost;
659         if (!this->InboundServerName.empty())
660         {
661                 quitserver = this->InboundServerName;
662         }
663         TreeServer* s = Utils->FindServer(quitserver);
664         if (s)
665         {
666                 Squit(s,"Remote host closed the connection");
667         }
668
669         if (!quitserver.empty())
670         {
671                 Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' failed.",quitserver.c_str());
672                 time_t server_uptime = Instance->Time() - this->age;
673                 if (server_uptime)
674                         Utils->Creator->RemoteMessage(NULL,"Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
675         }
676 }
677
678 int TreeSocket::OnIncomingConnection(int newsock, char* ip)
679 {
680         bool found = false;
681
682         found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), ip) != Utils->ValidIPs.end());
683         if (!found)
684         {
685                 for (std::vector<std::string>::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++)
686                 {
687                         if (*i == "*" || irc::sockets::MatchCIDR(ip, *i))
688                         {
689                                 found = true;
690                                 break;
691                         }
692                 }
693
694                 if (!found)
695                 {
696                         Utils->Creator->RemoteMessage(NULL,"Server connection from %s denied (no link blocks with that IP address)", ip);
697                         Instance->SE->Close(newsock);
698                         return false;
699                 }
700         }
701
702         /* we don't need a pointer to this, creating it stores it in the necessary places */
703         new TreeSocket(this->Utils, this->Instance, newsock, ip, this->Hook);
704         return true;
705 }