The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

utils.h

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
00006  * See: http://www.inspircd.org/wiki/index.php/Credits
00007  *
00008  * This program is free but copyrighted software; see
00009  *            the file COPYING for details.
00010  *
00011  * ---------------------------------------------------
00012  */
00013 
00014 #ifndef __ST__UTIL__
00015 #define __ST__UTIL__
00016 
00017 #include "inspircd.h"
00018 
00019 /* Foward declarations */
00020 class TreeServer;
00021 class TreeSocket;
00022 class Link;
00023 class ModuleSpanningTree;
00024 
00025 /* This hash_map holds the hash equivalent of the server
00026  * tree, used for rapid linear lookups.
00027  */
00028 #ifdef WINDOWS
00029         typedef nspace::hash_map<std::string, TreeServer*, nspace::hash_compare<std::string, std::less<std::string> > > server_hash;
00030 #else
00031         #ifdef HASHCOMP_DEPRECATED
00032                 typedef nspace::hash_map<std::string, TreeServer*, nspace::insensitive, irc::StrHashComp> server_hash;
00033         #else
00034                 typedef nspace::hash_map<std::string, TreeServer*, nspace::hash<std::string>, irc::StrHashComp> server_hash;
00035         #endif
00036 #endif
00037 
00038 typedef std::map<TreeServer*,TreeServer*> TreeServerList;
00039 
00043 typedef std::map<irc::string, Module*> hookmodules;
00044 
00048 class SpanningTreeUtilities : public classbase
00049 {
00050  private:
00053         InspIRCd* ServerInstance;
00054  public:
00057         ModuleSpanningTree* Creator;
00058 
00061         bool FlatLinks;
00064         bool HideULines;
00067         bool AnnounceTSChange;
00068 
00071         bool quiet_bursts;
00074         std::vector<TreeSocket*> Bindings;
00075         /* Number of seconds that a server can go without ping
00076          * before opers are warned of high latency.
00077          */
00078         int PingWarnTime;
00081         TreeServer *TreeRoot;
00084         std::vector<std::string> ValidIPs;
00087         server_hash serverlist;
00090         server_hash sidlist;
00093         std::map<irc::string,TreeSocket*> burstingserverlist;
00096         std::vector<Link> LinkBlocks;
00097 
00100         hookmodules hooks;
00101 
00104         std::vector<std::string> hooknames;
00105 
00112         bool ChallengeResponse;
00113 
00116         int PingFreq;
00117 
00120         SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningTree* Creator);
00121 
00124         ~SpanningTreeUtilities();
00125 
00128         bool DoOneToOne(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string target);
00129 
00132         bool DoOneToAllButSender(const std::string &prefix, const std::string &command, std::deque<std::string> &params, std::string omit);
00133 
00136         bool DoOneToAllButSender(const char* prefix, const char* command, std::deque<std::string> &params, std::string omit);
00137 
00140         bool DoOneToMany(const std::string &prefix, const std::string &command, std::deque<std::string> &params);
00141 
00144         bool DoOneToMany(const char* prefix, const char* command, std::deque<std::string> &params);
00145 
00148         bool DoOneToAllButSenderRaw(const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque<std::string> &params);
00149 
00152         void ReadConfiguration(bool rebind);
00153 
00156         void AddThisServer(TreeServer* server, TreeServerList &list);
00157 
00160         void GetListOfServersForChannel(Channel* c, TreeServerList &list, char status, const CUList &exempt_list);
00161 
00164         TreeServer* FindServer(const std::string &ServerName);
00165 
00168         TreeServer* FindServerID(const std::string &id);
00169 
00172         TreeServer* BestRouteTo(const std::string &ServerName);
00173 
00176         TreeServer* FindServerMask(const std::string &ServerName);
00177 
00180         bool IsServer(const std::string &ServerName);
00181 
00184         void DoFailOver(Link* x);
00185 
00188         Link* FindLink(const std::string& name);
00189 
00192         void RefreshIPCache();
00193 };
00194 
00195 #endif