]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/utils.cpp
9675a6ac8588f35dbf2ca71a1d1c41de0a3a1713
[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                 DELETE(Bindings[i]);
194         }
195         while (TreeRoot->ChildCount())
196         {
197                 TreeServer* child_server = TreeRoot->GetChild(0);
198                 if (child_server)
199                 {
200                         TreeSocket* sock = child_server->GetSocket();
201                         ServerInstance->SE->DelFd(sock);
202                         sock->Close();
203                         DELETE(sock);
204                 }
205         }
206         delete TreeRoot;
207 }
208
209 void SpanningTreeUtilities::AddThisServer(TreeServer* server, TreeServerList &list)
210 {
211         if (list.find(server) == list.end())
212                 list[server] = server;
213 }
214
215 /* returns a list of DIRECT servernames for a specific channel */
216 void SpanningTreeUtilities::GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list)
217 {
218         CUList *ulist;
219         switch (status)
220         {
221                 case '@':
222                         ulist = c->GetOppedUsers();
223                 break;
224                 case '%':
225                         ulist = c->GetHalfoppedUsers();
226                 break;
227                 case '+':
228                         ulist = c->GetVoicedUsers();
229                 break;
230                 default:
231                         ulist = c->GetUsers();
232                 break;
233         }
234         for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
235         {
236                 if ((i->first->GetFd() < 0) && (exempt_list.find(i->first) == exempt_list.end()))
237                 {
238                         TreeServer* best = this->BestRouteTo(i->first->server);
239                         if (best)
240                                 AddThisServer(best,list);
241                 }
242         }
243         return;
244 }
245
246 bool SpanningTreeUtilities::DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> &params)
247 {
248         char pfx = 0;
249         TreeServer* omitroute = this->BestRouteTo(omit);
250         if ((command == "NOTICE") || (command == "PRIVMSG"))
251         {
252                 if (params.size() >= 2)
253                 {
254                         /* Prefixes */
255                         if ((*(params[0].c_str()) == '@') || (*(params[0].c_str()) == '%') || (*(params[0].c_str()) == '+'))
256                         {
257                                 pfx = params[0][0];
258                                 params[0] = params[0].substr(1, params[0].length()-1);
259                         }
260                         if ((*(params[0].c_str()) != '#') && (*(params[0].c_str()) != '$'))
261                         {
262                                 // special routing for private messages/notices
263                                 userrec* d = ServerInstance->FindNick(params[0]);
264                                 if (d)
265                                 {
266                                         std::deque<std::string> par;
267                                         par.push_back(params[0]);
268                                         par.push_back(":"+params[1]);
269                                         this->DoOneToOne(prefix,command.c_str(),par,d->server);
270                                         return true;
271                                 }
272                         }
273                         else if (*(params[0].c_str()) == '$')
274                         {
275                                 std::deque<std::string> par;
276                                 par.push_back(params[0]);
277                                 par.push_back(":"+params[1]);
278                                 this->DoOneToAllButSender(prefix,command.c_str(),par,omitroute->GetName());
279                                 return true;
280                         }
281                         else
282                         {
283                                 chanrec* c = ServerInstance->FindChan(params[0]);
284                                 userrec* u = ServerInstance->FindNick(prefix);
285                                 if (c && u)
286                                 {
287                                         CUList elist;
288                                         TreeServerList list;
289                                         FOREACH_MOD(I_OnBuildExemptList, OnBuildExemptList((command == "PRIVMSG" ? MSG_PRIVMSG : MSG_NOTICE), c, u, pfx, elist));
290                                         GetListOfServersForChannel(c,list,pfx,elist);
291
292                                         for (TreeServerList::iterator i = list.begin(); i != list.end(); i++)
293                                         {
294                                                 TreeSocket* Sock = i->second->GetSocket();
295                                                 if ((Sock) && (i->second->GetName() != omit) && (omitroute != i->second))
296                                                 {
297                                                         Sock->WriteLine(data);
298                                                 }
299                                         }
300                                         return true;
301                                 }
302                         }
303                 }
304         }
305         unsigned int items =this->TreeRoot->ChildCount();
306         for (unsigned int x = 0; x < items; x++)
307         {
308                 TreeServer* Route = this->TreeRoot->GetChild(x);
309                 if ((Route) && (Route->GetSocket()) && (Route->GetName() != omit) && (omitroute != Route))
310                 {
311                         TreeSocket* Sock = Route->GetSocket();
312                         if (Sock)
313                                 Sock->WriteLine(data);
314                 }
315         }
316         return true;
317 }
318
319 bool SpanningTreeUtilities::DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string omit)
320 {
321         TreeServer* omitroute = this->BestRouteTo(omit);
322         std::string FullLine = ":" + prefix + " " + command;
323         unsigned int words = params.size();
324         for (unsigned int x = 0; x < words; x++)
325         {
326                 FullLine = FullLine + " " + params[x];
327         }
328         unsigned int items = this->TreeRoot->ChildCount();
329         for (unsigned int x = 0; x < items; x++)
330         {
331                 TreeServer* Route = this->TreeRoot->GetChild(x);
332                 // Send the line IF:
333                 // The route has a socket (its a direct connection)
334                 // The route isnt the one to be omitted
335                 // The route isnt the path to the one to be omitted
336                 if ((Route) && (Route->GetSocket()) && (Route->GetName() != omit) && (omitroute != Route))
337                 {
338                         TreeSocket* Sock = Route->GetSocket();
339                         if (Sock)
340                                 Sock->WriteLine(FullLine);
341                 }
342         }
343         return true;
344 }
345
346 bool SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> &params)
347 {
348         std::string FullLine = ":" + prefix + " " + command;
349         unsigned int words = params.size();
350         for (unsigned int x = 0; x < words; x++)
351         {
352                 FullLine = FullLine + " " + params[x];
353         }
354         unsigned int items = this->TreeRoot->ChildCount();
355         for (unsigned int x = 0; x < items; x++)
356         {
357                 TreeServer* Route = this->TreeRoot->GetChild(x);
358                 if (Route && Route->GetSocket())
359                 {
360                         TreeSocket* Sock = Route->GetSocket();
361                         if (Sock)
362                                 Sock->WriteLine(FullLine);
363                 }
364         }
365         return true;
366 }
367
368 bool SpanningTreeUtilities::DoOneToMany(const char* prefix, const char* command, std::deque<std::string> &params)
369 {
370         std::string spfx = prefix;
371         std::string scmd = command;
372         return this->DoOneToMany(spfx, scmd, params);
373 }
374
375 bool SpanningTreeUtilities::DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> &params, std::string omit)
376 {
377         std::string spfx = prefix;
378         std::string scmd = command;
379         return this->DoOneToAllButSender(spfx, scmd, params, omit);
380 }
381
382 bool SpanningTreeUtilities::DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string target)
383 {
384         TreeServer* Route = this->BestRouteTo(target);
385         if (Route)
386         {
387                 std::string FullLine = ":" + prefix + " " + command;
388                 unsigned int words = params.size();
389                 for (unsigned int x = 0; x < words; x++)
390                 {
391                         FullLine = FullLine + " " + params[x];
392                 }
393                 if (Route && Route->GetSocket())
394                 {
395                         TreeSocket* Sock = Route->GetSocket();
396                         if (Sock)
397                                 Sock->WriteLine(FullLine);
398                 }
399                 return true;
400         }
401         else
402         {
403                 return false;
404         }
405 }
406
407 void SpanningTreeUtilities::RefreshIPCache()
408 {
409         ValidIPs.clear();
410         for (std::vector<Link>::iterator L = LinkBlocks.begin(); L != LinkBlocks.end(); L++)
411         {
412                 if ((!L->IPAddr.empty()) && (!L->RecvPass.empty()) && (!L->SendPass.empty()) && (!L->Name.empty()) && (L->Port))
413                 {
414                         ValidIPs.push_back(L->IPAddr);
415
416                         if (L->AllowMask.length())
417                                 ValidIPs.push_back(L->AllowMask);
418
419                         /* Needs resolving */
420                         bool ipvalid = true;
421                         QueryType start_type = DNS_QUERY_A;
422 #ifdef IPV6
423                         start_type = DNS_QUERY_AAAA;
424                         if (strchr(L->IPAddr.c_str(),':'))
425                         {
426                                 in6_addr n;
427                                 if (inet_pton(AF_INET6, L->IPAddr.c_str(), &n) < 1)
428                                         ipvalid = false;
429                         }
430                         else
431 #endif
432                         {
433                                 in_addr n;
434                                 if (inet_aton(L->IPAddr.c_str(),&n) < 1)
435                                         ipvalid = false;
436                         }
437                         if (!ipvalid)
438                         {
439                                 try
440                                 {
441                                         bool cached;
442                                         SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L->IPAddr, *L, cached, start_type);
443                                         ServerInstance->AddResolver(sr, cached);
444                                 }
445                                 catch (...)
446                                 {
447                                 }
448                         }
449                 }
450         }
451 }
452
453 void SpanningTreeUtilities::ReadConfiguration(bool rebind)
454 {
455         ConfigReader* Conf = new ConfigReader(ServerInstance);
456         if (rebind)
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                                 while ((portno = portrange.GetToken()))
469                                 {
470                                         if (IP == "*")
471                                                 IP.clear();
472
473                                         if ((!transport.empty()) && (hooks.find(transport.c_str()) ==  hooks.end()))
474                                         {
475                                                 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());
476                                                 break;
477                                         }
478
479                                         TreeSocket* listener = new TreeSocket(this, ServerInstance, IP.c_str(), portno, true, 10, transport.empty() ? NULL : hooks[transport.c_str()]);
480                                         if (listener->GetState() == I_LISTENING)
481                                         {
482                                                 ServerInstance->Log(DEFAULT,"m_spanningtree: Binding server port %s:%d successful!", IP.c_str(), portno);
483                                                 Bindings.push_back(listener);
484                                         }
485                                         else
486                                         {
487                                                 ServerInstance->Log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port: %s:%d: %s",IP.c_str(), portno, strerror(errno));
488                                                 listener->Close();
489                                                 DELETE(listener);
490                                         }
491                                 }
492                         }
493                 }
494         }
495         FlatLinks = Conf->ReadFlag("options","flatlinks",0);
496         HideULines = Conf->ReadFlag("options","hideulines",0);
497         AnnounceTSChange = Conf->ReadFlag("options","announcets",0);
498         EnableTimeSync = Conf->ReadFlag("timesync","enable",0);
499         MasterTime = Conf->ReadFlag("timesync", "master", 0);
500         ChallengeResponse = !Conf->ReadFlag("options", "disablehmac", 0);
501         quiet_bursts = Conf->ReadFlag("options", "quietbursts", 0);
502         PingWarnTime = Conf->ReadInteger("options", "pingwarning", 0, true);
503
504         if (PingWarnTime < 0 || PingWarnTime > 59)
505                 PingWarnTime = 0;
506
507         LinkBlocks.clear();
508         ValidIPs.clear();
509         for (int j = 0; j < Conf->Enumerate("link"); j++)
510         {
511                 Link L;
512                 std::string Allow = Conf->ReadValue("link", "allowmask", j);
513                 L.Name = (Conf->ReadValue("link", "name", j)).c_str();
514                 L.AllowMask = Allow;
515                 L.IPAddr = Conf->ReadValue("link", "ipaddr", j);
516                 L.FailOver = Conf->ReadValue("link", "failover", j).c_str();
517                 L.Port = Conf->ReadInteger("link", "port", j, true);
518                 L.SendPass = Conf->ReadValue("link", "sendpass", j);
519                 L.RecvPass = Conf->ReadValue("link", "recvpass", j);
520                 L.AutoConnect = Conf->ReadInteger("link", "autoconnect", j, true);
521                 L.HiddenFromStats = Conf->ReadFlag("link", "statshidden", j);
522                 L.Timeout = Conf->ReadInteger("link", "timeout", j, true);
523                 L.Hook = Conf->ReadValue("link", "transport", j);
524                 L.Bind = Conf->ReadValue("link", "bind", j);
525                 L.Hidden = Conf->ReadFlag("link", "hidden", j);
526
527                 if ((!L.Hook.empty()) && (hooks.find(L.Hook.c_str()) ==  hooks.end()))
528                 {
529                         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.",
530                         L.Hook.c_str(), L.Name.c_str());
531                         continue;
532
533                 }
534
535                 L.NextConnectTime = time(NULL) + L.AutoConnect;
536                 /* Bugfix by brain, do not allow people to enter bad configurations */
537                 if (L.Name != ServerInstance->Config->ServerName)
538                 {
539                         if ((!L.IPAddr.empty()) && (!L.RecvPass.empty()) && (!L.SendPass.empty()) && (!L.Name.empty()) && (L.Port))
540                         {
541                                 ValidIPs.push_back(L.IPAddr);
542
543                                 if (Allow.length())
544                                         ValidIPs.push_back(Allow);
545
546                                 /* Needs resolving */
547                                 bool ipvalid = true;
548                                 QueryType start_type = DNS_QUERY_A;
549 #ifdef IPV6
550                                 start_type = DNS_QUERY_AAAA;
551                                 if (strchr(L.IPAddr.c_str(),':'))
552                                 {
553                                         in6_addr n;
554                                         if (inet_pton(AF_INET6, L.IPAddr.c_str(), &n) < 1)
555                                                 ipvalid = false;
556                                 }
557                                 else
558                                 {
559                                         in_addr n;
560                                         if (inet_aton(L.IPAddr.c_str(),&n) < 1)
561                                                 ipvalid = false;
562                                 }
563 #else
564                                 in_addr n;
565                                 if (inet_aton(L.IPAddr.c_str(),&n) < 1)
566                                         ipvalid = false;
567 #endif
568
569                                 if (!ipvalid)
570                                 {
571                                         try
572                                         {
573                                                 bool cached;
574                                                 SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached, start_type);
575                                                 ServerInstance->AddResolver(sr, cached);
576                                         }
577                                         catch (...)
578                                         {
579                                         }
580                                 }
581
582                                 LinkBlocks.push_back(L);
583                         }
584                         else
585                         {
586                                 if (L.IPAddr.empty())
587                                 {
588                                         ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', IP address not defined!",L.Name.c_str());
589                                 }
590                                 else if (L.RecvPass.empty())
591                                 {
592                                         ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', recvpass not defined!",L.Name.c_str());
593                                 }
594                                 else if (L.SendPass.empty())
595                                 {
596                                         ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', sendpass not defined!",L.Name.c_str());
597                                 }
598                                 else if (L.Name.empty())
599                                 {
600                                         ServerInstance->Log(DEFAULT,"Invalid configuration, link tag without a name!");
601                                 }
602                                 else if (!L.Port)
603                                 {
604                                         ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', no port specified!",L.Name.c_str());
605                                 }
606                         }
607                 }
608                 else
609                 {
610                         ServerInstance->Log(DEFAULT,"Invalid configuration for server '%s', link tag has the same server name as the local server!",L.Name.c_str());
611                 }
612         }
613         DELETE(Conf);
614 }
615
616 void SpanningTreeUtilities::DoFailOver(Link* x)
617 {
618         if (x->FailOver.length())
619         {
620                 if (x->FailOver == x->Name)
621                 {
622                         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());
623                         return;
624                 }
625                 Link* TryThisOne = this->FindLink(x->FailOver.c_str());
626                 if (TryThisOne)
627                 {
628                         ServerInstance->SNO->WriteToSnoMask('l',"FAILOVER: Trying failover link for \002%s\002: \002%s\002...", x->Name.c_str(), TryThisOne->Name.c_str());
629                         Creator->ConnectServer(TryThisOne);
630                 }
631                 else
632                 {
633                         ServerInstance->SNO->WriteToSnoMask('l',"FAILOVER: Invalid failover server specified for server \002%s\002, will not follow!", x->Name.c_str());
634                 }
635         }
636 }
637
638 Link* SpanningTreeUtilities::FindLink(const std::string& name)
639 {
640         for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
641         {
642                 if (ServerInstance->MatchText(x->Name.c_str(), name.c_str()))
643                 {
644                         return &(*x);
645                 }
646         }
647         return NULL;
648 }
649