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 SpanningTreeCommands;
35 class SpanningTreeUtilities;
36 class CacheRefreshTimer;
41 /** This is the main class for the spanningtree module
43 class ModuleSpanningTree : public Module
45 SpanningTreeCommands* commands;
46 void RedoConfig(Module* mod);
49 SpanningTreeUtilities* Utils;
51 CacheRefreshTimer *RefreshTimer;
52 /** Set to true if inside a spanningtree call, to prevent sending
53 * xlines and other things back to their source
64 void ShowLinks(TreeServer* Current, User* user, int hops);
66 /** Counts local and remote servers
70 /** Handle LINKS command
72 void HandleLinks(const std::vector<std::string>& parameters, User* user);
74 /** Show MAP output to a user (recursive)
76 void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
78 /** Handle MAP command
80 bool HandleMap(const std::vector<std::string>& parameters, User* user);
84 ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
86 /** Handle remote WHOIS
88 ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
90 /** Ping all local servers
92 void DoPingChecks(time_t curtime);
94 /** Connect a server locally
96 void ConnectServer(Link* x, Autoconnect* y = NULL);
98 /** Connect the next autoconnect server
100 void ConnectServer(Autoconnect* y, bool on_timer);
102 /** Check if any servers are due to be autoconnected
104 void AutoConnectServers(time_t curtime);
106 /** Check if any connecting servers should timeout
108 void DoConnectTimeout(time_t curtime);
110 /** Handle remote VERSON
112 ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
116 ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
118 /** Attempt to send a message to a user
120 void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
122 /** Returns oper-specific MAP information
124 const std::string MapOperInfo(TreeServer* Current);
126 /** Display a time as a human readable string
128 std::string TimeToStr(time_t secs);
131 ** *** MODULE EVENTS ***
134 ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line);
135 void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, LocalUser *user, CmdResult result, const std::string &original_line);
136 void OnGetServerDescription(const std::string &servername,std::string &description);
137 void OnUserConnect(LocalUser* source);
138 void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
139 void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
140 void OnWallops(User* user, const std::string &text);
141 void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
142 void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
143 void OnBackgroundTimer(time_t curtime);
144 void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts);
145 void OnChangeHost(User* user, const std::string &newhost);
146 void OnChangeName(User* user, const std::string &gecos);
147 void OnChangeIdent(User* user, const std::string &ident);
148 void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts);
149 void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
150 void OnUserPostNick(User* user, const std::string &oldnick);
151 void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts);
152 void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
153 void OnPreRehash(User* user, const std::string ¶meter);
154 void OnRehash(User* user);
155 void OnOper(User* user, const std::string &opertype);
156 void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
157 void OnAddLine(User *u, XLine *x);
158 void OnDelLine(User *u, XLine *x);
159 void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
160 ModResult OnStats(char statschar, User* user, string_list &results);
161 ModResult OnSetAway(User* user, const std::string &awaymsg);
162 void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
163 void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
164 void OnLoadModule(Module* mod);
165 void OnUnloadModule(Module* mod);
166 ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
168 ~ModuleSpanningTree();
169 Version GetVersion();