]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/treesocket2.cpp
Fix problem with autoconnects: don't reset NextConnectTime to a higher value than...
[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         ServerInstance->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->ServerInstance->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         ServerInstance->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 - ServerInstance->Time();
164                                         if ((delta < -600) || (delta > 600))
165                                         {
166                                                 ServerInstance->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                                                 ServerInstance->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
177                                 Utils->timeoutlist.erase(this);
178
179                                 Link* lnk = Utils->FindLink(InboundServerName);
180
181                                 Node = new TreeServer(this->Utils, this->ServerInstance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false);
182
183                                 if (Node->DuplicateID())
184                                 {
185                                         this->SendError("Server ID "+InboundSID+" already exists on the network!");
186                                         this->ServerInstance->SNO->WriteToSnoMask('l',"Server \2"+InboundServerName+"\2 being introduced from \2" + prefix + "\2 denied, server ID already exists on the network. Closing link.");
187                                         return false;
188                                 }
189
190                                 Utils->TreeRoot->AddChild(Node);
191                                 params.clear();
192                                 params.push_back(InboundServerName);
193                                 params.push_back("*");
194                                 params.push_back("1");
195                                 params.push_back(InboundSID);
196                                 params.push_back(":"+InboundDescription);
197                                 Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(),"SERVER",params,InboundServerName);
198                                 Node->bursting = true;
199                                 this->DoBurst(Node);
200                         }
201                         else if (command == "ERROR")
202                         {
203                                 return this->Error(params);
204                         }
205                         else if (command == "CAPAB")
206                         {
207                                 return this->Capab(params);
208                         }
209
210                 break;
211                 case CONNECTING:
212                         /*
213                          * State CONNECTING:
214                          *  We're connecting (OUTGOING) to another server. They are in state WAIT_AUTH_1 until they verify
215                          *  our credentials, when they proceed into WAIT_AUTH_2 and send SERVER to us. We then send BURST
216                          *  + our netburst, which will put them into CONNECTED state. -- w
217                          */
218                         if (command == "SERVER")
219                         {
220                                 // Our credentials have been accepted, send netburst. (this puts US into the CONNECTED state)
221                                 return this->Outbound_Reply_Server(params);
222                         }
223                         else if (command == "ERROR")
224                         {
225                                 return this->Error(params);
226                         }
227                         else if (command == "CAPAB")
228                         {
229                                 return this->Capab(params);
230                         }
231                 break;
232                 case CONNECTED:
233                         /*
234                         * State CONNECTED:
235                          *  Credentials have been exchanged, we've gotten their 'BURST' (or sent ours).
236                          *  Anything from here on should be accepted a little more reasonably.
237                          */
238                         if (!prefix.empty())
239                         {
240                                 /*
241                                  * Check for fake direction here, and drop any instances that are found.
242                                  * What is fake direction? Imagine the following server setup:
243                                  *    0AA <-> 0AB <-> 0AC
244                                  * Fake direction would be 0AC sending a message to 0AB claiming to be from
245                                  * 0AA, or something similar. Basically, a message taking a path that *cannot*
246                                  * be correct.
247                                  *
248                                  * When would this be seen?
249                                  * Well, hopefully never. It could be caused by race conditions, bugs, or
250                                  * "miscreant" servers, though, so let's check anyway. -- w
251                                  *
252                                  * We also check here for totally invalid prefixes (prefixes that are neither
253                                  * a valid SID or a valid UUID, so that invalid UUID or SID never makes it 
254                                  * to the higher level functions. -- B
255                                  */
256                                 std::string direction = prefix;
257
258                                 User *t = this->ServerInstance->FindUUID(prefix);
259                                 if (t)
260                                 {
261                                         /* Find UID */
262                                         direction = t->server;
263                                 }
264                                 else if (!this->Utils->FindServer(direction))
265                                 {
266                                         /* Find SID */
267                                         ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Protocol violation: Invalid prefix '%s' from connection '%s'", direction.c_str(), this->GetName().c_str());
268                                         return true;
269                                 }
270
271                                 TreeServer* route_back_again = Utils->BestRouteTo(direction);
272                                 if ((!route_back_again) || (route_back_again->GetSocket() != this))
273                                 {
274                                         if (route_back_again)
275                                                 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Protocol violation: Fake direction in command '%s' from connection '%s'",line.c_str(),this->GetName().c_str());
276                                         return true;
277                                 }
278                                 /* Fix by brain:
279                                  * When there is activity on the socket, reset the ping counter so
280                                  * that we're not wasting bandwidth pinging an active server.
281                                  */
282                                 route_back_again->SetNextPingTime(ServerInstance->Time() + Utils->PingFreq);
283                                 route_back_again->SetPingFlag();
284                         }
285                         else
286                         {
287                                 /*
288                                  * Empty prefix from a server to server link:
289                                  *  This is somewhat bad/naughty, so let's set the prefix
290                                  *  to be the link that we got it from, so we don't break anything. -- w
291                                  */
292                                 TreeServer* n = Utils->FindServer(GetName());
293                                 if (n)
294                                         prefix = n->GetID();
295                                 else
296                                         prefix = GetName();
297                         }
298
299                         /*
300                          * First up, check for any malformed commands (e.g. MODE without a timestamp)
301                          * and rewrite commands where necessary (SVSMODE -> MODE for services). -- w
302                          */
303                         if (command == "SVSMODE") // This isn't in an "else if" so we still force FMODE for changes on channels.
304                                 command = "MODE";
305
306                         /*
307                          * Now, check for (and parse) commands as appropriate. -- w
308                          */
309
310                         /* Find the server that this command originated from, used in the handlers below */
311                         TreeServer *ServerSource = Utils->FindServer(prefix);
312
313                         /* Find the link we just got this from so we don't bounce it back incorrectly */
314                         std::string sourceserv = this->myhost;
315                         if (!this->InboundServerName.empty())
316                         {
317                                 sourceserv = this->InboundServerName;
318                         }
319
320                         /*
321                          * XXX one of these days, this needs to be moved into class Commands.
322                          */
323                         if (command == "UID")
324                         {
325                                 return this->ParseUID(prefix, params);
326                         }
327                         else if (command == "FJOIN")
328                         {
329                                 return this->ForceJoin(prefix,params);
330                         }
331                         else if ((command == "NOTICE" || command == "PRIVMSG") && (Utils->IsServer(prefix)))
332                         {
333                                 return this->ServerMessage(assign(command), prefix, params, sourceserv);
334                         }
335                         else if (command == "STATS")
336                         {
337                                 return this->Stats(prefix, params);
338                         }
339                         else if (command == "MOTD")
340                         {
341                                 return this->Motd(prefix, params);
342                         }
343                         else if (command == "KILL" && ServerSource)
344                         {
345                                 // Kill from a server
346                                 return this->RemoteKill(prefix,params);
347                         }
348                         else if (command == "MODULES")
349                         {
350                                 return this->Modules(prefix, params);
351                         }
352                         else if (command == "ADMIN")
353                         {
354                                 return this->Admin(prefix, params);
355                         }
356                         else if (command == "MAP")
357                         {
358                                 User* user = ServerInstance->FindNick(prefix);
359                                 if (user)
360                                 {
361                                         std::vector<std::string> p(params.begin(), params.end());
362                                         return Utils->Creator->HandleMap(p, user);
363                                 }
364                         }
365                         else if (command == "SERVER")
366                         {
367                                 return this->RemoteServer(prefix,params);
368                         }
369                         else if (command == "ERROR")
370                         {
371                                 return this->Error(params);
372                         }
373                         else if (command == "OPERTYPE")
374                         {
375                                 return this->OperType(prefix,params);
376                         }
377                         else if (command == "FMODE")
378                         {
379                                 return this->ForceMode(prefix,params);
380                         }
381                         else if (command == "FTOPIC")
382                         {
383                                 return this->ForceTopic(prefix,params);
384                         }
385                         else if (command == "METADATA")
386                         {
387                                 return this->MetaData(prefix,params);
388                         }
389                         else if (command == "PING")
390                         {
391                                 return this->LocalPing(prefix,params);
392                         }
393                         else if (command == "PONG")
394                         {
395                                 TreeServer *s = Utils->FindServer(prefix);
396                                 if (s && s->bursting)
397                                 {
398                                         ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not finished burst, forcing end of burst (send ENDBURST!)", prefix.c_str());
399                                         s->FinishBurst();
400                                 }
401                                 return this->LocalPong(prefix,params);
402                         }
403                         else if (command == "VERSION")
404                         {
405                                 return this->ServerVersion(prefix,params);
406                         }
407                         else if (command == "FHOST")
408                         {
409                                 return this->ChangeHost(prefix,params);
410                         }
411                         else if (command == "FNAME")
412                         {
413                                 return this->ChangeName(prefix,params);
414                         }
415                         else if (command == "ADDLINE")
416                         {
417                                 return this->AddLine(prefix,params);
418                         }
419                         else if (command == "DELLINE")
420                         {
421                                 return this->DelLine(prefix,params);
422                         }
423                         else if (command == "SVSNICK")
424                         {
425                                 return this->ForceNick(prefix,params);
426                         }
427                         else if (command == "OPERQUIT")
428                         {
429                                 return this->OperQuit(prefix,params);
430                         }
431                         else if (command == "IDLE")
432                         {
433                                 return this->Whois(prefix,params);
434                         }
435                         else if (command == "PUSH")
436                         {
437                                 return this->Push(prefix,params);
438                         }
439                         else if (command == "TIME")
440                         {
441                                 return this->Time(prefix,params);
442                         }
443                         else if ((command == "KICK") && (Utils->IsServer(prefix)))
444                         {
445                                 if (params.size() == 3)
446                                 {
447                                         TreeServer* pf = Utils->FindServer(prefix);
448                                         User* user = this->ServerInstance->FindNick(params[1]);
449                                         Channel* chan = this->ServerInstance->FindChan(params[0]);
450                                         if (pf && user && chan)
451                                         {
452                                                 if (!chan->ServerKickUser(user, params[2].c_str(), false, pf->GetName().c_str()))
453                                                         /* Yikes, the channels gone! */
454                                                         delete chan;
455                                         }
456                                 }
457
458                                 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
459                         }
460                         else if (command == "SVSJOIN")
461                         {
462                                 return this->ServiceJoin(prefix,params);
463                         }
464                         else if (command == "SVSPART")
465                         {
466                                 return this->ServicePart(prefix,params);
467                         }
468                         else if (command == "SQUIT")
469                         {
470                                 if (params.size() == 2)
471                                 {
472                                         this->Squit(Utils->FindServer(params[0]),params[1]);
473                                 }
474                                 return true;
475                         }
476                         else if (command == "MODENOTICE")
477                         {
478                                 if (params.size() >= 2)
479                                 {
480                                         if (ServerSource)
481                                                 ServerInstance->Users->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()), params[1].c_str());
482                                 }
483                                 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
484                         }
485                         else if (command == "SNONOTICE")
486                         {
487                                 if (params.size() >= 2)
488                                 {
489                                         std::string oldprefix;
490                                         if (!ServerSource)
491                                         {
492                                                 oldprefix = prefix;
493                                                 User *u = ServerInstance->FindNick(prefix);
494                                                 if (!u)
495                                                         return true;
496                                                 prefix = u->nick;
497                                         }
498
499                                         ServerInstance->SNO->WriteToSnoMask(*(params[0].c_str()), "From " + (ServerSource ? ServerSource->GetName().c_str() : prefix) + ": "+ params[1]);
500                                         prefix = oldprefix;
501                                         return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
502                                 }
503
504                         }
505                         else if (command == "BURST")
506                         {
507                                 // Set prefix server as bursting
508                                 if (!ServerSource)
509                                 {
510                                         this->ServerInstance->SNO->WriteToSnoMask('l', "WTF: Got BURST from a nonexistant server(?): %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()));
511                                         return false;
512                                 }
513
514                                 ServerSource->bursting = true;
515                                 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
516                         }
517                         else if (command == "ENDBURST")
518                         {
519                                 if (!ServerSource)
520                                 {
521                                         this->ServerInstance->SNO->WriteToSnoMask('l', "WTF: Got ENDBURST from a nonexistant server(?): %s", (ServerSource ? ServerSource->GetName().c_str() : prefix.c_str()));
522                                         return false;
523                                 }
524
525                                 ServerSource->FinishBurst();
526                                 return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
527                         }
528                         else if (command == "ENCAP")
529                         {
530                                 return this->Encap(prefix, params);
531                         }
532                         else if (command == "MODE" && !this->ServerInstance->FindUUID(prefix)) // XXX we should check for no such serv?
533                         {
534                                 // Server-prefix MODE.
535                                 std::vector<std::string> modelist(params.begin(), params.end());
536
537                                 /* We don't support this for channel mode changes any more! */
538                                 if (params.size() >= 1)
539                                 {
540                                         if (ServerInstance->FindChan(params[0]))
541                                         {
542                                                 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.");
543                                                 return false;
544                                         }
545                                 }
546
547                                 // Insert into the parser
548                                 this->ServerInstance->SendMode(modelist, this->ServerInstance->FakeClient);
549
550                                 // Pass out to the network
551                                 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
552                         }
553                         else
554                         {
555                                 /*
556                                  * Not a special s2s command. Emulate the user doing it.
557                                  * This saves us having a huge ugly command parser again.
558                                  */
559                                 User* who = this->ServerInstance->FindUUID(prefix);
560
561                                 if (!who)
562                                 {
563                                         /* this looks ugly because command is an irc::string
564                                          * It is important that we dont close the link here, unknown prefix can occur
565                                          * due to various race conditions such as the KILL message for a user somehow
566                                          * crossing the users QUIT further upstream from the server. Thanks jilles!
567                                          */
568                                         ServerInstance->Logs->Log("m_spanningtree", DEBUG, "Command " + std::string(command.c_str()) + " from unknown prefix " + prefix + "! Dropping entire command.");
569                                         return true;
570                                 }
571
572                                 if (command == "NICK")
573                                 {
574                                         if (params.size() != 2)
575                                         {
576                                                 SendError("Protocol violation: NICK message without TS - :"+std::string(who->uuid)+" NICK "+params[0]);
577                                                 return false;
578                                         }
579                                         /* Update timestamp on user when they change nicks */
580                                         who->age = atoi(params[1].c_str());
581
582                                         /*
583                                          * On nick messages, check that the nick doesnt already exist here.
584                                          * If it does, perform collision logic.
585                                          */
586                                         User* x = this->ServerInstance->FindNickOnly(params[0]);
587                                         if ((x) && (x != who))
588                                         {
589                                                 int collideret = 0;
590                                                 /* x is local, who is remote */
591                                                 collideret = this->DoCollision(x, who->age, who->ident, who->GetIPString(), who->uuid);
592                                                 if (collideret != 1)
593                                                 {
594                                                         /*
595                                                          * Remote client lost, or both lost, parsing this nickchange would be
596                                                          * pointless, as the incoming client's server will soon recieve SVSNICK to
597                                                          * change its nick to its UID. :) -- w00t
598                                                          */
599                                                         return true;
600                                                 }
601                                         }
602                                 }
603
604                                 // its a user
605                                 std::vector<std::string> strparams(params.begin(), params.end());
606
607                                 switch (this->ServerInstance->CallCommandHandler(command.c_str(), strparams, who))
608                                 {
609                                         case CMD_INVALID:
610                                                 /*
611                                                  * XXX: command is irc::string, hence ugliness
612                                                  */
613                                                 this->SendError("Unrecognised or malformed command '" + std::string(command.c_str()) + "' -- possibly loaded mismatched modules");
614                                                 return false;
615                                                 break;
616                                         case CMD_FAILURE:
617                                                 /*
618                                                  * CMD_LOCALONLY is aliased to CMD_FAILURE, so this won't go out onto the network.
619                                                  */
620                                                 return true;
621                                                 break;
622                                         default:
623                                                 /* CMD_SUCCESS falls through here */
624                                                 break;
625                                 }
626
627                                 return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
628
629                         }
630                         return true;
631                         break; // end of state CONNECTED (phew).
632         }
633         return true;
634 }
635
636 std::string TreeSocket::GetName()
637 {
638         std::string sourceserv = this->myhost;
639         if (!this->InboundServerName.empty())
640         {
641                 sourceserv = this->InboundServerName;
642         }
643         return sourceserv;
644 }
645
646 void TreeSocket::OnTimeout()
647 {
648         if (this->LinkState == CONNECTING)
649         {
650                 this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Connection to \002%s\002 timed out.", myhost.c_str());
651                 Link* MyLink = Utils->FindLink(myhost);
652                 if (MyLink)
653                         Utils->DoFailOver(MyLink);
654         }
655 }
656
657 void TreeSocket::OnClose()
658 {
659         // Test fix for big fuckup
660         if (this->LinkState != CONNECTED)
661                 return;
662
663         // Connection closed.
664         // If the connection is fully up (state CONNECTED)
665         // then propogate a netsplit to all peers.
666         std::string quitserver = this->myhost;
667         if (!this->InboundServerName.empty())
668         {
669                 quitserver = this->InboundServerName;
670         }
671         TreeServer* s = Utils->FindServer(quitserver);
672         if (s)
673         {
674                 Squit(s,"Remote host closed the connection");
675         }
676
677         if (!quitserver.empty())
678         {
679                 this->ServerInstance->SNO->WriteToSnoMask('l', "Connection to '\2%s\2' failed.",quitserver.c_str());
680
681                 time_t server_uptime = ServerInstance->Time() - this->age;
682                 if (server_uptime)
683                                 this->ServerInstance->SNO->WriteToSnoMask('l', "Connection to '\2%s\2' was established for %s", quitserver.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
684         }
685 }
686
687