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