]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/utils.h
Add a TODO comment
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / utils.h
1 #ifndef __ST__UTIL__
2 #define __ST__UTIL__
3
4 #include "configreader.h"
5 #include "users.h"
6 #include "channels.h"
7 #include "modules.h"
8 #include "inspircd.h"
9
10 /* Foward declarations */
11 class TreeServer;
12 class TreeSocket;
13 class Link;
14 class ModuleSpanningTree;
15
16 /* This hash_map holds the hash equivalent of the server
17  * tree, used for rapid linear lookups.
18  */
19 typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<string>, irc::StrHashComp> server_hash;
20
21 typedef std::map<TreeServer*,TreeServer*> TreeServerList;
22
23 /** A group of modules that implement InspSocketHook
24  * that we can use to hook our server to server connections.
25  */
26 typedef std::map<irc::string, Module*> hookmodules;
27
28 /** Contains helper functions and variables for this module,
29  * and keeps them out of the global namespace
30  */
31 class SpanningTreeUtilities
32 {
33  private:
34         /** Creator server
35          */
36         InspIRCd* ServerInstance;
37  public:
38         /** Creator module
39          */
40         ModuleSpanningTree* Creator;
41         /** Flatten links and /MAP for non-opers
42          */
43         bool FlatLinks;
44         /** Hide U-Lined servers in /MAP and /LINKS
45          */
46         bool HideULines;
47         /** Announce TS changes to channels on merge
48          */
49         bool AnnounceTSChange;
50         /** Synchronize timestamps between servers
51          */
52         bool EnableTimeSync;
53         /** Socket bindings for listening sockets
54          */
55         std::vector<TreeSocket*> Bindings;
56         /** This variable represents the root of the server tree
57          */
58         TreeServer *TreeRoot;
59         /** IPs allowed to link to us
60          */
61         std::vector<std::string> ValidIPs;
62         /** Hash of currently connected servers by name
63          */
64         server_hash serverlist;
65         /** Holds the data from the <link> tags in the conf
66          */
67         std::vector<Link> LinkBlocks;
68         /** Holds a bitmask of queued xline types waiting to be applied.
69          * Will be a mask containing values APPLY_GLINES, APPLY_KLINES,
70          * APPLY_QLINES and APPLY_ZLINES.
71          */
72         int lines_to_apply;
73
74         hookmodules hooks;
75         std::vector<std::string> hooknames;
76
77         /** Initialise utility class
78          */
79         SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
80         /** Destroy class and free listeners etc
81          */
82         ~SpanningTreeUtilities();
83         /** Send a message from this server to one other local or remote
84          */
85         bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string target);
86         /** Send a message from this server to all but one other, local or remote
87          */
88         bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string omit);
89         /** Send a message from this server to all but one other, local or remote
90          */
91         bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> &params, std::string omit);
92         /** Send a message from this server to all others
93          */
94         bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> &params);
95         /** Send a message from this server to all others
96          */
97         bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> &params);
98         /** 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)
99          */
100         bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> &params);
101         /** Read the spanningtree module's tags from the config file
102          */
103         void ReadConfiguration(bool rebind);
104         /** Add a server to the server list for GetListOfServersForChannel
105          */
106         void AddThisServer(TreeServer* server, TreeServerList &list);
107         /** Compile a list of servers which contain members of channel c
108          */
109         void GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list);
110         /** Find a server by name
111          */
112         TreeServer* FindServer(const std::string &ServerName);
113         /** Find a route to a server by name
114          */
115         TreeServer* BestRouteTo(const std::string &ServerName);
116         /** Find a server by glob mask
117          */
118         TreeServer* FindServerMask(const std::string &ServerName);
119         /** Returns true if this is a server name we recognise
120          */
121         bool IsServer(const std::string &ServerName);
122         /** Attempt to connect to the failover link of link x
123          */
124         void DoFailOver(Link* x);
125         /** Find a link tag from a server name
126          */
127         Link* FindLink(const std::string& name);
128 };
129
130 #endif