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