1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 /* Foward declarations */
24 class ModuleSpanningTree;
25 class SpanningTreeUtilities;
27 /* This hash_map holds the hash equivalent of the server
28 * tree, used for rapid linear lookups.
30 #if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
31 typedef nspace::hash_map<std::string, TreeServer*, nspace::hash_compare<std::string, std::less<std::string> > > server_hash;
33 #ifdef HASHCOMP_DEPRECATED
34 typedef nspace::hash_map<std::string, TreeServer*, nspace::insensitive, irc::StrHashComp> server_hash;
36 typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<std::string>, irc::StrHashComp> server_hash;
40 typedef std::map<TreeServer*,TreeServer*> TreeServerList;
42 /** Contains helper functions and variables for this module,
43 * and keeps them out of the global namespace
45 class SpanningTreeUtilities : public classbase
50 ModuleSpanningTree* Creator;
52 /** Flatten links and /MAP for non-opers
55 /** Hide U-Lined servers in /MAP and /LINKS
58 /** Announce TS changes to channels on merge
60 bool AnnounceTSChange;
62 /** Allow modules marked as VF_OPTCOMMON to be mismatched when linking
66 /** Make snomasks +CQ quiet during bursts and splits
70 /* Number of seconds that a server can go without ping
71 * before opers are warned of high latency.
74 /** This variable represents the root of the server tree
77 /** IPs allowed to link to us
79 std::vector<std::string> ValidIPs;
80 /** Hash of currently connected servers by name
82 server_hash serverlist;
83 /** Hash of currently known server ids
86 /** Hash of servers currently bursting but not initialized as connected
88 std::map<irc::string,TreeSocket*> burstingserverlist;
89 /** List of all outgoing sockets and their timeouts
91 std::map<TreeSocket*, std::pair<std::string, int> > timeoutlist;
92 /** Holds the data from the <link> tags in the conf
94 std::vector<reference<Link> > LinkBlocks;
95 /** Holds the data from the <autoconnect> tags in the conf
97 std::vector<reference<Autoconnect> > AutoconnectBlocks;
99 /** True (default) if we are to use challenge-response HMAC
100 * to authenticate passwords.
102 * NOTE: This defaults to on, but should be turned off if
103 * you are linking to an older version of inspircd.
105 bool ChallengeResponse;
107 /** Ping frequency of server to server links
111 /** Initialise utility class
113 SpanningTreeUtilities(ModuleSpanningTree* Creator);
115 /** Prepare for class destruction
119 /** Destroy class and free listeners etc
121 ~SpanningTreeUtilities();
123 void RouteCommand(TreeServer*, const std::string&, const parameterlist&, User*);
125 /** Send a message from this server to one other local or remote
127 bool DoOneToOne(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string target);
129 /** Send a message from this server to all but one other, local or remote
131 bool DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist ¶ms, std::string omit);
133 /** Send a message from this server to all but one other, local or remote
135 bool DoOneToAllButSender(const char* prefix, const char* command, const parameterlist ¶ms, std::string omit);
137 /** Send a message from this server to all others
139 bool DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist ¶ms);
141 /** Send a message from this server to all others
143 bool DoOneToMany(const char* prefix, const char* command, const parameterlist ¶ms);
145 /** 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)
147 bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, const parameterlist ¶ms);
149 /** Read the spanningtree module's tags from the config file
151 void ReadConfiguration();
153 /** Add a server to the server list for GetListOfServersForChannel
155 void AddThisServer(TreeServer* server, TreeServerList &list);
157 /** Compile a list of servers which contain members of channel c
159 void GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list);
161 /** Find a server by name
163 TreeServer* FindServer(const std::string &ServerName);
165 /** Find server by SID
167 TreeServer* FindServerID(const std::string &id);
169 /** Find a route to a server by name
171 TreeServer* BestRouteTo(const std::string &ServerName);
173 /** Find a server by glob mask
175 TreeServer* FindServerMask(const std::string &ServerName);
177 /** Returns true if this is a server name we recognise
179 bool IsServer(const std::string &ServerName);
181 /** Find a link tag from a server name
183 Link* FindLink(const std::string& name);
185 /** Refresh the IP cache used for allowing inbound connections
187 void RefreshIPCache();