4 #include "configreader.h"
10 /* Foward declarations */
14 class ModuleSpanningTree;
16 /* This hash_map holds the hash equivalent of the server
17 * tree, used for rapid linear lookups.
19 typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<string>, irc::StrHashComp> server_hash;
21 typedef std::map<TreeServer*,TreeServer*> TreeServerList;
23 /** A group of modules that implement InspSocketHook
24 * that we can use to hook our server to server connections.
26 typedef std::map<irc::string, Module*> hookmodules;
28 /** Contains helper functions and variables for this module,
29 * and keeps them out of the global namespace
31 class SpanningTreeUtilities
36 InspIRCd* ServerInstance;
40 ModuleSpanningTree* Creator;
41 /** Flatten links and /MAP for non-opers
44 /** Hide U-Lined servers in /MAP and /LINKS
47 /** Announce TS changes to channels on merge
49 bool AnnounceTSChange;
50 /** Synchronize timestamps between servers
53 /** Socket bindings for listening sockets
55 std::vector<TreeSocket*> Bindings;
56 /** This variable represents the root of the server tree
59 /** IPs allowed to link to us
61 std::vector<std::string> ValidIPs;
62 /** Hash of currently connected servers by name
64 server_hash serverlist;
65 /** Holds the data from the <link> tags in the conf
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.
74 /** If this is true, this server is the master sync server for time
75 * synching - e.g. it is the server with its clock correct. It will
76 * send out the correct time at intervals.
80 /** List of module pointers which can provide I/O abstraction
84 /** List of module names which can provide I/O abstraction
86 std::vector<std::string> hooknames;
88 /** Initialise utility class
90 SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
91 /** Destroy class and free listeners etc
93 ~SpanningTreeUtilities();
94 /** Send a message from this server to one other local or remote
96 bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string target);
97 /** Send a message from this server to all but one other, local or remote
99 bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string omit);
100 /** Send a message from this server to all but one other, local or remote
102 bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> ¶ms, std::string omit);
103 /** Send a message from this server to all others
105 bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms);
106 /** Send a message from this server to all others
108 bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> ¶ms);
109 /** 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)
111 bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> ¶ms);
112 /** Read the spanningtree module's tags from the config file
114 void ReadConfiguration(bool rebind);
115 /** Add a server to the server list for GetListOfServersForChannel
117 void AddThisServer(TreeServer* server, TreeServerList &list);
118 /** Compile a list of servers which contain members of channel c
120 void GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list);
121 /** Find a server by name
123 TreeServer* FindServer(const std::string &ServerName);
124 /** Find a route to a server by name
126 TreeServer* BestRouteTo(const std::string &ServerName);
127 /** Find a server by glob mask
129 TreeServer* FindServerMask(const std::string &ServerName);
130 /** Returns true if this is a server name we recognise
132 bool IsServer(const std::string &ServerName);
133 /** Attempt to connect to the failover link of link x
135 void DoFailOver(Link* x);
136 /** Find a link tag from a server name
138 Link* FindLink(const std::string& name);