1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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://wiki.inspircd.org/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 = 1202;
30 const long MinCompatProtocol = 1201;
32 /** Forward declarations
34 class CommandRConnect;
39 class SpanningTreeUtilities;
40 class CacheRefreshTimer;
45 /** This is the main class for the spanningtree module
47 class ModuleSpanningTree : public Module
49 CommandRConnect* command_rconnect;
50 CommandRSQuit* command_rsquit;
51 CommandSVSJoin* command_svsjoin;
52 CommandSVSPart* command_svspart;
53 CommandSVSNick* command_svsnick;
54 SpanningTreeUtilities* Utils;
56 void RedoConfig(Module* mod);
59 CacheRefreshTimer *RefreshTimer;
60 /** Set to true if inside a spanningtree call, to prevent sending
61 * xlines and other things back to their source
71 void ShowLinks(TreeServer* Current, User* user, int hops);
73 /** Counts local and remote servers
77 /** Handle LINKS command
79 void HandleLinks(const std::vector<std::string>& parameters, User* user);
81 /** Show MAP output to a user (recursive)
83 void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
85 /** Handle remote MOTD
87 ModResult HandleMotd(const std::vector<std::string>& parameters, User* user);
89 /** Handle remote ADMIN
91 ModResult HandleAdmin(const std::vector<std::string>& parameters, User* user);
93 /** Handle remote STATS
95 ModResult HandleStats(const std::vector<std::string>& parameters, User* user);
97 /** Handle MAP command
99 bool HandleMap(const std::vector<std::string>& parameters, User* user);
103 ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
107 ModResult HandleTime(const std::vector<std::string>& parameters, User* user);
109 /** Handle remote WHOIS
111 ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
113 /** Ping all local servers
115 void DoPingChecks(time_t curtime);
117 /** Connect a server locally
119 void ConnectServer(Link* x, Autoconnect* y = NULL);
121 /** Connect the next autoconnect server
123 void ConnectServer(Autoconnect* y, bool on_timer);
125 /** Check if any servers are due to be autoconnected
127 void AutoConnectServers(time_t curtime);
129 /** Check if any connecting servers should timeout
131 void DoConnectTimeout(time_t curtime);
133 /** Handle remote VERSON
135 ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
139 ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
141 /** Attempt to send a message to a user
143 void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
145 /** Returns oper-specific MAP information
147 const std::string MapOperInfo(TreeServer* Current);
149 /** Display a time as a human readable string
151 std::string TimeToStr(time_t secs);
154 ** *** MODULE EVENTS ***
157 ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
158 void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
159 void OnGetServerDescription(const std::string &servername,std::string &description);
160 void OnUserConnect(LocalUser* source);
161 void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
162 void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
163 void OnWallops(User* user, const std::string &text);
164 void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
165 void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
166 void OnBackgroundTimer(time_t curtime);
167 void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts);
168 void OnChangeHost(User* user, const std::string &newhost);
169 void OnChangeName(User* user, const std::string &gecos);
170 void OnChangeIdent(User* user, const std::string &ident);
171 void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts);
172 void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
173 void OnUserPostNick(User* user, const std::string &oldnick);
174 void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts);
175 void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
176 void OnPreRehash(User* user, const std::string ¶meter);
177 void OnRehash(User* user);
178 void OnOper(User* user, const std::string &opertype);
179 void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
180 void OnAddLine(User *u, XLine *x);
181 void OnDelLine(User *u, XLine *x);
182 void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
183 ModResult OnStats(char statschar, User* user, string_list &results);
184 ModResult OnSetAway(User* user, const std::string &awaymsg);
185 void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
186 void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
187 void OnLoadModule(Module* mod);
188 void OnUnloadModule(Module* mod);
189 ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
191 ~ModuleSpanningTree();
192 Version GetVersion();