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 /** List of module pointers which can provide I/O abstraction
78 /** List of module names which can provide I/O abstraction
80 std::vector<std::string> hooknames;
82 /** Initialise utility class
84 SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
85 /** Destroy class and free listeners etc
87 ~SpanningTreeUtilities();
88 /** Send a message from this server to one other local or remote
90 bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string target);
91 /** Send a message from this server to all but one other, local or remote
93 bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string omit);
94 /** Send a message from this server to all but one other, local or remote
96 bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> ¶ms, std::string omit);
97 /** Send a message from this server to all others
99 bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms);
100 /** Send a message from this server to all others
102 bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> ¶ms);
103 /** 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)
105 bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> ¶ms);
106 /** Read the spanningtree module's tags from the config file
108 void ReadConfiguration(bool rebind);
109 /** Add a server to the server list for GetListOfServersForChannel
111 void AddThisServer(TreeServer* server, TreeServerList &list);
112 /** Compile a list of servers which contain members of channel c
114 void GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list);
115 /** Find a server by name
117 TreeServer* FindServer(const std::string &ServerName);
118 /** Find a route to a server by name
120 TreeServer* BestRouteTo(const std::string &ServerName);
121 /** Find a server by glob mask
123 TreeServer* FindServerMask(const std::string &ServerName);
124 /** Returns true if this is a server name we recognise
126 bool IsServer(const std::string &ServerName);
127 /** Attempt to connect to the failover link of link x
129 void DoFailOver(Link* x);
130 /** Find a link tag from a server name
132 Link* FindLink(const std::string& name);