-/* +------------------------------------+\r * | Inspire Internet Relay Chat Daemon |\r * +------------------------------------+\r *\r * InspIRCd: (C) 2002-2007 InspIRCd Development Team\r * See: http://www.inspircd.org/wiki/index.php/Credits\r *\r * This program is free but copyrighted software; see\r * the file COPYING for details.\r *\r * ---------------------------------------------------\r */\r\r#ifndef __ST_MAIN__\r#define __ST_MAIN__\r\r#include "inspircd.h"\r#include "modules.h"\r\r/** If you make a change which breaks the protocol, increment this.\r * If you completely change the protocol, completely change the number.\r *\r * IMPORTANT: If you make changes, document your changes here, without fail:\r * http://www.inspircd.org/wiki/List_of_protocol_changes_between_versions\r *\r * Failure to document your protocol changes will result in a painfully\r * painful death by pain. You have been warned.\r */\rconst long ProtocolVersion = 1105;\r\r/** Forward declarations\r */\rclass cmd_rconnect;\rclass cmd_rsquit;\rclass SpanningTreeUtilities;\rclass TimeSyncTimer;\rclass CacheRefreshTimer;\rclass TreeServer;\rclass Link;\r\r/** This is the main class for the spanningtree module\r */\rclass ModuleSpanningTree : public Module\r{\r int line;\r int NumServers;\r unsigned int max_local;\r unsigned int max_global;\r cmd_rconnect* command_rconnect;\r cmd_rsquit* command_rsquit;\r SpanningTreeUtilities* Utils;\r\r public:\r /** Timer for clock syncs\r */\r TimeSyncTimer *SyncTimer;\r\r CacheRefreshTimer *RefreshTimer;\r\r /** Constructor\r */\r ModuleSpanningTree(InspIRCd* Me);\r\r /** Shows /LINKS\r */\r void ShowLinks(TreeServer* Current, userrec* user, int hops);\r\r /** Counts local servers\r */\r int CountLocalServs();\r\r /** Counts local and remote servers\r */\r int CountServs();\r\r /** Handle LINKS command\r */\r void HandleLinks(const char** parameters, int pcnt, userrec* user);\r\r /** Handle LUSERS command\r */\r void HandleLusers(const char** parameters, int pcnt, userrec* user);\r\r /** Show MAP output to a user (recursive)\r */\r void ShowMap(TreeServer* Current, userrec* user, int depth, char matrix[128][128], float &totusers, float &totservers);\r\r /** Handle remote MOTD\r */\r int HandleMotd(const char** parameters, int pcnt, userrec* user);\r\r /** Handle remote ADMIN\r */\r int HandleAdmin(const char** parameters, int pcnt, userrec* user);\r\r /** Handle remote STATS\r */\r int HandleStats(const char** parameters, int pcnt, userrec* user);\r\r /** Handle MAP command\r */\r void HandleMap(const char** parameters, int pcnt, userrec* user);\r\r /** Handle SQUIT\r */\r int HandleSquit(const char** parameters, int pcnt, userrec* user);\r\r /** Handle TIME\r */\r int HandleTime(const char** parameters, int pcnt, userrec* user);\r\r /** Handle remote WHOIS\r */\r int HandleRemoteWhois(const char** parameters, int pcnt, userrec* user);\r\r /** Handle remote MODULES\r */\r int HandleModules(const char** parameters, int pcnt, userrec* user);\r\r /** Ping all local servers\r */\r void DoPingChecks(time_t curtime);\r\r /** Connect a server locally\r */\r void ConnectServer(Link* x);\r\r /** Check if any servers are due to be autoconnected\r */\r void AutoConnectServers(time_t curtime);\r\r /** Handle remote VERSON\r */\r int HandleVersion(const char** parameters, int pcnt, userrec* user);\r\r /** Handle CONNECT\r */\r int HandleConnect(const char** parameters, int pcnt, userrec* user);\r\r /** Send out time sync to all servers\r */\r void BroadcastTimeSync();\r\r /** Returns oper-specific MAP information\r */\r const std::string MapOperInfo(TreeServer* Current);\r\r /** Display a time as a human readable string\r */\r std::string TimeToStr(time_t secs);\r\r /**\r ** *** MODULE EVENTS ***\r **/\r\r virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line);\r virtual void OnPostCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, CmdResult result, const std::string &original_line);\r virtual void OnGetServerDescription(const std::string &servername,std::string &description);\r virtual void OnUserInvite(userrec* source,userrec* dest,chanrec* channel);\r virtual void OnPostLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic);\r virtual void OnWallops(userrec* user, const std::string &text);\r virtual void OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);\r virtual void OnUserMessage(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);\r virtual void OnBackgroundTimer(time_t curtime);\r virtual void OnUserJoin(userrec* user, chanrec* channel, bool &silent);\r virtual void OnChangeHost(userrec* user, const std::string &newhost);\r virtual void OnChangeName(userrec* user, const std::string &gecos);\r virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partmessage, bool &silent);\r virtual void OnUserConnect(userrec* user);\r virtual void OnUserQuit(userrec* user, const std::string &reason, const std::string &oper_message);\r virtual void OnUserPostNick(userrec* user, const std::string &oldnick);\r virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason, bool &silent);\r virtual void OnRemoteKill(userrec* source, userrec* dest, const std::string &reason, const std::string &operreason);\r virtual void OnRehash(userrec* user, const std::string ¶meter);\r virtual void OnOper(userrec* user, const std::string &opertype);\r void OnLine(userrec* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);\r virtual void OnAddGLine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);\r virtual void OnAddZLine(long duration, userrec* source, const std::string &reason, const std::string &ipmask);\r virtual void OnAddQLine(long duration, userrec* source, const std::string &reason, const std::string &nickmask);\r virtual void OnAddELine(long duration, userrec* source, const std::string &reason, const std::string &hostmask);\r virtual void OnDelGLine(userrec* source, const std::string &hostmask);\r virtual void OnDelZLine(userrec* source, const std::string &ipmask);\r virtual void OnDelQLine(userrec* source, const std::string &nickmask);\r virtual void OnDelELine(userrec* source, const std::string &hostmask);\r virtual void OnMode(userrec* user, void* dest, int target_type, const std::string &text);\r virtual int OnStats(char statschar, userrec* user, string_list &results);\r virtual void OnSetAway(userrec* user);\r virtual void OnCancelAway(userrec* user);\r virtual void ProtoSendMode(void* opaque, int target_type, void* target, const std::string &modeline);\r virtual void ProtoSendMetaData(void* opaque, int target_type, void* target, const std::string &extname, const std::string &extdata);\r virtual void OnEvent(Event* event);\r virtual ~ModuleSpanningTree();\r virtual Version GetVersion();\r void Implements(char* List);\r Priority Prioritize();\r};\r\r#endif\r
\ No newline at end of file
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#ifndef __ST_MAIN__
+#define __ST_MAIN__
+
+#include "inspircd.h"
+#include <stdarg.h>
+
+/** If you make a change which breaks the protocol, increment this.
+ * If you completely change the protocol, completely change the number.
+ *
+ * IMPORTANT: If you make changes, document your changes here, without fail:
+ * http://wiki.inspircd.org/List_of_protocol_changes_between_versions
+ *
+ * Failure to document your protocol changes will result in a painfully
+ * painful death by pain. You have been warned.
+ */
+const long ProtocolVersion = 1202;
+const long MinCompatProtocol = 1201;
+
+/** Forward declarations
+ */
+class CommandRConnect;
+class CommandRSQuit;
+class CommandSVSJoin;
+class CommandSVSPart;
+class CommandSVSNick;
+class SpanningTreeUtilities;
+class CacheRefreshTimer;
+class TreeServer;
+class Link;
+class Autoconnect;
+
+/** This is the main class for the spanningtree module
+ */
+class ModuleSpanningTree : public Module
+{
+ CommandRConnect* command_rconnect;
+ CommandRSQuit* command_rsquit;
+ CommandSVSJoin* command_svsjoin;
+ CommandSVSPart* command_svspart;
+ CommandSVSNick* command_svsnick;
+ SpanningTreeUtilities* Utils;
+
+ void RedoConfig(Module* mod);
+
+ public:
+ CacheRefreshTimer *RefreshTimer;
+ /** Set to true if inside a spanningtree call, to prevent sending
+ * xlines and other things back to their source
+ */
+ bool loopCall;
+
+ /** Constructor
+ */
+ ModuleSpanningTree();
+
+ /** Shows /LINKS
+ */
+ void ShowLinks(TreeServer* Current, User* user, int hops);
+
+ /** Counts local and remote servers
+ */
+ int CountServs();
+
+ /** Handle LINKS command
+ */
+ void HandleLinks(const std::vector<std::string>& parameters, User* user);
+
+ /** Show MAP output to a user (recursive)
+ */
+ void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
+
+ /** Handle remote MOTD
+ */
+ ModResult HandleMotd(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle remote ADMIN
+ */
+ ModResult HandleAdmin(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle remote STATS
+ */
+ ModResult HandleStats(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle MAP command
+ */
+ bool HandleMap(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle SQUIT
+ */
+ ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle TIME
+ */
+ ModResult HandleTime(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle remote WHOIS
+ */
+ ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
+
+ /** Ping all local servers
+ */
+ void DoPingChecks(time_t curtime);
+
+ /** Connect a server locally
+ */
+ void ConnectServer(Link* x, Autoconnect* y = NULL);
+
+ /** Connect the next autoconnect server
+ */
+ void ConnectServer(Autoconnect* y, bool on_timer);
+
+ /** Check if any servers are due to be autoconnected
+ */
+ void AutoConnectServers(time_t curtime);
+
+ /** Check if any connecting servers should timeout
+ */
+ void DoConnectTimeout(time_t curtime);
+
+ /** Handle remote VERSON
+ */
+ ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle CONNECT
+ */
+ ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
+
+ /** Attempt to send a message to a user
+ */
+ void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
+
+ /** Returns oper-specific MAP information
+ */
+ const std::string MapOperInfo(TreeServer* Current);
+
+ /** Display a time as a human readable string
+ */
+ std::string TimeToStr(time_t secs);
+
+ /**
+ ** *** MODULE EVENTS ***
+ **/
+
+ ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User *user, bool validated, const std::string &original_line);
+ void OnPostCommand(const std::string &command, const std::vector<std::string>& parameters, User *user, CmdResult result, const std::string &original_line);
+ void OnGetServerDescription(const std::string &servername,std::string &description);
+ void OnUserConnect(LocalUser* source);
+ void OnUserInvite(User* source,User* dest,Channel* channel, time_t);
+ void OnPostTopicChange(User* user, Channel* chan, const std::string &topic);
+ void OnWallops(User* user, const std::string &text);
+ void OnUserNotice(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
+ void OnUserMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list);
+ void OnBackgroundTimer(time_t curtime);
+ void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts);
+ void OnChangeHost(User* user, const std::string &newhost);
+ void OnChangeName(User* user, const std::string &gecos);
+ void OnChangeIdent(User* user, const std::string &ident);
+ void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts);
+ void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message);
+ void OnUserPostNick(User* user, const std::string &oldnick);
+ void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts);
+ void OnRemoteKill(User* source, User* dest, const std::string &reason, const std::string &operreason);
+ void OnPreRehash(User* user, const std::string ¶meter);
+ void OnRehash(User* user);
+ void OnOper(User* user, const std::string &opertype);
+ void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
+ void OnAddLine(User *u, XLine *x);
+ void OnDelLine(User *u, XLine *x);
+ void OnMode(User* user, void* dest, int target_type, const std::vector<std::string> &text, const std::vector<TranslateType> &translate);
+ ModResult OnStats(char statschar, User* user, string_list &results);
+ ModResult OnSetAway(User* user, const std::string &awaymsg);
+ void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
+ void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
+ void OnLoadModule(Module* mod);
+ void OnUnloadModule(Module* mod);
+ ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
+ CullResult cull();
+ ~ModuleSpanningTree();
+ Version GetVersion();
+ void Prioritize();
+};
+
+#endif