]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/utils.cpp
Add snomask +s +L - remote link notices.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / utils.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
29 /* $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 */
30
31 /* Create server sockets off a listener. */
32 void ServerSocketListener::OnAcceptReady(const std::string &ipconnectedto, int newsock, const std::string &incomingip)
33 {
34         bool found = false;
35         char *ip = (char *)incomingip.c_str(); // XXX ugly cast
36
37         found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), ip) != Utils->ValidIPs.end());
38         if (!found)
39         {
40                 for (std::vector<std::string>::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++)
41                 {
42                         if (*i == "*" || irc::sockets::MatchCIDR(ip, *i))
43                         {
44                                 found = true;
45                                 break;
46                         }
47                 }
48
49                 if (!found)
50                 {
51                         this->ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", ip);
52                         ServerInstance->SE->Close(newsock);
53                         return;
54                 }
55         }
56
57         if (this->GetIOHook())
58         {
59                 this->GetIOHook()->OnRawSocketAccept(newsock, incomingip.c_str(), this->bind_port);
60         }
61
62         /* we don't need a pointer to this, creating it stores it in the necessary places */
63         new TreeSocket(this->Utils, this->ServerInstance, newsock, ip, this->GetIOHook());
64         return;
65 }
66
67 /** Yay for fast searches!
68  * This is hundreds of times faster than recursion
69  * or even scanning a linked list, especially when
70  * there are more than a few servers to deal with.
71  * (read as: lots).
72  */
73 TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName)
74 {
75         if (this->ServerInstance->IsSID(ServerName))
76                 return this->FindServerID(ServerName);
77
78         server_hash::iterator iter = serverlist.find(ServerName.c_str());
79         if (iter != serverlist.end())
80         {
81                 return iter->second;
82         }
83         else
84         {
85                 return NULL;
86         }
87 }
88
89 /** Returns the locally connected server we must route a
90  * message through to reach server 'ServerName'. This
91  * only applies to one-to-one and not one-to-many routing.
92  * See the comments for the constructor of TreeServer
93  * for more details.
94  */
95 TreeServer* SpanningTreeUtilities::BestRouteTo(const std::string &ServerName)
96 {
97         if (ServerName.c_str() == TreeRoot->GetName() || ServerName == ServerInstance->Config->GetSID())
98                 return NULL;
99         TreeServer* Found = FindServer(ServerName);
100         if (Found)
101         {
102                 return Found->GetRoute();
103         }
104         else
105         {
106                 // Cheat a bit. This allows for (better) working versions of routing commands with nick based prefixes, without hassle
107                 User *u = ServerInstance->FindNick(ServerName);
108                 if (u)
109                 {
110                         Found = FindServer(u->server);
111                         if (Found)
112                                 return Found->GetRoute();
113                 }
114
115                 return NULL;
116         }
117 }
118
119 /** Find the first server matching a given glob mask.
120  * Theres no find-using-glob method of hash_map [awwww :-(]
121  * so instead, we iterate over the list using an iterator
122  * and match each one until we get a hit. Yes its slow,
123  * deal with it.
124  */
125 TreeServer* SpanningTreeUtilities::FindServerMask(const std::string &ServerName)
126 {
127         for (server_hash::iterator i = serverlist.begin(); i != serverlist.end(); i++)
128         {
129                 if (InspIRCd::Match(i->first,ServerName))
130                         return i->second;
131         }
132         return NULL;
133 }
134
135 TreeServer* SpanningTreeUtilities::FindServerID(const std::string &id)
136 {
137         server_hash::iterator iter = sidlist.find(id);
138         if (iter != sidlist.end())
139                 return iter->second;
140         else
141                 return NULL;
142 }
143
144 /* A convenient wrapper that returns true if a server exists */
145 bool SpanningTreeUtilities::IsServer(const std::string &ServerName)
146 {
147         return (FindServer(ServerName) != NULL);
148 }
149
150 SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* C) : ServerInstance(Instance), Creator(C)
151 {
152         Bindings.clear();
153
154         ServerInstance->Logs->Log("m_spanningtree",DEBUG,"***** Using SID for hash: %s *****", ServerInstance->Config->GetSID().c_str());
155
156         this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID());
157
158         modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook");
159
160         /* Did we find any modules? */
161         if (ml)
162         {
163                 /* Yes, enumerate them all to find out the hook name */
164                 for (modulelist::iterator m = ml->begin(); m != ml->end(); m++)
165                 {
166                         /* Make a request to it for its name, its implementing
167                          * BufferedSocketHook so we know its safe to do this
168                          */
169                         std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send();
170                         /* Build a map of them */
171                         hooks[name.c_str()] = *m;
172                         hooknames.push_back(name);
173                 }
174         }
175
176         this->ReadConfiguration(true);
177 }
178
179 SpanningTreeUtilities::~SpanningTreeUtilities()
180 {
181         for (unsigned int i = 0; i < Bindings.size(); i++)
182         {
183                 delete Bindings[i];
184         }
185
186         while (TreeRoot->ChildCount())
187         {
188                 TreeServer* child_server = TreeRoot->GetChild(0);
189                 if (child_server)
190                 {
191                         TreeSocket* sock = child_server->GetSocket();
192                         ServerInstance->SE->DelFd(sock);
193                         sock->Close();
194                 }
195         }
196         delete TreeRoot;
197         ServerInstance->BufferedSocketCull();
198 }
199
200 void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &list)
201 {
202         if (list.find(server) == list.end())
203                 list[server] = server;
204 }
205
206 /* returns a list of DIRECT servernames for a specific channel */
207 void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list)
208 {
209         CUList *ulist = c->GetUsers();
210
211         for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
212         {
213                 if (IS_LOCAL(i->first))
214                         continue;
215
216                 if (status && !strchr(c->GetAllPrefixChars(i->first), status))
217                         continue;
218
219                 if (exempt_list.find(i->first) == exempt_list.end())
220                 {
221                         TreeServer* best = this->BestRouteTo(i->first->server);
222                         if (best)
223                                 AddThisServer(best,list);
224                 }
225         }
226         return;
227 }
228
229 bool SpanningTreeUtilities::DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> &params)
230 {
231         char pfx = 0;
232         TreeServer* omitroute = this->BestRouteTo(omit);
233         if ((command == "NOTICE") || (command == "PRIVMSG"))
234         {
235                 if (params.size() >= 2)
236                 {
237                         /* Prefixes */
238                         if (ServerInstance->Modes->FindPrefix(params[0][0]))
239                         {
240                                 pfx = params[0][0];
241                                 params[0] = params[0].substr(1, params[0].length()-1);
242                         }
243                         if ((*(params[0].c_str()) != '#') && (*(params[0].c_str()) != '$'))
244                         {
245                                 // special routing for private messages/notices
246                                 User* d = ServerInstance->FindNick(params[0]);
247                                 if (d)
248                                 {
249                                         std::deque<std::string> par;
250                                         par.push_back(params[0]);
251                                         par.push_back(":"+params[1]);
252                                         this->DoOneToOne(prefix,command.c_str(),par,d->server);
253                                         return true;
254                                 }
255                         }
256                         else if (*(params[0].c_str()) == '$')
257                         {
258                                 std::deque<std::string> par;
259                                 par.push_back(params[0]);
260                                 par.push_back(":"+params[1]);
261                                 this->DoOneToAllButSender(prefix,command.c_str(),par,omitroute->GetName());
262                                 return true;
263                         }
264                         else
265                         {
266                                 Channel* c = ServerInstance->FindChan(params[0]);
267                                 User* u = ServerInstance->FindNick(prefix);
268                                 if (c)
269                                 {
270                                         CUList elist;
271                                         TreeServerList list;
272                                         FOREACH_MOD(I_OnBuildExemptList, OnBuildExemptList((command == "PRIVMSG" ? MSG_PRIVMSG : MSG_NOTICE), c, u, pfx, elist, params[1]));
273                                         GetListOfServersForChannel(c,list,pfx,elist);
274
275                                         for (TreeServerList::iterator i = list.begin(); i != list.end(); i++)
276                                         {
277                                                 TreeSocket* Sock = i->second->GetSocket();
278                                                 if ((Sock) && (i->second->GetName() != omit) && (omitroute != i->second))
279                                                 {
280                                                         Sock->WriteLine(data);
281                                                 }
282                                         }
283                                         return true;
284                                 }
285                         }
286                 }
287         }
288         unsigned int items =this->TreeRoot->ChildCount();
289         for (unsigned int x = 0; x < items; x++)
290         {
291                 TreeServer* Route = this->TreeRoot->GetChild(x);
292                 if ((Route) && (Route->GetSocket()) && (Route->GetName() != omit) && (omitroute != Route))
293                 {
294                         TreeSocket* Sock = Route->GetSocket();
295                         if (Sock)
296                                 Sock->WriteLine(data);
297                 }
298         }
299         return true;
300 }
301
302 bool SpanningTreeUtilities::DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string omit)
303 {
304         TreeServer* omitroute = this->BestRouteTo(omit);
305         std::string FullLine = ":" + prefix + " " + command;
306         unsigned int words = params.size();
307         for (unsigned int x = 0; x < words; x++)
308         {
309                 FullLine = FullLine + " " + params[x];
310         }
311         unsigned int items = this->TreeRoot->ChildCount();
312         for (unsigned int x = 0; x < items; x++)
313         {
314                 TreeServer* Route = this->TreeRoot->GetChild(x);
315                 // Send the line IF:
316                 // The route has a socket (its a direct connection)
317                 // The route isnt the one to be omitted
318                 // The route isnt the path to the one to be omitted
319                 if ((Route) && (Route->GetSocket()) && (Route->GetName() != omit) && (omitroute != Route))
320                 {
321                         TreeSocket* Sock = Route->GetSocket();
322                         if (Sock)
323                                 Sock->WriteLine(FullLine);
324                 }
325         }
326         return true;
327 }
328
329 bool SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> &params)
330 {
331         std::string FullLine = ":" + prefix + " " + command;
332         unsigned int words = params.size();
333         for (unsigned int x = 0; x < words; x++)
334         {
335                 FullLine = FullLine + " " + params[x];
336         }
337         unsigned int items = this->TreeRoot->ChildCount();
338         for (unsigned int x = 0; x < items; x++)
339         {
340                 TreeServer* Route = this->TreeRoot->GetChild(x);
341                 if (Route && Route->GetSocket())
342                 {
343                         TreeSocket* Sock = Route->GetSocket();
344                         if (Sock)
345                                 Sock->WriteLine(FullLine);
346                 }
347         }
348         return true;
349 }
350
351 bool SpanningTreeUtilities::DoOneToMany(const char* prefix, const char* command, std::deque<std::string> &params)
352 {
353         std::string spfx = prefix;
354         std::string scmd = command;
355         return this->DoOneToMany(spfx, scmd, params);
356 }
357
358 bool SpanningTreeUtilities::DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> &params, std::string omit)
359 {
360         std::string spfx = prefix;
361         std::string scmd = command;
362         return this->DoOneToAllButSender(spfx, scmd, params, omit);
363 }
364
365 bool SpanningTreeUtilities::DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string target)
366 {
367         TreeServer* Route = this->BestRouteTo(target);
368         if (Route)
369         {
370                 std::string FullLine = ":" + prefix + " " + command;
371                 unsigned int words = params.size();
372                 for (unsigned int x = 0; x < words; x++)
373                 {
374                         FullLine = FullLine + " " + params[x];
375                 }
376                 if (Route && Route->GetSocket())
377                 {
378                         TreeSocket* Sock = Route->GetSocket();
379                         if (Sock)
380                                 Sock->WriteLine(FullLine);
381                 }
382                 return true;
383         }
384         else
385         {
386                 return false;
387         }
388 }
389
390 void SpanningTreeUtilities::RefreshIPCache()
391 {
392         ValidIPs.clear();
393         for (std::vector<Link>::iterator L = LinkBlocks.begin(); L != LinkBlocks.end(); L++)
394         {
395                 if (L->IPAddr.empty() || L->RecvPass.empty() || L->SendPass.empty() || L->Name.empty() || !L->Port)
396                 {
397                         if (L->Name.empty())
398                         {
399                                 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"m_spanningtree: Ignoring a malformed link block (all link blocks require a name!)");
400                         }
401                         else
402                         {
403                                 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"m_spanningtree: Ignoring a link block missing recvpass, sendpass, port or ipaddr.");
404                         }
405
406                         /* Invalid link block */
407                         continue;
408                 }
409
410                 ValidIPs.push_back(L->IPAddr);
411
412                 if (L->AllowMask.length())
413                         ValidIPs.push_back(L->AllowMask);
414
415                 /* Needs resolving */
416                 bool ipvalid = true;
417                 QueryType start_type = DNS_QUERY_A;
418 #ifdef IPV6
419                 start_type = DNS_QUERY_AAAA;
420                 if (strchr(L->IPAddr.c_str(),':'))
421                 {
422                         in6_addr n;
423                         if (inet_pton(AF_INET6, L->IPAddr.c_str(), &n) < 1)
424                                 ipvalid = false;
425                 }
426                 else
427 #endif
428                 {
429                         in_addr n;
430                         if (inet_aton(L->IPAddr.c_str(),&n) < 1)
431                                 ipvalid = false;
432                 }
433
434                 if (!ipvalid)
435                 {
436                         try
437                         {
438                                 bool cached;
439                                 SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L->IPAddr, *L, cached, start_type);
440                                 ServerInstance->AddResolver(sr, cached);
441                         }
442                         catch (...)
443                         {
444                         }
445                 }
446         }
447 }
448
449 void SpanningTreeUtilities::ReadConfiguration(bool rebind)
450 {
451         ConfigReader* Conf = new ConfigReader(ServerInstance);
452         if (rebind)
453         {
454                 for (unsigned int i = 0; i < Bindings.size(); i++)
455                 {
456                         delete Bindings[i];
457                 }
458                 ServerInstance->BufferedSocketCull();
459                 Bindings.clear();
460
461                 for (int j = 0; j < Conf->Enumerate("bind"); j++)
462                 {
463                         std::string Type = Conf->ReadValue("bind","type",j);
464                         std::string IP = Conf->ReadValue("bind","address",j);
465                         std::string Port = Conf->ReadValue("bind","port",j);
466                         std::string transport = Conf->ReadValue("bind","transport",j);
467                         if (Type == "servers")
468                         {
469                                 irc::portparser portrange(Port, false);
470                                 int portno = -1;
471
472                                 if (IP == "*")
473                                         IP.clear();
474
475                                 while ((portno = portrange.GetToken()))
476                                 {
477                                         if ((!transport.empty()) && (hooks.find(transport.c_str()) ==  hooks.end()))
478                                         {
479                                                 throw CoreException("Can't find transport type '"+transport+"' for port "+IP+":"+Port+" - maybe you forgot to load it BEFORE m_spanningtree in your config file?");
480                                                 break;
481                                         }
482
483                                         ServerSocketListener *listener = new ServerSocketListener(ServerInstance, this, portno, (char *)IP.c_str());
484                                         if (listener->GetFd() == -1)
485                                         {
486                                                 delete listener;
487                                                 continue;
488                                         }
489
490                                         if (!transport.empty())
491                                                 listener->AddIOHook(hooks[transport.c_str()]);
492
493                                         Bindings.push_back(listener);
494                                 }
495                         }
496                 }
497         }
498         FlatLinks = Conf->ReadFlag("security","flatlinks",0);
499         HideULines = Conf->ReadFlag("security","hideulines",0);
500         AnnounceTSChange = Conf->ReadFlag("options","announcets",0);
501         ChallengeResponse = !Conf->ReadFlag("security", "disablehmac", 0);
502         quiet_bursts = Conf->ReadFlag("performance", "quietbursts", 0);
503         PingWarnTime = Conf->ReadInteger("options", "pingwarning", 0, true);
504         PingFreq = Conf->ReadInteger("options", "serverpingfreq", 0, true);
505
506         if (PingFreq == 0)
507                 PingFreq = 60;
508
509         if (PingWarnTime < 0 || PingWarnTime > PingFreq - 1)
510                 PingWarnTime = 0;
511
512         LinkBlocks.clear();
513         ValidIPs.clear();
514         for (int j = 0; j < Conf->Enumerate("link"); j++)
515         {
516                 Link L;
517                 std::string Allow = Conf->ReadValue("link", "allowmask", j);
518                 L.Name = (Conf->ReadValue("link", "name", j)).c_str();
519                 L.AllowMask = Allow;
520                 L.IPAddr = Conf->ReadValue("link", "ipaddr", j);
521                 L.FailOver = Conf->ReadValue("link", "failover", j).c_str();
522                 L.Port = Conf->ReadInteger("link", "port", j, true);
523                 L.SendPass = Conf->ReadValue("link", "sendpass", j);
524                 L.RecvPass = Conf->ReadValue("link", "recvpass", j);
525                 L.AutoConnect = Conf->ReadInteger("link", "autoconnect", j, true);
526                 L.HiddenFromStats = Conf->ReadFlag("link", "statshidden", j);
527                 L.Timeout = Conf->ReadInteger("link", "timeout", j, true);
528                 L.Hook = Conf->ReadValue("link", "transport", j);
529                 L.Bind = Conf->ReadValue("link", "bind", j);
530                 L.Hidden = Conf->ReadFlag("link", "hidden", j);
531
532                 if ((!L.Hook.empty()) && (hooks.find(L.Hook.c_str()) ==  hooks.end()))
533                 {
534                         throw CoreException("Can't find transport type '"+L.Hook+"' for link '"+assign(L.Name)+"' - maybe you forgot to load it BEFORE m_spanningtree in your config file? Skipping <link> tag completely.");
535                         continue;
536
537                 }
538
539                 L.NextConnectTime = time(NULL) + L.AutoConnect;
540
541                 if (L.Name.find('.') == std::string::npos)
542                         throw CoreException("The link name '"+assign(L.Name)+"' is invalid and must contain at least one '.' character");
543
544                 if (L.Name.length() > 64)
545                         throw CoreException("The link name '"+assign(L.Name)+"' is longer than 64 characters!");
546
547                 if ((!L.IPAddr.empty()) && (!L.RecvPass.empty()) && (!L.SendPass.empty()) && (!L.Name.empty()) && (L.Port))
548                 {
549                         if (Allow.length())
550                                 ValidIPs.push_back(Allow);
551
552                         ValidIPs.push_back(L.IPAddr);
553
554                         /* Needs resolving */
555                         bool ipvalid = true;
556                         QueryType start_type = DNS_QUERY_A;
557 #ifdef IPV6
558                         start_type = DNS_QUERY_AAAA;
559                         if (strchr(L.IPAddr.c_str(),':'))
560                         {
561                                 in6_addr n;
562                                 if (inet_pton(AF_INET6, L.IPAddr.c_str(), &n) < 1)
563                                         ipvalid = false;
564                         }
565                         else
566                         {
567                                 in_addr n;
568                                 if (inet_aton(L.IPAddr.c_str(),&n) < 1)
569                                         ipvalid = false;
570                         }
571 #else
572                         in_addr n;
573                         if (inet_aton(L.IPAddr.c_str(),&n) < 1)
574                                 ipvalid = false;
575 #endif
576
577                         if (!ipvalid)
578                         {
579                                 try
580                                 {
581                                         bool cached;
582                                         SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached, start_type);
583                                         ServerInstance->AddResolver(sr, cached);
584                                 }
585                                 catch (...)
586                                 {
587                                 }
588                         }
589                 }
590                 else
591                 {
592                         if (L.IPAddr.empty())
593                         {
594                                 L.IPAddr = "*";
595                                 ValidIPs.push_back("*");
596                                 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Configuration warning: Link block " + assign(L.Name) + " has no IP defined! This will allow any IP to connect as this server, and MAY not be what you want.");
597                         }
598
599                         if (L.RecvPass.empty())
600                         {
601                                 throw CoreException("Invalid configuration for server '"+assign(L.Name)+"', recvpass not defined!");
602                         }
603
604                         if (L.SendPass.empty())
605                         {
606                                 throw CoreException("Invalid configuration for server '"+assign(L.Name)+"', sendpass not defined!");
607                         }
608
609                         if (L.Name.empty())
610                         {
611                                 throw CoreException("Invalid configuration, link tag without a name! IP address: "+L.IPAddr);
612                         }
613
614                         if (!L.Port)
615                         {
616                                 ServerInstance->Logs->Log("m_spanningtree",DEFAULT,"Configuration warning: Link block " + assign(L.Name) + " has no port defined, you will not be able to /connect it.");
617                         }
618                 }
619
620                 LinkBlocks.push_back(L);
621         }
622         delete Conf;
623 }
624
625 void SpanningTreeUtilities::DoFailOver(Link* x)
626 {
627         if (x->FailOver.length())
628         {
629                 if (x->FailOver == x->Name)
630                 {
631                         this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Some muppet configured the failover for server \002%s\002 to point at itself. Not following it!", x->Name.c_str());
632                         return;
633                 }
634                 Link* TryThisOne = this->FindLink(x->FailOver.c_str());
635                 if (TryThisOne)
636                 {
637                         TreeServer* CheckDupe = this->FindServer(x->FailOver.c_str());
638                         if (CheckDupe)
639                         {
640                                 ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Skipping existing failover: %s", x->FailOver.c_str());
641                         }
642                         else
643                         {
644                                 this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
645                                 Creator->ConnectServer(TryThisOne);
646                         }
647                 }
648                 else
649                 {
650                         this->ServerInstance->SNO->WriteToSnoMask('l', "FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
651                 }
652         }
653 }
654
655 Link* SpanningTreeUtilities::FindLink(const std::string& name)
656 {
657         for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
658         {
659                 if (InspIRCd::Match(x->Name.c_str(), name.c_str()))
660                 {
661                         return &(*x);
662                 }
663         }
664         return NULL;
665 }