-/* +------------------------------------+\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
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ * Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
+ * Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
+ * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#pragma once
+
+#include "inspircd.h"
+#include "event.h"
+#include "modules/dns.h"
+#include "servercommand.h"
+#include "commands.h"
+#include "protocolinterface.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 = 1205;
+const long MinCompatProtocol = 1202;
+
+/** Forward declarations
+ */
+class SpanningTreeUtilities;
+class CacheRefreshTimer;
+class TreeServer;
+class Link;
+class Autoconnect;
+
+/** This is the main class for the spanningtree module
+ */
+class ModuleSpanningTree : public Module
+{
+ /** Client to server commands, registered in the core
+ */
+ CommandRConnect rconnect;
+ CommandRSQuit rsquit;
+ CommandMap map;
+
+ /** Server to server only commands, not registered in the core
+ */
+ SpanningTreeCommands commands;
+
+ /** Next membership id assigned when a local user joins a channel
+ */
+ Membership::Id currmembid;
+
+ /** The specialized ProtocolInterface that is assigned to ServerInstance->PI on load
+ */
+ SpanningTreeProtocolInterface protocolinterface;
+
+ /** Event provider for our events
+ */
+ Events::ModuleEventProvider eventprov;
+
+ public:
+ dynamic_reference<DNS::Manager> DNS;
+
+ ServerCommandManager CmdManager;
+
+ /** Set to true if inside a spanningtree call, to prevent sending
+ * xlines and other things back to their source
+ */
+ bool loopCall;
+
+ /** Constructor
+ */
+ ModuleSpanningTree();
+ void init() CXX11_OVERRIDE;
+
+ /** Shows /LINKS
+ */
+ void ShowLinks(TreeServer* Current, User* user, int hops);
+
+ /** Handle LINKS command
+ */
+ void HandleLinks(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle SQUIT
+ */
+ ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
+
+ /** Handle remote WHOIS
+ */
+ ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
+
+ /** 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);
+
+ /** Display a time as a human readable string
+ */
+ static std::string TimeToStr(time_t secs);
+
+ const Events::ModuleEventProvider& GetEventProvider() const { return eventprov; }
+
+ /**
+ ** *** MODULE EVENTS ***
+ **/
+
+ ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE;
+ void OnPostCommand(Command*, const std::vector<std::string>& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE;
+ void OnUserConnect(LocalUser* source) CXX11_OVERRIDE;
+ void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE;
+ ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) CXX11_OVERRIDE;
+ void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE;
+ void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE;
+ void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE;
+ void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts) CXX11_OVERRIDE;
+ void OnChangeHost(User* user, const std::string &newhost) CXX11_OVERRIDE;
+ void OnChangeName(User* user, const std::string &gecos) CXX11_OVERRIDE;
+ void OnChangeIdent(User* user, const std::string &ident) CXX11_OVERRIDE;
+ void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts) CXX11_OVERRIDE;
+ void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE;
+ void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE;
+ void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE;
+ void OnPreRehash(User* user, const std::string ¶meter) CXX11_OVERRIDE;
+ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE;
+ void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE;
+ void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE;
+ void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE;
+ ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE;
+ ModResult OnSetAway(User* user, const std::string &awaymsg) CXX11_OVERRIDE;
+ void OnLoadModule(Module* mod) CXX11_OVERRIDE;
+ void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
+ ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE;
+ void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags, const std::string& output_mode) CXX11_OVERRIDE;
+ CullResult cull();
+ ~ModuleSpanningTree();
+ Version GetVersion() CXX11_OVERRIDE;
+ void Prioritize();
+};