1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 = 1201;
31 /** Forward declarations
35 class SpanningTreeUtilities;
36 class CacheRefreshTimer;
40 /** This is the main class for the spanningtree module
42 class ModuleSpanningTree : public Module
46 unsigned int max_local;
47 unsigned int max_global;
48 cmd_rconnect* command_rconnect;
49 cmd_rsquit* command_rsquit;
50 SpanningTreeUtilities* Utils;
53 CacheRefreshTimer *RefreshTimer;
57 ModuleSpanningTree(InspIRCd* Me);
61 void ShowLinks(TreeServer* Current, User* user, int hops);
63 /** Counts local servers
65 int CountLocalServs();
67 /** Counts local and remote servers
71 /** Handle LINKS command
73 void HandleLinks(const std::vector<std::string>& parameters, User* user);
75 /** Handle LUSERS command
77 void HandleLusers(const std::vector<std::string>& parameters, User* user);
79 /** Show MAP output to a user (recursive)
81 void ShowMap(TreeServer* Current, User* user, int depth, char matrix[250][250], float &totusers, float &totservers);
83 /** Handle remote MOTD
85 int HandleMotd(const std::vector<std::string>& parameters, User* user);
87 /** Handle remote ADMIN
89 int HandleAdmin(const std::vector<std::string>& parameters, User* user);
91 /** Handle remote STATS
93 int HandleStats(const std::vector<std::string>& parameters, User* user);
95 /** Handle MAP command
97 int HandleMap(const std::vector<std::string>& parameters, User* user);
101 int HandleSquit(const std::vector<std::string>& parameters, User* user);
105 int HandleTime(const std::vector<std::string>& parameters, User* user);
107 /** Handle remote WHOIS
109 int HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
111 /** Handle remote MODULES
113 int HandleModules(const std::vector<std::string>& parameters, User* user);
115 /** Ping all local servers
117 void DoPingChecks(time_t curtime);
119 /** Connect a server locally
121 void ConnectServer(Link* x);
123 /** Check if any servers are due to be autoconnected
125 void AutoConnectServers(time_t curtime);
127 /** Check if any connecting servers should timeout
129 void DoConnectTimeout(time_t curtime);
131 /** Handle remote VERSON
133 int HandleVersion(const std::vector<std::string>& parameters, User* user);
137 int HandleConnect(const std::vector<std::string>& parameters, User* user);
139 /** Attempt to send a message to a user
141 void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
143 /** Returns oper-specific MAP information
145 const std::string MapOperInfo(TreeServer* Current);
147 /** Display a time as a human readable string
149 std::string TimeToStr(time_t secs);
152 ** *** MODULE EVENTS ***
155 virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
156 virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
157 virtual void OnGetServerDescription(const std::string &servername,std::string &description);
158 virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
159 virtual void OnPostLocalTopicChange(User* user, Channel* chan, const std::string &topic);
160 virtual void OnWallops(User* user, const std::string &text);
161 virtual void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
162 virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
163 virtual void OnBackgroundTimer(time_t curtime);
164 virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
165 virtual void OnChangeHost(User* user, const std::string &newhost);
166 virtual void OnChangeName(User* user, const std::string &gecos);
167 virtual void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
168 virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
169 virtual void OnUserPostNick(User* user, const std::string &oldnick);
170 virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent);
171 virtual void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
172 virtual void OnRehash(User* user, const std::string ¶meter);
173 virtual void OnOper(User* user, const std::string &opertype);
174 void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
175 virtual void OnAddLine(User *u, XLine *x);
176 virtual void OnDelLine(User *u, XLine *x);
177 virtual void OnMode(User* user, void* dest, int target_type, const std::string &text);
178 virtual int OnStats(char statschar, User* user, string_list &results);
179 virtual int OnSetAway(User* user, const std::string &awaymsg);
180 virtual void ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline);
181 virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata);
182 virtual void OnEvent(Event* event);
183 virtual ~ModuleSpanningTree();
184 virtual Version GetVersion();