]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
m_spanningtree Change allocation of ModuleSpanningTree::commands to be physically...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
6  *   Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
7  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
8  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
9  *
10  * This file is part of InspIRCd.  InspIRCd is free software: you can
11  * redistribute it and/or modify it under the terms of the GNU General Public
12  * License as published by the Free Software Foundation, version 2.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23
24 #pragma once
25
26 #include "inspircd.h"
27 #include "event.h"
28 #include "modules/dns.h"
29 #include "servercommand.h"
30 #include "commands.h"
31 #include "protocolinterface.h"
32
33 /** If you make a change which breaks the protocol, increment this.
34  * If you  completely change the protocol, completely change the number.
35  *
36  * IMPORTANT: If you make changes, document your changes here, without fail:
37  * http://wiki.inspircd.org/List_of_protocol_changes_between_versions
38  *
39  * Failure to document your protocol changes will result in a painfully
40  * painful death by pain. You have been warned.
41  */
42 const long ProtocolVersion = 1205;
43 const long MinCompatProtocol = 1202;
44
45 /** Forward declarations
46  */
47 class SpanningTreeUtilities;
48 class CacheRefreshTimer;
49 class TreeServer;
50 class Link;
51 class Autoconnect;
52
53 /** This is the main class for the spanningtree module
54  */
55 class ModuleSpanningTree : public Module
56 {
57         /** Client to server commands, registered in the core
58          */
59         CommandRConnect rconnect;
60         CommandRSQuit rsquit;
61         CommandMap map;
62
63         /** Server to server only commands, not registered in the core
64          */
65         SpanningTreeCommands commands;
66
67         /** Next membership id assigned when a local user joins a channel
68          */
69         Membership::Id currmembid;
70
71         /** The specialized ProtocolInterface that is assigned to ServerInstance->PI on load
72          */
73         SpanningTreeProtocolInterface protocolinterface;
74
75         /** Event provider for our events
76          */
77         Events::ModuleEventProvider eventprov;
78
79  public:
80         dynamic_reference<DNS::Manager> DNS;
81
82         ServerCommandManager CmdManager;
83
84         /** Set to true if inside a spanningtree call, to prevent sending
85          * xlines and other things back to their source
86          */
87         bool loopCall;
88
89         /** Constructor
90          */
91         ModuleSpanningTree();
92         void init() CXX11_OVERRIDE;
93
94         /** Shows /LINKS
95          */
96         void ShowLinks(TreeServer* Current, User* user, int hops);
97
98         /** Handle LINKS command
99          */
100         void HandleLinks(const std::vector<std::string>& parameters, User* user);
101
102         /** Handle SQUIT
103          */
104         ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
105
106         /** Handle remote WHOIS
107          */
108         ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
109
110         /** Connect a server locally
111          */
112         void ConnectServer(Link* x, Autoconnect* y = NULL);
113
114         /** Connect the next autoconnect server
115          */
116         void ConnectServer(Autoconnect* y, bool on_timer);
117
118         /** Check if any servers are due to be autoconnected
119          */
120         void AutoConnectServers(time_t curtime);
121
122         /** Check if any connecting servers should timeout
123          */
124         void DoConnectTimeout(time_t curtime);
125
126         /** Handle remote VERSON
127          */
128         ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
129
130         /** Handle CONNECT
131          */
132         ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
133
134         /** Attempt to send a message to a user
135          */
136         void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
137
138         /** Display a time as a human readable string
139          */
140         static std::string TimeToStr(time_t secs);
141
142         const Events::ModuleEventProvider& GetEventProvider() const { return eventprov; }
143
144         /**
145          ** *** MODULE EVENTS ***
146          **/
147
148         ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE;
149         void OnPostCommand(Command*, const std::vector<std::string>& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE;
150         void OnUserConnect(LocalUser* source) CXX11_OVERRIDE;
151         void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE;
152         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE;
153         void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE;
154         void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE;
155         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts) CXX11_OVERRIDE;
156         void OnChangeHost(User* user, const std::string &newhost) CXX11_OVERRIDE;
157         void OnChangeName(User* user, const std::string &gecos) CXX11_OVERRIDE;
158         void OnChangeIdent(User* user, const std::string &ident) CXX11_OVERRIDE;
159         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts) CXX11_OVERRIDE;
160         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE;
161         void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE;
162         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE;
163         void OnPreRehash(User* user, const std::string &parameter) CXX11_OVERRIDE;
164         void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE;
165         void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE;
166         void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE;
167         void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE;
168         ModResult OnStats(char statschar, User* user, string_list &results) CXX11_OVERRIDE;
169         ModResult OnSetAway(User* user, const std::string &awaymsg) CXX11_OVERRIDE;
170         void OnLoadModule(Module* mod) CXX11_OVERRIDE;
171         void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
172         ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE;
173         void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags, const std::string& output_mode) CXX11_OVERRIDE;
174         CullResult cull();
175         ~ModuleSpanningTree();
176         Version GetVersion() CXX11_OVERRIDE;
177         void Prioritize();
178 };