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