]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/main.h
e9be4416701bb88a24420d51cd41d6b8ceeaeb8c
[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 "modules/dns.h"
28 #include "servercommand.h"
29
30 /** If you make a change which breaks the protocol, increment this.
31  * If you  completely change the protocol, completely change the number.
32  *
33  * IMPORTANT: If you make changes, document your changes here, without fail:
34  * http://wiki.inspircd.org/List_of_protocol_changes_between_versions
35  *
36  * Failure to document your protocol changes will result in a painfully
37  * painful death by pain. You have been warned.
38  */
39 const long ProtocolVersion = 1205;
40 const long MinCompatProtocol = 1202;
41
42 /** Forward declarations
43  */
44 class SpanningTreeCommands;
45 class SpanningTreeUtilities;
46 class CacheRefreshTimer;
47 class TreeServer;
48 class Link;
49 class Autoconnect;
50
51 /** This is the main class for the spanningtree module
52  */
53 class ModuleSpanningTree : public Module
54 {
55         SpanningTreeCommands* commands;
56
57  public:
58         dynamic_reference<DNS::Manager> DNS;
59
60         ServerCommandManager CmdManager;
61
62         /** Set to true if inside a spanningtree call, to prevent sending
63          * xlines and other things back to their source
64          */
65         bool loopCall;
66
67         /** Constructor
68          */
69         ModuleSpanningTree();
70         void init() CXX11_OVERRIDE;
71
72         /** Shows /LINKS
73          */
74         void ShowLinks(TreeServer* Current, User* user, int hops);
75
76         /** Handle LINKS command
77          */
78         void HandleLinks(const std::vector<std::string>& parameters, User* user);
79
80         /** Show MAP output to a user (recursive)
81          */
82         void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
83
84         /** Handle MAP command
85          */
86         bool HandleMap(const std::vector<std::string>& parameters, User* user);
87
88         /** Handle SQUIT
89          */
90         ModResult HandleSquit(const std::vector<std::string>& parameters, User* user);
91
92         /** Handle remote WHOIS
93          */
94         ModResult HandleRemoteWhois(const std::vector<std::string>& parameters, User* user);
95
96         /** Ping all local servers
97          */
98         void DoPingChecks(time_t curtime);
99
100         /** Connect a server locally
101          */
102         void ConnectServer(Link* x, Autoconnect* y = NULL);
103
104         /** Connect the next autoconnect server
105          */
106         void ConnectServer(Autoconnect* y, bool on_timer);
107
108         /** Check if any servers are due to be autoconnected
109          */
110         void AutoConnectServers(time_t curtime);
111
112         /** Check if any connecting servers should timeout
113          */
114         void DoConnectTimeout(time_t curtime);
115
116         /** Handle remote VERSON
117          */
118         ModResult HandleVersion(const std::vector<std::string>& parameters, User* user);
119
120         /** Handle CONNECT
121          */
122         ModResult HandleConnect(const std::vector<std::string>& parameters, User* user);
123
124         /** Attempt to send a message to a user
125          */
126         void RemoteMessage(User* user, const char* format, ...) CUSTOM_PRINTF(3, 4);
127
128         /** Returns oper-specific MAP information
129          */
130         const std::string MapOperInfo(TreeServer* Current);
131
132         /** Display a time as a human readable string
133          */
134         static std::string TimeToStr(time_t secs);
135
136         /**
137          ** *** MODULE EVENTS ***
138          **/
139
140         ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE;
141         void OnPostCommand(Command*, const std::vector<std::string>& parameters, LocalUser* user, CmdResult result, const std::string& original_line) CXX11_OVERRIDE;
142         void OnGetServerDescription(const std::string &servername,std::string &description) CXX11_OVERRIDE;
143         void OnUserConnect(LocalUser* source) CXX11_OVERRIDE;
144         void OnUserInvite(User* source,User* dest,Channel* channel, time_t) CXX11_OVERRIDE;
145         void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) CXX11_OVERRIDE;
146         void OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE;
147         void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE;
148         void OnUserJoin(Membership* memb, bool sync, bool created, CUList& excepts) CXX11_OVERRIDE;
149         void OnChangeHost(User* user, const std::string &newhost) CXX11_OVERRIDE;
150         void OnChangeName(User* user, const std::string &gecos) CXX11_OVERRIDE;
151         void OnChangeIdent(User* user, const std::string &ident) CXX11_OVERRIDE;
152         void OnUserPart(Membership* memb, std::string &partmessage, CUList& excepts) CXX11_OVERRIDE;
153         void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message) CXX11_OVERRIDE;
154         void OnUserPostNick(User* user, const std::string &oldnick) CXX11_OVERRIDE;
155         void OnUserKick(User* source, Membership* memb, const std::string &reason, CUList& excepts) CXX11_OVERRIDE;
156         void OnPreRehash(User* user, const std::string &parameter) CXX11_OVERRIDE;
157         void OnRehash(User* user) CXX11_OVERRIDE;
158         void OnOper(User* user, const std::string &opertype) CXX11_OVERRIDE;
159         void OnLine(User* source, const std::string &host, bool adding, char linetype, long duration, const std::string &reason);
160         void OnAddLine(User *u, XLine *x) CXX11_OVERRIDE;
161         void OnDelLine(User *u, XLine *x) CXX11_OVERRIDE;
162         ModResult OnStats(char statschar, User* user, string_list &results) CXX11_OVERRIDE;
163         ModResult OnSetAway(User* user, const std::string &awaymsg) CXX11_OVERRIDE;
164         void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate);
165         void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata);
166         void OnLoadModule(Module* mod) CXX11_OVERRIDE;
167         void OnUnloadModule(Module* mod) CXX11_OVERRIDE;
168         ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE;
169         CullResult cull();
170         ~ModuleSpanningTree();
171         Version GetVersion() CXX11_OVERRIDE;
172         void Prioritize();
173 };