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 /** Flatten links and /MAP for non-opers
57 /** Hide U-Lined servers in /MAP and /LINKS
60 /** Announce TS changes to channels on merge
62 bool AnnounceTSChange;
63 /** Synchronize timestamps between servers
66 /** Socket bindings for listening sockets
68 std::vector<TreeSocket*> Bindings;
69 /** This variable represents the root of the server tree
72 /** IPs allowed to link to us
74 std::vector<std::string> ValidIPs;
75 /** Hash of currently connected servers by name
77 server_hash serverlist;
78 /** Holds the data from the <link> tags in the conf
80 std::vector<Link> LinkBlocks;
81 /** Holds a bitmask of queued xline types waiting to be applied.
82 * Will be a mask containing values APPLY_GLINES, APPLY_KLINES,
83 * APPLY_QLINES and APPLY_ZLINES.
87 /** If this is true, this server is the master sync server for time
88 * synching - e.g. it is the server with its clock correct. It will
89 * send out the correct time at intervals.
93 /** List of module pointers which can provide I/O abstraction
97 /** List of module names which can provide I/O abstraction
99 std::vector<std::string> hooknames;
101 /** Initialise utility class
103 SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
104 /** Destroy class and free listeners etc
106 ~SpanningTreeUtilities();
107 /** Send a message from this server to one other local or remote
109 bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string target);
110 /** Send a message from this server to all but one other, local or remote
112 bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms, std::string omit);
113 /** Send a message from this server to all but one other, local or remote
115 bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> ¶ms, std::string omit);
116 /** Send a message from this server to all others
118 bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> ¶ms);
119 /** Send a message from this server to all others
121 bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> ¶ms);
122 /** 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)
124 bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> ¶ms);
125 /** Read the spanningtree module's tags from the config file
127 void ReadConfiguration(bool rebind);
128 /** Add a server to the server list for GetListOfServersForChannel
130 void AddThisServer(TreeServer* server, TreeServerList &list);
131 /** Compile a list of servers which contain members of channel c
133 void GetListOfServersForChannel(chanrec* c, TreeServerList &list, char status, const CUList &exempt_list);
134 /** Find a server by name
136 TreeServer* FindServer(const std::string &ServerName);
137 /** Find a route to a server by name
139 TreeServer* BestRouteTo(const std::string &ServerName);
140 /** Find a server by glob mask
142 TreeServer* FindServerMask(const std::string &ServerName);
143 /** Returns true if this is a server name we recognise
145 bool IsServer(const std::string &ServerName);
146 /** Attempt to connect to the failover link of link x
148 void DoFailOver(Link* x);
149 /** Find a link tag from a server name
151 Link* FindLink(const std::string& name);
152 /** Refresh the IP cache used for allowing inbound connections
154 void RefreshIPCache();