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 * ---------------------------------------------------
21 /** If you make a change which breaks the protocol, increment this.
22 * If you completely change the protocol, completely change the number.
24 * IMPORTANT: If you make changes, document your changes here, without fail:
25 * http://www.inspircd.org/wiki/List_of_protocol_changes_between_versions
27 * Failure to document your protocol changes will result in a painfully
28 * painful death by pain. You have been warned.
30 const long ProtocolVersion = 1200;
32 /** Forward declarations
36 class SpanningTreeUtilities;
38 class CacheRefreshTimer;
42 /** This is the main class for the spanningtree module
44 class ModuleSpanningTree : public Module
48 unsigned int max_local;
49 unsigned int max_global;
50 cmd_rconnect* command_rconnect;
51 cmd_rsquit* command_rsquit;
52 SpanningTreeUtilities* Utils;
55 /** Timer for clock syncs
57 TimeSyncTimer *SyncTimer;
59 CacheRefreshTimer *RefreshTimer;
63 ModuleSpanningTree(InspIRCd* Me);
67 void ShowLinks(TreeServer* Current, userrec* user, int hops);
69 /** Counts local servers
71 int CountLocalServs();
73 /** Counts local and remote servers
77 /** Handle LINKS command
79 void HandleLinks(const char** parameters, int pcnt, userrec* user);
81 /** Handle LUSERS command
83 void HandleLusers(const char** parameters, int pcnt, userrec* user);
85 /** Show MAP output to a user (recursive)
87 void ShowMap(TreeServer* Current, userrec* user, int depth, char matrix[128][128], float &totusers, float &totservers);
89 /** Handle remote MOTD
91 int HandleMotd(const char** parameters, int pcnt, userrec* user);
93 /** Handle remote ADMIN
95 int HandleAdmin(const char** parameters, int pcnt, userrec* user);
97 /** Handle remote STATS
99 int HandleStats(const char** parameters, int pcnt, userrec* user);
101 /** Handle MAP command
103 void HandleMap(const char** parameters, int pcnt, userrec* user);
107 int HandleSquit(const char** parameters, int pcnt, userrec* user);
111 int HandleTime(const char** parameters, int pcnt, userrec* user);
113 /** Handle remote WHOIS
115 int HandleRemoteWhois(const char** parameters, int pcnt, userrec* user);
117 /** Handle remote MODULES
119 int HandleModules(const char** parameters, int pcnt, userrec* user);
121 /** Ping all local servers
123 void DoPingChecks(time_t curtime);
125 /** Connect a server locally
127 void ConnectServer(Link* x);
129 /** Check if any servers are due to be autoconnected
131 void AutoConnectServers(time_t curtime);
133 /** Handle remote VERSON
135 int HandleVersion(const char** parameters, int pcnt, userrec* user);
139 int HandleConnect(const char** parameters, int pcnt, userrec* user);
141 /** Send out time sync to all servers
143 void BroadcastTimeSync();
145 /** Attempt to send a message to a user
147 void RemoteMessage(userrec* user, const char* format, ...);
149 /** Returns oper-specific MAP information
151 const std::string MapOperInfo(TreeServer* Current);
153 /** Display a time as a human readable string
155 std::string TimeToStr(time_t secs);
158 ** *** MODULE EVENTS ***
161 virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line);
162 virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line);
163 virtual void OnGetServerDescription(const std::string &servername,std::string &description);
164 virtual void OnUserInvite(userrec* source,userrec* dest,chanrec* channel);
165 virtual void OnPostLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic);
166 virtual void OnWallops(userrec* user, const std::string &text);
167 virtual void OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
168 virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
169 virtual void OnBackgroundTimer(time_t curtime);
170 virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent);
171 virtual void OnChangeHost(userrec* user, const std::string &newhost);
172 virtual void OnChangeName(userrec* user, const std::string &gecos);
173 virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent);
174 virtual void OnUserConnect(userrec* user);
175 virtual void OnUserQuit(userrec* user, const std::string &reason, const std::string &oper_message);
176 virtual void OnUserPostNick(userrec* user, const std::string &oldnick);
177 virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason, bool &silent);
178 virtual void OnRemoteKill(userrec* source, userrec* dest, const std::string &reason, const std::string &operreason);
179 virtual void OnRehash(userrec* user, const std::string ¶meter);
180 virtual void OnOper(userrec* user, const std::string &opertype);
181 void OnLine(userrec* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
182 virtual void OnAddGLine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);
183 virtual void OnAddZLine(long duration, userrec* source, const std::string &reason, const std::string &ipmask);
184 virtual void OnAddQLine(long duration, userrec* source, const std::string &reason, const std::string &nickmask);
185 virtual void OnAddELine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);
186 virtual void OnDelGLine(userrec* source, const std::string &hostmask);
187 virtual void OnDelZLine(userrec* source, const std::string &ipmask);
188 virtual void OnDelQLine(userrec* source, const std::string &nickmask);
189 virtual void OnDelELine(userrec* source, const std::string &hostmask);
190 virtual void OnMode(userrec* user, void* dest, int target_type, const std::string &text);
191 virtual int OnStats(char statschar, userrec* user, string_list &results);
192 virtual void OnSetAway(userrec* user);
193 virtual void OnCancelAway(userrec* user);
194 virtual void ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline);
195 virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata);
196 virtual void OnEvent(Event* event);
197 virtual ~ModuleSpanningTree();
198 virtual Version GetVersion();
199 void Implements(char* List);
200 Priority Prioritize();