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