1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 /** If you make a change which breaks the protocol, increment this.
21 * If you completely change the protocol, completely change the number.
23 * IMPORTANT: If you make changes, document your changes here, without fail:
24 * http://www.inspircd.org/wiki/List_of_protocol_changes_between_versions
26 * Failure to document your protocol changes will result in a painfully
27 * painful death by pain. You have been warned.
29 const long ProtocolVersion = 1105;
31 /** Forward declarations
35 class SpanningTreeUtilities;
37 class CacheRefreshTimer;
41 /** This is the main class for the spanningtree module
43 class ModuleSpanningTree : public Module
47 unsigned int max_local;
48 unsigned int max_global;
49 cmd_rconnect* command_rconnect;
50 cmd_rsquit* command_rsquit;
51 SpanningTreeUtilities* Utils;
54 /** Timer for clock syncs
56 TimeSyncTimer *SyncTimer;
58 CacheRefreshTimer *RefreshTimer;
62 ModuleSpanningTree(InspIRCd* Me);
66 void ShowLinks(TreeServer* Current, userrec* user, int hops);
68 /** Counts local servers
70 int CountLocalServs();
72 /** Counts local and remote servers
76 /** Handle LINKS command
78 void HandleLinks(const char** parameters, int pcnt, userrec* user);
80 /** Handle LUSERS command
82 void HandleLusers(const char** parameters, int pcnt, userrec* user);
84 /** Show MAP output to a user (recursive)
86 void ShowMap(TreeServer* Current, userrec* user, int depth, char matrix[128][128], float &totusers, float &totservers);
88 /** Handle remote MOTD
90 int HandleMotd(const char** parameters, int pcnt, userrec* user);
92 /** Handle remote ADMIN
94 int HandleAdmin(const char** parameters, int pcnt, userrec* user);
96 /** Handle remote STATS
98 int HandleStats(const char** parameters, int pcnt, userrec* user);
100 /** Handle MAP command
102 void HandleMap(const char** parameters, int pcnt, userrec* user);
106 int HandleSquit(const char** parameters, int pcnt, userrec* user, bool remote=false);
110 int HandleTime(const char** parameters, int pcnt, userrec* user);
112 /** Handle remote WHOIS
114 int HandleRemoteWhois(const char** parameters, int pcnt, userrec* user);
116 /** Handle remote MODULES
118 int HandleModules(const char** parameters, int pcnt, userrec* user);
120 /** Ping all local servers
122 void DoPingChecks(time_t curtime);
124 /** Connect a server locally
126 void ConnectServer(Link* x);
128 /** Check if any servers are due to be autoconnected
130 void AutoConnectServers(time_t curtime);
132 /** Handle remote VERSON
134 int HandleVersion(const char** parameters, int pcnt, userrec* user);
138 int HandleConnect(const char** parameters, int pcnt, userrec* user);
140 /** Send out time sync to all servers
142 void BroadcastTimeSync();
144 /** Returns oper-specific MAP information
146 const std::string MapOperInfo(TreeServer* Current);
148 /** Display a time as a human readable string
150 std::string TimeToStr(time_t secs);
153 ** *** MODULE EVENTS ***
156 virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line);
157 virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line);
158 virtual void OnGetServerDescription(const std::string &servername,std::string &description);
159 virtual void OnUserInvite(userrec* source,userrec* dest,chanrec* channel);
160 virtual void OnPostLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic);
161 virtual void OnWallops(userrec* user, const std::string &text);
162 virtual void OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
163 virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
164 virtual void OnBackgroundTimer(time_t curtime);
165 virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent);
166 virtual void OnChangeHost(userrec* user, const std::string &newhost);
167 virtual void OnChangeName(userrec* user, const std::string &gecos);
168 virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent);
169 virtual void OnUserConnect(userrec* user);
170 virtual void OnUserQuit(userrec* user, const std::string &reason, const std::string &oper_message);
171 virtual void OnUserPostNick(userrec* user, const std::string &oldnick);
172 virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason, bool &silent);
173 virtual void OnRemoteKill(userrec* source, userrec* dest, const std::string &reason);
174 virtual void OnRehash(userrec* user, const std::string ¶meter);
175 virtual void OnOper(userrec* user, const std::string &opertype);
176 void OnLine(userrec* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
177 virtual void OnAddGLine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);
178 virtual void OnAddZLine(long duration, userrec* source, const std::string &reason, const std::string &ipmask);
179 virtual void OnAddQLine(long duration, userrec* source, const std::string &reason, const std::string &nickmask);
180 virtual void OnAddELine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);
181 virtual void OnDelGLine(userrec* source, const std::string &hostmask);
182 virtual void OnDelZLine(userrec* source, const std::string &ipmask);
183 virtual void OnDelQLine(userrec* source, const std::string &nickmask);
184 virtual void OnDelELine(userrec* source, const std::string &hostmask);
185 virtual void OnMode(userrec* user, void* dest, int target_type, const std::string &text);
186 virtual int OnStats(char statschar, userrec* user, string_list &results);
187 virtual void OnSetAway(userrec* user);
188 virtual void OnCancelAway(userrec* user);
189 virtual void ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline);
190 virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata);
191 virtual void OnEvent(Event* event);
192 virtual ~ModuleSpanningTree();
193 virtual Version GetVersion();
194 void Implements(char* List);
195 Priority Prioritize();