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 = 1201;
30 const long MinCompatProtocol = 1201;
32 /** Forward declarations
34 class CommandRConnect;
36 class SpanningTreeUtilities;
37 class CacheRefreshTimer;
41 /** This is the main class for the spanningtree module
43 class ModuleSpanningTree : public Module
45 unsigned int max_local;
46 unsigned int max_global;
47 CommandRConnect* command_rconnect;
48 CommandRSQuit* command_rsquit;
49 SpanningTreeUtilities* Utils;
51 void RedoConfig(Module* mod, const std::string &name);
54 CacheRefreshTimer *RefreshTimer;
55 /** Set to true if inside a spanningtree call, to prevent sending
56 * xlines and other things back to their source
62 ModuleSpanningTree(InspIRCd* Me);
66 void ShowLinks(TreeServer* Current, User* user, int hops);
68 /** Counts local servers
70 int CountLocalServs();
72 /** Counts local and remote servers
76 /** Handle LINKS command
78 void HandleLinks(const std::vector<std::string>& parameters, User* user);
80 /** Handle LUSERS command
82 void HandleLusers(const std::vector<std::string>& parameters, User* user);
84 /** Show MAP output to a user (recursive)
86 void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
88 /** Handle remote MOTD
90 int HandleMotd(const std::vector<std::string>& parameters, User* user);
92 /** Handle remote ADMIN
94 int HandleAdmin(const std::vector<std::string>& parameters, User* user);
96 /** Handle remote STATS
98 int HandleStats(const std::vector<std::string>& parameters, User* user);
100 /** Handle MAP command
102 int HandleMap(const std::vector<std::string>& parameters, User* user);
106 int HandleSquit(const std::vector<std::string>& parameters, User* user);
110 int HandleTime(const std::vector<std::string>& parameters, User* user);
112 /** Handle remote WHOIS
114 int HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
116 /** Handle remote MODULES
118 int HandleModules(const std::vector<std::string>& parameters, User* 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 /** Check if any connecting servers should timeout
134 void DoConnectTimeout(time_t curtime);
136 /** Handle remote VERSON
138 int HandleVersion(const std::vector<std::string>& parameters, User* user);
142 int HandleConnect(const std::vector<std::string>& parameters, User* user);
144 /** Attempt to send a message to a user
146 void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
148 /** Returns oper-specific MAP information
150 const std::string MapOperInfo(TreeServer* Current);
152 /** Display a time as a human readable string
154 std::string TimeToStr(time_t secs);
157 ** *** MODULE EVENTS ***
160 virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
161 virtual void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
162 virtual void OnGetServerDescription(const std::string &servername,std::string &description);
163 virtual void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
164 virtual void OnPostLocalTopicChange(User* user, Channel* chan, const std::string &topic);
165 virtual void OnWallops(User* user, const std::string &text);
166 virtual void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
167 virtual void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
168 virtual void OnBackgroundTimer(time_t curtime);
169 virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent);
170 virtual int OnChangeLocalUserHost(User* user, const std::string &newhost);
171 virtual void OnChangeName(User* user, const std::string &gecos);
172 virtual void OnUserPart(User* user, Channel* channel, std::string &partmessage, bool &silent);
173 virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
174 virtual void OnUserPostNick(User* user, const std::string &oldnick);
175 virtual void OnUserKick(User* source, User* user, Channel* chan, const std::string &reason, bool &silent);
176 virtual void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
177 virtual void OnPreRehash(User* user, const std::string ¶meter);
178 virtual void OnRehash(User* user);
179 virtual void OnOper(User* user, const std::string &opertype);
180 void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
181 virtual void OnAddLine(User *u, XLine *x);
182 virtual void OnDelLine(User *u, XLine *x);
183 virtual void OnMode(User* user, void* dest, int target_type, const std::deque<std::string> &text, const std::deque<TranslateType> &translate);
184 virtual int OnStats(char statschar, User* user, string_list &results);
185 virtual int OnSetAway(User* user, const std::string &awaymsg);
186 virtual void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::deque<std::string> &modeline, const std::deque<TranslateType> &translate);
187 virtual void ProtoSendMetaData(void* opaque, TargetTypeFlags target_type, void* target, const std::string &extname, const std::string &extdata);
188 virtual void OnEvent(Event* event);
189 virtual void OnLoadModule(Module* mod,const std::string &name);
190 virtual void OnUnloadModule(Module* mod,const std::string &name);
191 virtual ~ModuleSpanningTree();
192 virtual Version GetVersion();