]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
Replace all abstract usages of his/he/her with they/their/it.
[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 "modules/ssl.h"
30 #include "modules/stats.h"
31 #include "servercommand.h"
32 #include "commands.h"
33 #include "protocolinterface.h"
34
35 /** An enumeration of all known protocol versions.
36  *
37  * If you introduce new protocol versions please document them here:
38  * https://docs.inspircd.org/spanningtree/changes
39  */
40 enum ProtocolVersion
41 {
42         /** The linking protocol version introduced in InspIRCd v2.0. */
43         PROTO_INSPIRCD_20 = 1202,
44
45         /** The linking protocol version introduced in InspIRCd v2.1 alpha 0. */
46         PROTO_INSPIRCD_21_A0 = 1203,
47
48         /** The linking protocol version introduced in InspIRCd v2.1 beta 2. */
49         PROTO_INSPIRCD_21_B2 = 1204,
50
51         /** The linking protocol version introduced in InspIRCd v3.0. */
52         PROTO_INSPIRCD_30 = 1205,
53
54         /** The oldest version of the protocol that we support. */
55         PROTO_OLDEST = PROTO_INSPIRCD_20,
56
57         /** The newest version of the protocol that we support. */
58         PROTO_NEWEST = PROTO_INSPIRCD_30
59 };
60
61 /** Forward declarations
62  */
63 class SpanningTreeUtilities;
64 class CacheRefreshTimer;
65 class TreeServer;
66 class Link;
67 class Autoconnect;
68
69 /** This is the main class for the spanningtree module
70  */
71 class ModuleSpanningTree
72         : public Module
73         , public Away::EventListener
74         , public Stats::EventListener
75 {
76         /** Client to server commands, registered in the core
77          */
78         CommandRConnect rconnect;
79         CommandRSQuit rsquit;
80         CommandMap map;
81
82         /** Server to server only commands, not registered in the core
83          */
84         SpanningTreeCommands commands;
85
86         /** Next membership id assigned when a local user joins a channel
87          */
88         Membership::Id currmembid;
89
90         /** The specialized ProtocolInterface that is assigned to ServerInstance->PI on load
91          */
92         SpanningTreeProtocolInterface protocolinterface;
93
94         /** Event provider for our events
95          */
96         Events::ModuleEventProvider eventprov;
97
98         /** API for accessing user SSL certificates. */
99         UserCertificateAPI sslapi;
100
101  public:
102         dynamic_reference<DNS::Manager> DNS;
103
104         /** Event provider for message tags. */
105         Events::ModuleEventProvider tagevprov;
106
107         ServerCommandManager CmdManager;
108
109         /** Set to true if inside a spanningtree call, to prevent sending
110          * xlines and other things back to their source
111          */
112         bool loopCall;
113
114         /** Constructor
115          */
116         ModuleSpanningTree();
117         void init() CXX11_OVERRIDE;
118
119         /** Shows /LINKS
120          */
121         void ShowLinks(TreeServer* Current, User* user, int hops);
122
123         /** Handle LINKS command
124          */
125         void HandleLinks(const CommandBase::Params& parameters, User* user);
126
127         /** Handle SQUIT
128          */
129         ModResult HandleSquit(const CommandBase::Params& parameters, User* user);
130
131         /** Handle remote WHOIS
132          */
133         ModResult HandleRemoteWhois(const CommandBase::Params& parameters, User* user);
134
135         /** Connect a server locally
136          */
137         void ConnectServer(Link* x, Autoconnect* y = NULL);
138
139         /** Connect the next autoconnect server
140          */
141         void ConnectServer(Autoconnect* y, bool on_timer);
142
143         /** Check if any servers are due to be autoconnected
144          */
145         void AutoConnectServers(time_t curtime);
146
147         /** Check if any connecting servers should timeout
148          */
149         void DoConnectTimeout(time_t curtime);
150
151         /** Handle remote VERSON
152          */
153         ModResult HandleVersion(const CommandBase::Params& parameters, User* user);
154
155         /** Handle CONNECT
156          */
157         ModResult HandleConnect(const CommandBase::Params& parameters, User* user);
158
159         const Events::ModuleEventProvider& GetEventProvider() const { return eventprov; }
160
161         /**
162          ** *** MODULE EVENTS ***
163          **/
164
165         ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE;
166         void OnPostCommand(Command*, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, bool loop) CXX11_OVERRIDE;
167         void OnUserConnect(LocalUser* source) CXX11_OVERRIDE;
168         void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) CXX11_OVERRIDE;
169         ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) CXX11_OVERRIDE;
170         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE;
171         void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE;
172         void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE;
173         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts) CXX11_OVERRIDE;
174         void OnChangeHost(User* user, const std::string &newhost) CXX11_OVERRIDE;
175         void OnChangeRealName(User* user, const std::string& real) CXX11_OVERRIDE;
176         void OnChangeIdent(User* user, const std::string &ident) CXX11_OVERRIDE;
177         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts) CXX11_OVERRIDE;
178         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE;
179         void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE;
180         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE;
181         void OnPreRehash(User* user, const std::string &parameter) CXX11_OVERRIDE;
182         void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE;
183         void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE;
184         void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE;
185         void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE;
186         ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE;
187         void OnUserAway(User* user) CXX11_OVERRIDE;
188         void OnUserBack(User* user) CXX11_OVERRIDE;
189         void OnLoadModule(Module* mod) CXX11_OVERRIDE;
190         void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
191         ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE;
192         void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags) CXX11_OVERRIDE;
193         CullResult cull() CXX11_OVERRIDE;
194         ~ModuleSpanningTree();
195         Version GetVersion() CXX11_OVERRIDE;
196         void Prioritize() CXX11_OVERRIDE;
197 };