1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
23 #include "inspircd_config.h"
25 #include <ext/hash_map>
33 #include "helperfuncs.h"
35 #include "inspstring.h"
40 #define nspace __gnu_cxx
45 class ModuleSpanningTree;
46 static ModuleSpanningTree* TreeProtocolModule;
48 extern std::vector<Module*> modules;
49 extern std::vector<ircd_module*> factory;
52 enum ServerState { LISTENER, CONNECTING, WAIT_AUTH_1, WAIT_AUTH_2, CONNECTED };
54 typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
55 typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash;
57 extern user_hash clientlist;
58 extern chan_hash chanlist;
63 bool DoOneToOne(std::string prefix, std::string command, std::deque<std::string> params, std::string target);
64 bool DoOneToAllButSender(std::string prefix, std::string command, std::deque<std::string> params, std::string omit);
65 bool DoOneToMany(std::string prefix, std::string command, std::deque<std::string> params);
66 bool DoOneToAllButSenderRaw(std::string data,std::string omit, std::string prefix,std::string command,std::deque<std::string> params);
67 void ReadConfiguration(bool rebind);
72 std::vector<TreeServer*> Children;
73 std::string ServerName;
74 std::string ServerDesc;
75 std::string VersionString;
78 TreeSocket* Socket; // for directly connected servers this points at the socket object
88 UserCount = OperCount = 0;
91 TreeServer(std::string Name, std::string Desc) : ServerName(Name), ServerDesc(Desc)
95 UserCount = OperCount = 0;
98 TreeServer(std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock) : Parent(Above), ServerName(Name), ServerDesc(Desc), Socket(Sock)
101 UserCount = OperCount = 0;
104 std::string GetName()
106 return this->ServerName;
109 std::string GetDesc()
111 return this->ServerDesc;
114 std::string GetVersion()
116 return this->VersionString;
121 return this->UserCount;
126 return this->OperCount;
129 TreeSocket* GetSocket()
134 TreeServer* GetParent()
139 unsigned int ChildCount()
141 return Children.size();
144 TreeServer* GetChild(unsigned int n)
146 if (n < Children.size())
156 void AddChild(TreeServer* Child)
158 Children.push_back(Child);
161 bool DelChild(TreeServer* Child)
163 for (std::vector<TreeServer*>::iterator a = Children.begin(); a < Children.end(); a++)
174 // removes child nodes of this node, and of that node, etc etc
177 bool stillchildren = true;
178 while (stillchildren)
180 stillchildren = false;
181 for (std::vector<TreeServer*>::iterator a = Children.begin(); a < Children.end(); a++)
183 TreeServer* s = (TreeServer*)*a;
187 stillchildren = true;
201 std::string SendPass;
202 std::string RecvPass;
205 /* $ModDesc: Povides a spanning tree server link protocol */
209 TreeServer *TreeRoot;
210 std::vector<Link> LinkBlocks;
212 TreeServer* RouteEnumerate(TreeServer* Current, std::string ServerName)
214 if (Current->GetName() == ServerName)
216 for (unsigned int q = 0; q < Current->ChildCount(); q++)
218 TreeServer* found = RouteEnumerate(Current->GetChild(q),ServerName);
227 // Returns the locally connected server we must route a
228 // message through to reach server 'ServerName'. This
229 // only applies to one-to-one and not one-to-many routing.
230 TreeServer* BestRouteTo(std::string ServerName)
232 if (ServerName.c_str() == TreeRoot->GetName())
236 // first, find the server by recursively walking the tree
237 TreeServer* Found = RouteEnumerate(TreeRoot,ServerName);
238 // did we find it? If not, they did something wrong, abort.
245 // The server exists, follow its parent nodes until
246 // the parent of the current is 'TreeRoot', we know
247 // then that this is a directly-connected server.
248 while ((Found) && (Found->GetParent() != TreeRoot))
250 Found = Found->GetParent();
256 bool LookForServer(TreeServer* Current, std::string ServerName)
258 if (ServerName == Current->GetName())
260 for (unsigned int q = 0; q < Current->ChildCount(); q++)
262 if (LookForServer(Current->GetChild(q),ServerName))
270 void RFindServer(TreeServer* Current, std::string ServerName)
272 if ((ServerName == Current->GetName()) && (!Found))
279 for (unsigned int q = 0; q < Current->ChildCount(); q++)
282 RFindServer(Current->GetChild(q),ServerName);
288 TreeServer* FindServer(std::string ServerName)
291 RFindServer(TreeRoot,ServerName);
295 bool IsServer(std::string ServerName)
297 return LookForServer(TreeRoot,ServerName);
300 class TreeSocket : public InspSocket
303 std::string in_buffer;
304 ServerState LinkState;
305 std::string InboundServerName;
306 std::string InboundDescription;
308 int num_lost_servers;
309 nspace::hash_map<std::string,std::string> replacements;
313 TreeSocket(std::string host, int port, bool listening, unsigned long maxtime)
314 : InspSocket(host, port, listening, maxtime)
317 this->LinkState = LISTENER;
320 TreeSocket(std::string host, int port, bool listening, unsigned long maxtime, std::string ServerName)
321 : InspSocket(host, port, listening, maxtime)
324 this->LinkState = CONNECTING;
327 TreeSocket(int newfd, char* ip)
328 : InspSocket(newfd, ip)
330 this->LinkState = WAIT_AUTH_1;
333 virtual bool OnConnected()
335 if (this->LinkState == CONNECTING)
337 Srv->SendOpers("*** Connection to "+myhost+"["+this->GetIP()+"] established.");
338 // we should send our details here.
339 // if the other side is satisfied, they send theirs.
340 // we do not need to change state here.
341 for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
343 if (x->Name == this->myhost)
345 // found who we're supposed to be connecting to, send the neccessary gubbins.
346 this->WriteLine("SERVER "+Srv->GetServerName()+" "+x->SendPass+" 0 :"+Srv->GetServerDescription());
354 virtual void OnError(InspSocketError e)
358 virtual int OnDisconnect()
363 // recursively send the server tree with distances as hops
364 void SendServers(TreeServer* Current, TreeServer* s, int hops)
367 for (unsigned int q = 0; q < Current->ChildCount(); q++)
369 TreeServer* recursive_server = Current->GetChild(q);
370 if (recursive_server != s)
372 // :source.server SERVER server.name hops :Description
373 snprintf(command,1024,":%s SERVER %s * %d :%s",Current->GetName().c_str(),recursive_server->GetName().c_str(),hops,recursive_server->GetDesc().c_str());
374 this->WriteLine(command);
375 // down to next level
376 this->SendServers(recursive_server, s, hops+1);
381 void SquitServer(TreeServer* Current)
383 // recursively squit the servers attached to 'Current'
384 for (unsigned int q = 0; q < Current->ChildCount(); q++)
386 TreeServer* recursive_server = Current->GetChild(q);
387 this->SquitServer(recursive_server);
389 // Now we've whacked the kids, whack self
391 bool quittingpeople = true;
392 while (quittingpeople)
394 quittingpeople = false;
395 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
397 if (!strcasecmp(u->second->server,Current->GetName().c_str()))
399 Srv->QuitUser(u->second,Current->GetName()+" "+std::string(Srv->GetServerName()));
401 quittingpeople = true;
408 void Squit(TreeServer* Current,std::string reason)
412 std::deque<std::string> params;
413 params.push_back(Current->GetName());
414 params.push_back(":"+reason);
415 DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
416 if (Current->GetParent() == TreeRoot)
418 Srv->SendOpers("Server \002"+Current->GetName()+"\002 split: "+reason);
422 Srv->SendOpers("Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
424 num_lost_servers = 0;
426 SquitServer(Current);
428 Current->GetParent()->DelChild(Current);
430 WriteOpers("Netsplit complete, lost \002%d\002 users on \002%d\002 servers.", num_lost_users, num_lost_servers);
434 log(DEFAULT,"Squit from unknown server");
438 bool ForceMode(std::string source, std::deque<std::string> params)
440 userrec* who = new userrec;
441 who->fd = FD_MAGIC_NUMBER;
442 if (params.size() < 2)
445 for (unsigned int q = 0; q < params.size(); q++)
447 modelist[q] = (char*)params[q].c_str();
449 Srv->SendMode(modelist,params.size(),who);
450 DoOneToAllButSender(source,"FMODE",params,source);
455 bool ForceTopic(std::string source, std::deque<std::string> params)
457 // FTOPIC %s %lu %s :%s
458 if (params.size() != 4)
460 std::string channel = params[0];
461 time_t ts = atoi(params[1].c_str());
462 std::string setby = params[2];
463 std::string topic = params[3];
465 chanrec* c = Srv->FindChannel(channel);
468 if ((ts >= c->topicset) || (!*c->topic))
470 strlcpy(c->topic,topic.c_str(),MAXTOPIC);
471 strlcpy(c->setby,setby.c_str(),NICKMAX);
473 WriteChannelWithServ((char*)source.c_str(), c, "TOPIC %s :%s", c->name, c->topic);
478 // all done, send it on its way
479 params[3] = ":" + params[3];
480 DoOneToAllButSender(source,"FTOPIC",params,source);
485 bool ForceJoin(std::string source, std::deque<std::string> params)
487 if (params.size() < 3)
491 char modestring[MAXBUF];
492 char* mode_users[127];
493 mode_users[0] = first;
494 mode_users[1] = modestring;
495 strcpy(mode_users[1],"+");
496 unsigned int modectr = 2;
499 std::string channel = params[0];
500 time_t TS = atoi(params[1].c_str());
503 chanrec* chan = Srv->FindChannel(channel);
508 strlcpy(mode_users[0],channel.c_str(),MAXBUF);
510 // default is a high value, which if we dont have this
511 // channel will let the other side apply their modes.
512 time_t ourTS = time(NULL)+20;
513 chanrec* us = Srv->FindChannel(channel);
519 log(DEBUG,"FJOIN detected, our TS=%lu, their TS=%lu",ourTS,TS);
521 // corect all nicknames that have been force changed due to collision
522 for (unsigned int usernum = 2; usernum < params.size(); usernum++)
524 log(DEBUG,"Collision translation: In=%s",params[usernum].c_str());
525 char* usr = (char*)params[usernum].c_str();
526 char permissions = *usr;
535 std::string nickname = this->GetFJoinReplacement(usr);
536 if ((permissions == '@') || (permissions == '%') || (permissions == '+'))
538 nickname = permissions + nickname;
540 params[usernum] = nickname;
541 log(DEBUG,"Collision translation: Out=%s",params[usernum].c_str());
544 // do this first, so our mode reversals are correctly received by other servers
545 // if there is a TS collision.
546 DoOneToAllButSender(source,"FJOIN",params,source);
548 for (unsigned int usernum = 2; usernum < params.size(); usernum++)
550 // process one channel at a time, applying modes.
551 char* usr = (char*)params[usernum].c_str();
552 std::string nickname;
553 char permissions = *usr;
558 mode_users[modectr++] = usr;
559 strlcat(modestring,"o",MAXBUF);
563 mode_users[modectr++] = usr;
564 strlcat(modestring,"h",MAXBUF);
568 mode_users[modectr++] = usr;
569 strlcat(modestring,"v",MAXBUF);
572 who = Srv->FindNick(usr);
575 Srv->JoinUserToChannel(who,channel,key);
576 if (modectr >= (MAXMODES-1))
578 // theres a mode for this user. push them onto the mode queue, and flush it
579 // if there are more than MAXMODES to go.
582 log(DEBUG,"Our our channel newer than theirs, accepting their modes");
583 Srv->SendMode(mode_users,modectr,who);
587 log(DEBUG,"Their channel newer than ours, bouncing their modes");
589 std::deque<std::string> params;
590 // modes are now being UNSET...
591 *mode_users[1] = '-';
592 for (unsigned int x = 0; x < modectr; x++)
594 params.push_back(mode_users[x]);
596 // tell everyone to bounce the modes. bad modes, bad!
597 DoOneToMany(Srv->GetServerName(),"FMODE",params);
599 strcpy(mode_users[1],"+");
604 // there werent enough modes built up to flush it during FJOIN,
605 // or, there are a number left over. flush them out.
606 if ((modectr > 2) && (who))
610 log(DEBUG,"Our our channel newer than theirs, accepting their modes");
611 Srv->SendMode(mode_users,modectr,who);
615 log(DEBUG,"Their channel newer than ours, bouncing their modes");
616 std::deque<std::string> params;
617 *mode_users[1] = '-';
618 for (unsigned int x = 0; x < modectr; x++)
620 params.push_back(mode_users[x]);
622 DoOneToMany(Srv->GetServerName(),"FMODE",params);
628 bool ClearFJoinReplacement()
630 replacements.clear();
634 void AddFJoinReplacement(std::string oldnick, std::string newnick)
636 nspace::hash_map<std::string,std::string>::iterator iter = replacements.find(oldnick);
637 if (iter != replacements.end())
639 replacements[oldnick] = newnick;
642 std::string GetFJoinReplacement(std::string nickname)
644 nspace::hash_map<std::string,std::string>::iterator iter = replacements.find(nickname);
645 if (iter != replacements.end())
655 bool IntroduceClient(std::string source, std::deque<std::string> params)
657 if (params.size() < 8)
659 // NICK age nick host dhost ident +modes ip :gecos
661 std::string nick = params[1];
662 std::string host = params[2];
663 std::string dhost = params[3];
664 std::string ident = params[4];
665 time_t age = atoi(params[0].c_str());
666 std::string modes = params[5];
667 if (*(modes.c_str()) == '+')
669 char* m = (char*)modes.c_str();
673 std::string ip = params[6];
674 std::string gecos = params[7];
675 char* tempnick = (char*)nick.c_str();
676 log(DEBUG,"Introduce client %s!%s@%s",tempnick,ident.c_str(),host.c_str());
678 user_hash::iterator iter;
679 iter = clientlist.find(tempnick);
680 if (iter != clientlist.end())
683 log(DEBUG,"Nick collision on %s!%s@%s: %lu %lu",tempnick,ident.c_str(),host.c_str(),(unsigned long)age,(unsigned long)iter->second->age);
684 if (iter->second->age >= age)
686 // ours is older than theirs, ours stays. Set a new nick here, send SVSNICK
687 params[1] = nick = "Guest0";
688 this->WriteLine(":"+Srv->GetServerName()+" FNICK "+tempnick+" "+nick);
689 // temporarily (until end of burst) we auto-replace occurances of the old nick with the new nick
690 AddFJoinReplacement(tempnick,nick);
694 // the other end will be changing our nick to the guest nick.
695 // Pause and wait for their FNICK.
700 clientlist[tempnick] = new userrec();
701 clientlist[tempnick]->fd = FD_MAGIC_NUMBER;
702 strlcpy(clientlist[tempnick]->nick, tempnick,NICKMAX);
703 strlcpy(clientlist[tempnick]->host, host.c_str(),160);
704 strlcpy(clientlist[tempnick]->dhost, dhost.c_str(),160);
705 clientlist[tempnick]->server = (char*)FindServerNamePtr(source.c_str());
706 strlcpy(clientlist[tempnick]->ident, ident.c_str(),IDENTMAX);
707 strlcpy(clientlist[tempnick]->fullname, gecos.c_str(),MAXGECOS);
708 clientlist[tempnick]->registered = 7;
709 clientlist[tempnick]->signon = age;
710 strlcpy(clientlist[tempnick]->ip,ip.c_str(),16);
711 for (int i = 0; i < MAXCHANS; i++)
713 clientlist[tempnick]->chans[i].channel = NULL;
714 clientlist[tempnick]->chans[i].uc_modes = 0;
716 params[7] = ":" + params[7];
717 DoOneToAllButSender(source,"NICK",params,source);
721 void SendFJoins(TreeServer* Current, chanrec* c)
724 snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age);
725 std::vector<char*> *ulist = c->GetUsers();
726 for (unsigned int i = 0; i < ulist->size(); i++)
728 char* o = (*ulist)[i];
729 userrec* otheruser = (userrec*)o;
730 strlcat(list," ",MAXBUF);
731 strlcat(list,cmode(otheruser,c),MAXBUF);
732 strlcat(list,otheruser->nick,MAXBUF);
733 if (strlen(list)>(480-NICKMAX))
735 this->WriteLine(list);
736 snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age);
739 if (list[strlen(list)-1] != ':')
741 this->WriteLine(list);
745 void SendChannelModes(TreeServer* Current)
748 for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++)
750 SendFJoins(Current, c->second);
751 snprintf(data,MAXBUF,":%s FMODE %s +%s",Srv->GetServerName().c_str(),c->second->name,chanmodes(c->second));
752 this->WriteLine(data);
753 if (*c->second->topic)
755 snprintf(data,MAXBUF,":%s FTOPIC %s %lu %s :%s",Srv->GetServerName().c_str(),c->second->name,(unsigned long)c->second->topicset,c->second->setby,c->second->topic);
756 this->WriteLine(data);
758 for (BanList::iterator b = c->second->bans.begin(); b != c->second->bans.end(); b++)
760 snprintf(data,MAXBUF,":%s FMODE %s +b %s",Srv->GetServerName().c_str(),c->second->name,b->data);
761 this->WriteLine(data);
763 FOREACH_MOD OnSyncChannel(c->second,(Module*)TreeProtocolModule,(void*)this);
767 // send all users and their channels
768 void SendUsers(TreeServer* Current)
771 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
773 if (u->second->registered == 7)
775 snprintf(data,MAXBUF,":%s NICK %lu %s %s %s %s +%s %s :%s",u->second->server,(unsigned long)u->second->age,u->second->nick,u->second->host,u->second->dhost,u->second->ident,u->second->modes,u->second->ip,u->second->fullname);
776 this->WriteLine(data);
777 if (strchr(u->second->modes,'o'))
779 this->WriteLine(":"+std::string(u->second->nick)+" OPERTYPE "+std::string(u->second->oper));
781 //char* chl = chlist(u->second,u->second);
784 // this->WriteLine(":"+std::string(u->second->nick)+" FJOIN "+std::string(chl));
786 FOREACH_MOD OnSyncUser(u->second,(Module*)TreeProtocolModule,(void*)this);
791 void DoBurst(TreeServer* s)
793 Srv->SendOpers("*** Bursting to "+s->GetName()+".");
794 this->WriteLine("BURST");
796 this->SendServers(TreeRoot,s,1);
797 // Send users and their channels
799 this->WriteLine("ENDUSERS");
800 this->SendChannelModes(s);
801 this->WriteLine("ENDBURST");
804 virtual bool OnDataReady()
806 char* data = this->Read();
809 this->in_buffer += data;
810 while (in_buffer.find("\n") != std::string::npos)
812 char* line = (char*)in_buffer.c_str();
813 std::string ret = "";
814 while ((*line != '\n') && (strlen(line)))
819 if ((*line == '\n') || (*line == '\r'))
822 if (!this->ProcessLine(ret))
828 return (data != NULL);
831 int WriteLine(std::string line)
833 return this->Write(line + "\r\n");
836 bool Error(std::deque<std::string> params)
838 if (params.size() < 1)
840 std::string Errmsg = params[0];
841 std::string SName = myhost;
842 if (InboundServerName != "")
844 SName = InboundServerName;
846 Srv->SendOpers("*** ERROR from "+SName+": "+Errmsg);
847 // we will return false to cause the socket to close.
851 bool OperType(std::string prefix, std::deque<std::string> params)
853 if (params.size() != 1)
855 std::string opertype = params[0];
856 userrec* u = Srv->FindNick(prefix);
859 strlcpy(u->oper,opertype.c_str(),NICKMAX);
860 if (!strchr(u->modes,'o'))
862 strcat(u->modes,"o");
864 DoOneToAllButSender(u->server,"OPERTYPE",params,u->server);
869 bool ForceNick(std::string prefix, std::deque<std::string> params)
871 if (params.size() != 2)
873 std::string oldnick = params[0];
874 std::string newnick = params[1];
875 userrec* u = Srv->FindNick(oldnick);
878 Srv->ChangeUserNick(u,newnick);
879 DoOneToAllButSender(prefix,"FNICK",params,prefix);
885 bool RemoteRehash(std::string prefix, std::deque<std::string> params)
887 if (params.size() < 1)
889 std::string servermask = params[0];
890 if (Srv->MatchText(Srv->GetServerName(),servermask))
892 Srv->SendOpers("*** Remote rehash initiated from server \002"+prefix+"\002.");
894 ReadConfiguration(false);
896 DoOneToAllButSender(prefix,"REHASH",params,prefix);
900 bool RemoteKill(std::string prefix, std::deque<std::string> params)
902 if (params.size() != 2)
904 std::string nick = params[0];
905 std::string reason = params[1];
906 userrec* u = Srv->FindNick(prefix);
907 userrec* who = Srv->FindNick(nick);
910 std::string sourceserv = prefix;
913 sourceserv = u->server;
915 params[1] = ":" + params[1];
916 DoOneToAllButSender(prefix,"KILL",params,sourceserv);
917 Srv->QuitUser(who,reason);
922 bool RemoteServer(std::string prefix, std::deque<std::string> params)
924 if (params.size() < 4)
926 std::string servername = params[0];
927 std::string password = params[1];
928 // hopcount is not used for a remote server, we calculate this ourselves
929 std::string description = params[3];
930 TreeServer* ParentOfThis = FindServer(prefix);
933 this->WriteLine("ERROR :Protocol error - Introduced remote server from unknown server "+prefix);
936 TreeServer* Node = new TreeServer(servername,description,ParentOfThis,NULL);
937 ParentOfThis->AddChild(Node);
938 params[3] = ":" + params[3];
939 DoOneToAllButSender(prefix,"SERVER",params,prefix);
940 Srv->SendOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
944 bool Outbound_Reply_Server(std::deque<std::string> params)
946 if (params.size() < 4)
948 std::string servername = params[0];
949 std::string password = params[1];
950 int hops = atoi(params[2].c_str());
953 this->WriteLine("ERROR :Server too far away for authentication");
956 std::string description = params[3];
957 for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
959 if ((x->Name == servername) && (x->RecvPass == password))
961 // Begin the sync here. this kickstarts the
962 // other side, waiting in WAIT_AUTH_2 state,
963 // into starting their burst, as it shows
965 this->LinkState = CONNECTED;
966 // we should add the details of this server now
967 // to the servers tree, as a child of the root
969 TreeServer* Node = new TreeServer(servername,description,TreeRoot,this);
970 TreeRoot->AddChild(Node);
971 params[3] = ":" + params[3];
972 DoOneToAllButSender(TreeRoot->GetName(),"SERVER",params,servername);
974 this->SendChannelModes(s);
975 this->WriteLine("ENDBURST");
979 this->WriteLine("ERROR :Invalid credentials");
983 bool Inbound_Server(std::deque<std::string> params)
985 if (params.size() < 4)
987 std::string servername = params[0];
988 std::string password = params[1];
989 int hops = atoi(params[2].c_str());
992 this->WriteLine("ERROR :Server too far away for authentication");
995 std::string description = params[3];
996 for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
998 if ((x->Name == servername) && (x->RecvPass == password))
1000 Srv->SendOpers("*** Verified incoming server connection from \002"+servername+"\002["+this->GetIP()+"] ("+description+")");
1001 this->InboundServerName = servername;
1002 this->InboundDescription = description;
1003 // this is good. Send our details: Our server name and description and hopcount of 0,
1004 // along with the sendpass from this block.
1005 this->WriteLine("SERVER "+Srv->GetServerName()+" "+x->SendPass+" 0 :"+Srv->GetServerDescription());
1006 // move to the next state, we are now waiting for THEM.
1007 this->LinkState = WAIT_AUTH_2;
1011 this->WriteLine("ERROR :Invalid credentials");
1015 std::deque<std::string> Split(std::string line, bool stripcolon)
1017 std::deque<std::string> n;
1018 if (!strchr(line.c_str(),' '))
1023 std::stringstream s(line);
1024 std::string param = "";
1043 if ((param == ":") && (item > 0))
1066 bool ProcessLine(std::string line)
1068 char* l = (char*)line.c_str();
1069 while ((strlen(l)) && (l[strlen(l)-1] == '\r') || (l[strlen(l)-1] == '\n'))
1070 l[strlen(l)-1] = '\0';
1074 Srv->Log(DEBUG,"IN: '"+line+"'");
1075 std::deque<std::string> params = this->Split(line,true);
1076 std::string command = "";
1077 std::string prefix = "";
1078 if (((params[0].c_str())[0] == ':') && (params.size() > 1))
1081 command = params[1];
1082 char* pref = (char*)prefix.c_str();
1090 command = params[0];
1094 switch (this->LinkState)
1099 // Waiting for SERVER command from remote server. Server initiating
1100 // the connection sends the first SERVER command, listening server
1101 // replies with theirs if its happy, then if the initiator is happy,
1102 // it starts to send its net sync, which starts the merge, otherwise
1103 // it sends an ERROR.
1104 if (command == "SERVER")
1106 return this->Inbound_Server(params);
1108 else if (command == "ERROR")
1110 return this->Error(params);
1114 // Waiting for start of other side's netmerge to say they liked our
1116 if (command == "SERVER")
1118 // cant do this, they sent it to us in the WAIT_AUTH_1 state!
1122 else if (command == "BURST")
1124 this->LinkState = CONNECTED;
1125 Node = new TreeServer(InboundServerName,InboundDescription,TreeRoot,this);
1126 TreeRoot->AddChild(Node);
1128 params.push_back(InboundServerName);
1129 params.push_back("*");
1130 params.push_back("1");
1131 params.push_back(":"+InboundDescription);
1132 DoOneToAllButSender(TreeRoot->GetName(),"SERVER",params,InboundServerName);
1134 else if (command == "ENDUSERS")
1136 // one server must wait till the other servers list of synched users
1137 // before starting, so we have time to resolve collisions
1138 this->DoBurst(Node);
1139 this->SendChannelModes(s);
1140 this->WriteLine("ENDBURST");
1142 else if (command == "ERROR")
1144 return this->Error(params);
1149 this->WriteLine("ERROR :Internal error -- listening socket accepted its own descriptor!!!");
1153 if (command == "SERVER")
1155 // another server we connected to, which was in WAIT_AUTH_1 state,
1156 // has just sent us their credentials. If we get this far, theyre
1157 // happy with OUR credentials, and they are now in WAIT_AUTH_2 state.
1158 // if we're happy with this, we should send our netburst which
1159 // kickstarts the merge.
1160 return this->Outbound_Reply_Server(params);
1162 else if (command == "ERROR")
1164 return this->Error(params);
1168 // This is the 'authenticated' state, when all passwords
1169 // have been exchanged and anything past this point is taken
1171 std::string target = "";
1172 if ((command == "NICK") && (params.size() > 1))
1174 return this->IntroduceClient(prefix,params);
1176 else if (command == "FJOIN")
1178 return this->ForceJoin(prefix,params);
1180 else if (command == "SERVER")
1182 return this->RemoteServer(prefix,params);
1184 else if (command == "ERROR")
1186 return this->Error(params);
1188 else if (command == "OPERTYPE")
1190 return this->OperType(prefix,params);
1192 else if (command == "FMODE")
1194 return this->ForceMode(prefix,params);
1196 else if (command == "KILL")
1198 return this->RemoteKill(prefix,params);
1200 else if (command == "FTOPIC")
1202 return this->ForceTopic(prefix,params);
1204 else if (command == "REHASH")
1206 return this->RemoteRehash(prefix,params);
1208 else if (command == "FNICK")
1210 return this->ForceNick(prefix,params);
1212 else if (command == "ENDBURST")
1214 return this->ClearFJoinReplacement();
1216 else if (command == "SQUIT")
1218 if (params.size() == 2)
1220 this->Squit(FindServer(params[0]),params[1]);
1226 // not a special inter-server command.
1227 // Emulate the actual user doing the command,
1228 // this saves us having a huge ugly parser.
1229 userrec* who = Srv->FindNick(prefix);
1230 std::string sourceserv = this->myhost;
1231 if (this->InboundServerName != "")
1233 sourceserv = this->InboundServerName;
1238 target = who->server;
1239 char* strparams[127];
1240 for (unsigned int q = 0; q < params.size(); q++)
1242 strparams[q] = (char*)params[q].c_str();
1244 Srv->CallCommandHandler(command, strparams, params.size(), who);
1248 // its not a user. Its either a server, or somethings screwed up.
1249 if (IsServer(prefix))
1251 target = Srv->GetServerName();
1255 log(DEBUG,"Command with unknown origin '%s'",prefix.c_str());
1259 return DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
1268 virtual std::string GetName()
1270 std::string sourceserv = this->myhost;
1271 if (this->InboundServerName != "")
1273 sourceserv = this->InboundServerName;
1278 virtual void OnTimeout()
1280 if (this->LinkState == CONNECTING)
1282 Srv->SendOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
1286 virtual void OnClose()
1288 // Connection closed.
1289 // If the connection is fully up (state CONNECTED)
1290 // then propogate a netsplit to all peers.
1291 std::string quitserver = this->myhost;
1292 if (this->InboundServerName != "")
1294 quitserver = this->InboundServerName;
1296 TreeServer* s = FindServer(quitserver);
1299 Squit(s,"Remote host closed the connection");
1303 virtual int OnIncomingConnection(int newsock, char* ip)
1305 TreeSocket* s = new TreeSocket(newsock, ip);
1311 void AddThisServer(TreeServer* server, std::deque<TreeServer*> &list)
1313 for (unsigned int c = 0; c < list.size(); c++)
1315 if (list[c] == server)
1320 list.push_back(server);
1323 // returns a list of DIRECT servernames for a specific channel
1324 std::deque<TreeServer*> GetListOfServersForChannel(chanrec* c)
1326 std::deque<TreeServer*> list;
1327 std::vector<char*> *ulist = c->GetUsers();
1328 for (unsigned int i = 0; i < ulist->size(); i++)
1330 char* o = (*ulist)[i];
1331 userrec* otheruser = (userrec*)o;
1332 if (std::string(otheruser->server) != Srv->GetServerName())
1334 TreeServer* best = BestRouteTo(otheruser->server);
1336 AddThisServer(best,list);
1342 bool DoOneToAllButSenderRaw(std::string data,std::string omit,std::string prefix,std::string command,std::deque<std::string> params)
1344 TreeServer* omitroute = BestRouteTo(omit);
1345 if ((command == "NOTICE") || (command == "PRIVMSG"))
1347 if (params.size() >= 2)
1349 if (*(params[0].c_str()) != '#')
1351 // special routing for private messages/notices
1352 userrec* d = Srv->FindNick(params[0]);
1355 std::deque<std::string> par;
1357 par.push_back(params[0]);
1358 par.push_back(":"+params[1]);
1359 DoOneToOne(prefix,command,par,d->server);
1365 log(DEBUG,"Channel privmsg going to chan %s",params[0].c_str());
1366 chanrec* c = Srv->FindChannel(params[0]);
1369 std::deque<TreeServer*> list = GetListOfServersForChannel(c);
1370 log(DEBUG,"Got a list of %d servers",list.size());
1371 for (unsigned int i = 0; i < list.size(); i++)
1373 TreeSocket* Sock = list[i]->GetSocket();
1374 if ((Sock) && (list[i]->GetName() != omit) && (omitroute != list[i]))
1376 log(DEBUG,"Writing privmsg to server %s",list[i]->GetName().c_str());
1377 Sock->WriteLine(data);
1385 for (unsigned int x = 0; x < TreeRoot->ChildCount(); x++)
1387 TreeServer* Route = TreeRoot->GetChild(x);
1388 if ((Route->GetSocket()) && (Route->GetName() != omit) && (omitroute != Route))
1390 TreeSocket* Sock = Route->GetSocket();
1391 Sock->WriteLine(data);
1397 bool DoOneToAllButSender(std::string prefix, std::string command, std::deque<std::string> params, std::string omit)
1399 TreeServer* omitroute = BestRouteTo(omit);
1400 std::string FullLine = ":" + prefix + " " + command;
1401 for (unsigned int x = 0; x < params.size(); x++)
1403 FullLine = FullLine + " " + params[x];
1405 for (unsigned int x = 0; x < TreeRoot->ChildCount(); x++)
1407 TreeServer* Route = TreeRoot->GetChild(x);
1408 // Send the line IF:
1409 // The route has a socket (its a direct connection)
1410 // The route isnt the one to be omitted
1411 // The route isnt the path to the one to be omitted
1412 if ((Route->GetSocket()) && (Route->GetName() != omit) && (omitroute != Route))
1414 TreeSocket* Sock = Route->GetSocket();
1415 Sock->WriteLine(FullLine);
1421 bool DoOneToMany(std::string prefix, std::string command, std::deque<std::string> params)
1423 std::string FullLine = ":" + prefix + " " + command;
1424 for (unsigned int x = 0; x < params.size(); x++)
1426 FullLine = FullLine + " " + params[x];
1428 for (unsigned int x = 0; x < TreeRoot->ChildCount(); x++)
1430 TreeServer* Route = TreeRoot->GetChild(x);
1431 if (Route->GetSocket())
1433 TreeSocket* Sock = Route->GetSocket();
1434 Sock->WriteLine(FullLine);
1440 bool DoOneToOne(std::string prefix, std::string command, std::deque<std::string> params, std::string target)
1442 TreeServer* Route = BestRouteTo(target);
1445 std::string FullLine = ":" + prefix + " " + command;
1446 for (unsigned int x = 0; x < params.size(); x++)
1448 FullLine = FullLine + " " + params[x];
1450 if (Route->GetSocket())
1452 TreeSocket* Sock = Route->GetSocket();
1453 Sock->WriteLine(FullLine);
1463 std::vector<TreeSocket*> Bindings;
1465 void ReadConfiguration(bool rebind)
1469 for (int j =0; j < Conf->Enumerate("bind"); j++)
1471 std::string Type = Conf->ReadValue("bind","type",j);
1472 std::string IP = Conf->ReadValue("bind","address",j);
1473 long Port = Conf->ReadInteger("bind","port",j,true);
1474 if (Type == "servers")
1480 TreeSocket* listener = new TreeSocket(IP.c_str(),Port,true,10);
1481 if (listener->GetState() == I_LISTENING)
1483 Srv->AddSocket(listener);
1484 Bindings.push_back(listener);
1488 log(DEFAULT,"m_spanningtree: Warning: Failed to bind server port %d",Port);
1496 for (int j =0; j < Conf->Enumerate("link"); j++)
1499 L.Name = Conf->ReadValue("link","name",j);
1500 L.IPAddr = Conf->ReadValue("link","ipaddr",j);
1501 L.Port = Conf->ReadInteger("link","port",j,true);
1502 L.SendPass = Conf->ReadValue("link","sendpass",j);
1503 L.RecvPass = Conf->ReadValue("link","recvpass",j);
1504 LinkBlocks.push_back(L);
1505 log(DEBUG,"m_spanningtree: Read server %s with host %s:%d",L.Name.c_str(),L.IPAddr.c_str(),L.Port);
1510 class ModuleSpanningTree : public Module
1512 std::vector<TreeSocket*> Bindings;
1517 ModuleSpanningTree()
1520 Conf = new ConfigReader;
1523 // Create the root of the tree
1524 TreeRoot = new TreeServer(Srv->GetServerName(),Srv->GetServerDescription());
1526 ReadConfiguration(true);
1529 void ShowLinks(TreeServer* Current, userrec* user, int hops)
1531 std::string Parent = TreeRoot->GetName();
1532 if (Current->GetParent())
1534 Parent = Current->GetParent()->GetName();
1536 for (unsigned int q = 0; q < Current->ChildCount(); q++)
1538 ShowLinks(Current->GetChild(q),user,hops+1);
1540 WriteServ(user->fd,"364 %s %s %s :%d %s",user->nick,Current->GetName().c_str(),Parent.c_str(),hops,Current->GetDesc().c_str());
1543 void HandleLinks(char** parameters, int pcnt, userrec* user)
1545 ShowLinks(TreeRoot,user,0);
1546 WriteServ(user->fd,"365 %s * :End of /LINKS list.",user->nick);
1550 void HandleLusers(char** parameters, int pcnt, userrec* user)
1555 // WARNING: NOT THREAD SAFE - DONT GET ANY SMART IDEAS.
1557 void ShowMap(TreeServer* Current, userrec* user, int depth, char matrix[128][80])
1561 for (int t = 0; t < depth; t++)
1563 matrix[line][t] = ' ';
1565 strlcpy(&matrix[line][depth],Current->GetName().c_str(),80);
1567 for (unsigned int q = 0; q < Current->ChildCount(); q++)
1569 ShowMap(Current->GetChild(q),user,depth+2,matrix);
1574 // Ok, prepare to be confused.
1575 // After much mulling over how to approach this, it struck me that
1576 // the 'usual' way of doing a /MAP isnt the best way. Instead of
1577 // keeping track of a ton of ascii characters, and line by line
1578 // under recursion working out where to place them using multiplications
1579 // and divisons, we instead render the map onto a backplane of characters
1580 // (a character matrix), then draw the branches as a series of "L" shapes
1581 // from the nodes. This is not only friendlier on CPU it uses less stack.
1583 void HandleMap(char** parameters, int pcnt, userrec* user)
1585 // This array represents a virtual screen which we will
1586 // "scratch" draw to, as the console device of an irc
1587 // client does not provide for a proper terminal.
1588 char matrix[128][80];
1589 for (unsigned int t = 0; t < 128; t++)
1591 matrix[t][0] = '\0';
1594 // The only recursive bit is called here.
1595 ShowMap(TreeRoot,user,0,matrix);
1596 // Process each line one by one. The algorithm has a limit of
1597 // 128 servers (which is far more than a spanning tree should have
1598 // anyway, so we're ok). This limit can be raised simply by making
1599 // the character matrix deeper, 128 rows taking 10k of memory.
1600 for (int l = 1; l < line; l++)
1602 // scan across the line looking for the start of the
1603 // servername (the recursive part of the algorithm has placed
1604 // the servers at indented positions depending on what they
1606 int first_nonspace = 0;
1607 while (matrix[l][first_nonspace] == ' ')
1612 // Draw the `- (corner) section: this may be overwritten by
1613 // another L shape passing along the same vertical pane, becoming
1614 // a |- (branch) section instead.
1615 matrix[l][first_nonspace] = '-';
1616 matrix[l][first_nonspace-1] = '`';
1618 // Draw upwards until we hit the parent server, causing possibly
1619 // other corners (`-) to become branches (|-)
1620 while ((matrix[l2][first_nonspace-1] == ' ') || (matrix[l2][first_nonspace-1] == '`'))
1622 matrix[l2][first_nonspace-1] = '|';
1626 // dump the whole lot to the user. This is the easy bit, honest.
1627 for (int t = 0; t < line; t++)
1629 WriteServ(user->fd,"006 %s :%s",user->nick,&matrix[t][0]);
1631 WriteServ(user->fd,"007 %s :End of /MAP",user->nick);
1635 int HandleSquit(char** parameters, int pcnt, userrec* user)
1640 int HandleConnect(char** parameters, int pcnt, userrec* user)
1642 for (std::vector<Link>::iterator x = LinkBlocks.begin(); x < LinkBlocks.end(); x++)
1644 if (Srv->MatchText(x->Name.c_str(),parameters[0]))
1646 WriteServ(user->fd,"NOTICE %s :*** CONNECT: Connecting to server: %s (%s:%d)",user->nick,x->Name.c_str(),x->IPAddr.c_str(),x->Port);
1647 TreeSocket* newsocket = new TreeSocket(x->IPAddr,x->Port,false,10,x->Name);
1648 Srv->AddSocket(newsocket);
1652 WriteServ(user->fd,"NOTICE %s :*** CONNECT: No matching server could be found in the config file.",user->nick);
1656 virtual int OnPreCommand(std::string command, char **parameters, int pcnt, userrec *user)
1658 if (command == "CONNECT")
1660 return this->HandleConnect(parameters,pcnt,user);
1662 else if (command == "SQUIT")
1664 return this->HandleSquit(parameters,pcnt,user);
1666 else if (command == "MAP")
1668 this->HandleMap(parameters,pcnt,user);
1671 else if (command == "LUSERS")
1673 this->HandleLusers(parameters,pcnt,user);
1676 else if (command == "LINKS")
1678 this->HandleLinks(parameters,pcnt,user);
1681 else if (Srv->IsValidModuleCommand(command, pcnt, user))
1683 // this bit of code cleverly routes all module commands
1684 // to all remote severs *automatically* so that modules
1685 // can just handle commands locally, without having
1686 // to have any special provision in place for remote
1687 // commands and linking protocols.
1688 std::deque<std::string> params;
1690 for (int j = 0; j < pcnt; j++)
1692 if (strchr(parameters[j],' '))
1694 params.push_back(":" + std::string(parameters[j]));
1698 params.push_back(std::string(parameters[j]));
1701 DoOneToMany(user->nick,command,params);
1706 virtual void OnGetServerDescription(std::string servername,std::string &description)
1708 TreeServer* s = FindServer(servername);
1711 description = s->GetDesc();
1715 virtual void OnUserInvite(userrec* source,userrec* dest,chanrec* channel)
1717 if (std::string(source->server) == Srv->GetServerName())
1719 std::deque<std::string> params;
1720 params.push_back(dest->nick);
1721 params.push_back(channel->name);
1722 DoOneToMany(source->nick,"INVITE",params);
1726 virtual void OnPostLocalTopicChange(userrec* user, chanrec* chan, std::string topic)
1728 std::deque<std::string> params;
1729 params.push_back(chan->name);
1730 params.push_back(":"+topic);
1731 DoOneToMany(user->nick,"TOPIC",params);
1734 virtual void OnUserNotice(userrec* user, void* dest, int target_type, std::string text)
1736 if (target_type == TYPE_USER)
1738 userrec* d = (userrec*)dest;
1739 if ((std::string(d->server) != Srv->GetServerName()) && (std::string(user->server) == Srv->GetServerName()))
1741 std::deque<std::string> params;
1743 params.push_back(d->nick);
1744 params.push_back(":"+text);
1745 DoOneToOne(user->nick,"NOTICE",params,d->server);
1750 if (std::string(user->server) == Srv->GetServerName())
1752 chanrec *c = (chanrec*)dest;
1753 std::deque<TreeServer*> list = GetListOfServersForChannel(c);
1754 for (unsigned int i = 0; i < list.size(); i++)
1756 TreeSocket* Sock = list[i]->GetSocket();
1758 Sock->WriteLine(":"+std::string(user->nick)+" NOTICE "+std::string(c->name)+" :"+text);
1764 virtual void OnUserMessage(userrec* user, void* dest, int target_type, std::string text)
1766 if (target_type == TYPE_USER)
1768 // route private messages which are targetted at clients only to the server
1769 // which needs to receive them
1770 userrec* d = (userrec*)dest;
1771 if ((std::string(d->server) != Srv->GetServerName()) && (std::string(user->server) == Srv->GetServerName()))
1773 std::deque<std::string> params;
1775 params.push_back(d->nick);
1776 params.push_back(":"+text);
1777 DoOneToOne(user->nick,"PRIVMSG",params,d->server);
1782 if (std::string(user->server) == Srv->GetServerName())
1784 chanrec *c = (chanrec*)dest;
1785 std::deque<TreeServer*> list = GetListOfServersForChannel(c);
1786 for (unsigned int i = 0; i < list.size(); i++)
1788 TreeSocket* Sock = list[i]->GetSocket();
1790 Sock->WriteLine(":"+std::string(user->nick)+" PRIVMSG "+std::string(c->name)+" :"+text);
1796 virtual void OnUserJoin(userrec* user, chanrec* channel)
1798 // Only do this for local users
1799 if (std::string(user->server) == Srv->GetServerName())
1801 std::deque<std::string> params;
1803 params.push_back(channel->name);
1806 // if the channel has a key, force the join by emulating the key.
1807 params.push_back(channel->key);
1809 DoOneToMany(user->nick,"JOIN",params);
1813 virtual void OnUserPart(userrec* user, chanrec* channel)
1815 if (std::string(user->server) == Srv->GetServerName())
1817 std::deque<std::string> params;
1819 params.push_back(channel->name);
1820 DoOneToMany(user->nick,"PART",params);
1824 virtual void OnUserConnect(userrec* user)
1826 char agestr[MAXBUF];
1827 if (std::string(user->server) == Srv->GetServerName())
1829 std::deque<std::string> params;
1830 snprintf(agestr,MAXBUF,"%lu",(unsigned long)user->age);
1832 params.push_back(agestr);
1833 params.push_back(user->nick);
1834 params.push_back(user->host);
1835 params.push_back(user->dhost);
1836 params.push_back(user->ident);
1837 params.push_back("+"+std::string(user->modes));
1838 params.push_back(user->ip);
1839 params.push_back(":"+std::string(user->fullname));
1840 DoOneToMany(Srv->GetServerName(),"NICK",params);
1844 virtual void OnUserQuit(userrec* user, std::string reason)
1846 if (std::string(user->server) == Srv->GetServerName())
1848 std::deque<std::string> params;
1849 params.push_back(":"+reason);
1850 DoOneToMany(user->nick,"QUIT",params);
1854 virtual void OnUserPostNick(userrec* user, std::string oldnick)
1856 if (std::string(user->server) == Srv->GetServerName())
1858 std::deque<std::string> params;
1859 params.push_back(user->nick);
1860 DoOneToMany(oldnick,"NICK",params);
1864 virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, std::string reason)
1866 if (std::string(source->server) == Srv->GetServerName())
1868 std::deque<std::string> params;
1869 params.push_back(chan->name);
1870 params.push_back(user->nick);
1871 params.push_back(":"+reason);
1872 DoOneToMany(source->nick,"KICK",params);
1876 virtual void OnRemoteKill(userrec* source, userrec* dest, std::string reason)
1878 std::deque<std::string> params;
1879 params.push_back(dest->nick);
1880 params.push_back(":"+reason);
1881 DoOneToMany(source->nick,"KILL",params);
1884 virtual void OnRehash(std::string parameter)
1886 if (parameter != "")
1888 std::deque<std::string> params;
1889 params.push_back(parameter);
1890 DoOneToMany(Srv->GetServerName(),"REHASH",params);
1892 if (Srv->MatchText(Srv->GetServerName(),parameter))
1894 Srv->SendOpers("*** Remote rehash initiated from server \002"+Srv->GetServerName()+"\002.");
1895 Srv->RehashServer();
1898 ReadConfiguration(false);
1901 // note: the protocol does not allow direct umode +o except
1902 // via NICK with 8 params. sending OPERTYPE infers +o modechange
1904 virtual void OnOper(userrec* user, std::string opertype)
1906 if (std::string(user->server) == Srv->GetServerName())
1908 std::deque<std::string> params;
1909 params.push_back(opertype);
1910 DoOneToMany(user->nick,"OPERTYPE",params);
1914 virtual void OnMode(userrec* user, void* dest, int target_type, std::string text)
1916 if (std::string(user->server) == Srv->GetServerName())
1918 if (target_type == TYPE_USER)
1920 userrec* u = (userrec*)dest;
1921 std::deque<std::string> params;
1922 params.push_back(u->nick);
1923 params.push_back(text);
1924 DoOneToMany(user->nick,"MODE",params);
1928 chanrec* c = (chanrec*)dest;
1929 std::deque<std::string> params;
1930 params.push_back(c->name);
1931 params.push_back(text);
1932 DoOneToMany(user->nick,"MODE",params);
1937 virtual void ProtoSendMode(void* opaque, int target_type, void* target, std::string modeline)
1939 TreeSocket* s = (TreeSocket*)opaque;
1942 if (target_type == TYPE_USER)
1944 userrec* u = (userrec*)target;
1945 s->WriteLine(":"+Srv->GetServerName()+" FMODE "+u->nick+" "+modeline);
1949 chanrec* c = (chanrec*)target;
1950 s->WriteLine(":"+Srv->GetServerName()+" FMODE "+c->name+" "+modeline);
1955 virtual ~ModuleSpanningTree()
1960 virtual Version GetVersion()
1962 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
1967 class ModuleSpanningTreeFactory : public ModuleFactory
1970 ModuleSpanningTreeFactory()
1974 ~ModuleSpanningTreeFactory()
1978 virtual Module * CreateModule()
1980 TreeProtocolModule = new ModuleSpanningTree;
1981 return TreeProtocolModule;
1987 extern "C" void * init_module( void )
1989 return new ModuleSpanningTreeFactory;