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