1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 #include "configreader.h"
23 /* Foward declarations */
27 class ModuleSpanningTree;
29 /* This hash_map holds the hash equivalent of the server
30 * tree, used for rapid linear lookups.
32 typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<string>, irc::StrHashComp> server_hash;
34 typedef std::map<TreeServer*,TreeServer*> TreeServerList;
36 /** A group of modules that implement InspSocketHook
37 * that we can use to hook our server to server connections.
39 typedef std::map<irc::string, Module*> hookmodules;
41 /** Contains helper functions and variables for this module,
42 * and keeps them out of the global namespace
44 class SpanningTreeUtilities
49 InspIRCd* ServerInstance;
53 ModuleSpanningTree* Creator;
54 /** Remote servers that are currently bursting
56 server_hash RemoteServersBursting;
57 /** Flatten links and /MAP for non-opers
60 /** Hide U-Lined servers in /MAP and /LINKS
63 /** Announce TS changes to channels on merge
65 bool AnnounceTSChange;
66 /** Synchronize timestamps between servers
69 /** Make snomasks +CQ quiet during bursts and splits
72 /** Socket bindings for listening sockets
74 std::vector<TreeSocket*> Bindings;
75 /** This variable represents the root of the server tree
78 /** IPs allowed to link to us
80 std::vector<std::string> ValidIPs;
81 /** Hash of currently connected servers by name
83 server_hash serverlist;
84 /** Hash of servers currently bursting but not initialized as connected
86 std::map<irc::string,TreeSocket*> burstingserverlist;
87 /** Holds the data from the <link> tags in the conf
89 std::vector<Link> LinkBlocks;
90 /** Holds a bitmask of queued xline types waiting to be applied.
91 * Will be a mask containing values APPLY_GLINES, APPLY_KLINES,
92 * APPLY_QLINES and APPLY_ZLINES.
96 /** If this is true, this server is the master sync server for time
97 * synching - e.g. it is the server with its clock correct. It will
98 * send out the correct time at intervals.
102 /** List of module pointers which can provide I/O abstraction
106 /** List of module names which can provide I/O abstraction
108 std::vector<std::string> hooknames;
110 /** True (default) if we are to use challenge-response HMAC
111 * to authenticate passwords.
113 * NOTE: This defaults to on, but should be turned off if
114 * you are linking to an older version of inspircd.
116 bool ChallengeResponse;
118 /** Initialise utility class
120 SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
121 /** Destroy class and free listeners etc
123 ~SpanningTreeUtilities();
124 /** Send a message from this server to one other local or remote
126 bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string target);
127 /** Send a message from this server to all but one other, local or remote
129 bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string omit);
130 /** Send a message from this server to all but one other, local or remote
132 bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> ¶ms, std::string omit);
133 /** Send a message from this server to all others
135 bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms);
136 /** Send a message from this server to all others
138 bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> ¶ms);
139 /** 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)
141 bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> ¶ms);
142 /** Read the spanningtree module's tags from the config file
144 void ReadConfiguration(bool rebind);
145 /** Add a server to the server list for GetListOfServersForChannel
147 void AddThisServer(TreeServer* server, TreeServerList &list);
148 /** Compile a list of servers which contain members of channel c
150 void GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list);
151 /** Find a server by name
153 TreeServer* FindServer(const std::string &ServerName);
154 /** Find a remote bursting server by name
156 TreeServer* FindRemoteBurstServer(TreeServer* Server);
157 /** Set a remote server to bursting or not bursting
159 void SetRemoteBursting(TreeServer* Server, bool bursting);
160 /** Find a route to a server by name
162 TreeServer* BestRouteTo(const std::string &ServerName);
163 /** Find a server by glob mask
165 TreeServer* FindServerMask(const std::string &ServerName);
166 /** Returns true if this is a server name we recognise
168 bool IsServer(const std::string &ServerName);
169 /** Attempt to connect to the failover link of link x
171 void DoFailOver(Link* x);
172 /** Find a link tag from a server name
174 Link* FindLink(const std::string& name);
175 /** Refresh the IP cache used for allowing inbound connections
177 void RefreshIPCache();
179 TreeSocket* FindBurstingServer(const std::string &ServerName);
181 void AddBurstingServer(const std::string &ServerName, TreeSocket* s);
183 void DelBurstingServer(TreeSocket* s);