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.
75 std::vector<std::string> hooknames;
77 /** Initialise utility class
79 SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
80 /** Destroy class and free listeners etc
82 ~SpanningTreeUtilities();
83 /** Send a message from this server to one other local or remote
85 bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string target);
86 /** Send a message from this server to all but one other, local or remote
88 bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string omit);
89 /** Send a message from this server to all but one other, local or remote
91 bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> ¶ms, std::string omit);
92 /** Send a message from this server to all others
94 bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms);
95 /** Send a message from this server to all others
97 bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> ¶ms);
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)
100 bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> ¶ms);
101 /** Read the spanningtree module's tags from the config file
103 void ReadConfiguration(bool rebind);
104 /** Add a server to the server list for GetListOfServersForChannel
106 void AddThisServer(TreeServer* server, TreeServerList &list);
107 /** Compile a list of servers which contain members of channel c
109 void GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list);
110 /** Find a server by name
112 TreeServer* FindServer(const std::string &ServerName);
113 /** Find a route to a server by name
115 TreeServer* BestRouteTo(const std::string &ServerName);
116 /** Find a server by glob mask
118 TreeServer* FindServerMask(const std::string &ServerName);
119 /** Returns true if this is a server name we recognise
121 bool IsServer(const std::string &ServerName);
122 /** Attempt to connect to the failover link of link x
124 void DoFailOver(Link* x);
125 /** Find a link tag from a server name
127 Link* FindLink(const std::string& name);