]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/utils.h
Correct the silentbursts logic
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / utils.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #ifndef __ST__UTIL__
15 #define __ST__UTIL__
16
17 #include "configreader.h"
18 #include "users.h"
19 #include "channels.h"
20 #include "modules.h"
21 #include "inspircd.h"
22
23 /* Foward declarations */
24 class TreeServer;
25 class TreeSocket;
26 class Link;
27 class ModuleSpanningTree;
28
29 /* This hash_map holds the hash equivalent of the server
30  * tree, used for rapid linear lookups.
31  */
32 typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<string>, irc::StrHashComp> server_hash;
33
34 typedef std::map<TreeServer*,TreeServer*> TreeServerList;
35
36 /** A group of modules that implement InspSocketHook
37  * that we can use to hook our server to server connections.
38  */
39 typedef std::map<irc::string, Module*> hookmodules;
40
41 /** Contains helper functions and variables for this module,
42  * and keeps them out of the global namespace
43  */
44 class SpanningTreeUtilities
45 {
46  private:
47         /** Creator server
48          */
49         InspIRCd* ServerInstance;
50  public:
51         /** Creator module
52          */
53         ModuleSpanningTree* Creator;
54         /** Flatten links and /MAP for non-opers
55          */
56         bool FlatLinks;
57         /** Hide U-Lined servers in /MAP and /LINKS
58          */
59         bool HideULines;
60         /** Announce TS changes to channels on merge
61          */
62         bool AnnounceTSChange;
63         /** Synchronize timestamps between servers
64          */
65         bool EnableTimeSync;
66         /** Make snomasks +CQ quiet during bursts and splits
67          */
68         bool quiet_bursts;
69         /** Socket bindings for listening sockets
70          */
71         std::vector<TreeSocket*> Bindings;
72         /** This variable represents the root of the server tree
73          */
74         TreeServer *TreeRoot;
75         /** IPs allowed to link to us
76          */
77         std::vector<std::string> ValidIPs;
78         /** Hash of currently connected servers by name
79          */
80         server_hash serverlist;
81         /** Hash of servers currently bursting but not initialized as connected
82          */
83         std::map<irc::string,TreeSocket*> burstingserverlist;
84         /** Holds the data from the <link> tags in the conf
85          */
86         std::vector<Link> LinkBlocks;
87         /** Holds a bitmask of queued xline types waiting to be applied.
88          * Will be a mask containing values APPLY_GLINES, APPLY_KLINES,
89          * APPLY_QLINES and APPLY_ZLINES.
90          */
91         int lines_to_apply;
92
93         /** If this is true, this server is the master sync server for time
94          * synching - e.g. it is the server with its clock correct. It will
95          * send out the correct time at intervals.
96          */
97         bool MasterTime;
98
99         /** List of module pointers which can provide I/O abstraction
100          */
101         hookmodules hooks;
102
103         /** List of module names which can provide I/O abstraction
104          */
105         std::vector<std::string> hooknames;
106
107         /** True (default) if we are to use challenge-response HMAC
108          * to authenticate passwords.
109          *
110          * NOTE: This defaults to on, but should be turned off if
111          * you are linking to an older version of inspircd.
112          */
113         bool ChallengeResponse;
114
115         /** Initialise utility class
116          */
117         SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
118         /** Destroy class and free listeners etc
119          */
120         ~SpanningTreeUtilities();
121         /** Send a message from this server to one other local or remote
122          */
123         bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string target);
124         /** Send a message from this server to all but one other, local or remote
125          */
126         bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string omit);
127         /** Send a message from this server to all but one other, local or remote
128          */
129         bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> &params, std::string omit);
130         /** Send a message from this server to all others
131          */
132         bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> &params);
133         /** Send a message from this server to all others
134          */
135         bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> &params);
136         /** Send a message from this server to all others, without doing any processing on the command (e.g. send it as-is with colons and all)
137          */
138         bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> &params);
139         /** Read the spanningtree module's tags from the config file
140          */
141         void ReadConfiguration(bool rebind);
142         /** Add a server to the server list for GetListOfServersForChannel
143          */
144         void AddThisServer(TreeServer* server, TreeServerList &list);
145         /** Compile a list of servers which contain members of channel c
146          */
147         void GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list);
148         /** Find a server by name
149          */
150         TreeServer* FindServer(const std::string &ServerName);
151         /** Find a route to a server by name
152          */
153         TreeServer* BestRouteTo(const std::string &ServerName);
154         /** Find a server by glob mask
155          */
156         TreeServer* FindServerMask(const std::string &ServerName);
157         /** Returns true if this is a server name we recognise
158          */
159         bool IsServer(const std::string &ServerName);
160         /** Attempt to connect to the failover link of link x
161          */
162         void DoFailOver(Link* x);
163         /** Find a link tag from a server name
164          */
165         Link* FindLink(const std::string& name);
166         /** Refresh the IP cache used for allowing inbound connections
167          */
168         void RefreshIPCache();
169
170         TreeSocket* FindBurstingServer(const std::string &ServerName);
171
172         void AddBurstingServer(const std::string &ServerName, TreeSocket* s);
173
174         void DelBurstingServer(TreeSocket* s);
175 };
176
177 #endif