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

SpanningTreeUtilities Class Reference

Contains helper functions and variables for this module, and keeps them out of the global namespace. More...

#include <utils.h>

Inheritance diagram for SpanningTreeUtilities:

Inheritance graph
[legend]
Collaboration diagram for SpanningTreeUtilities:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SpanningTreeUtilities (InspIRCd *Instance, ModuleSpanningTree *Creator)
 Initialise utility class.
 ~SpanningTreeUtilities ()
 Destroy class and free listeners etc.
bool DoOneToOne (const std::string &prefix, const std::string &command, std::deque< std::string > &params, std::string target)
 Send a message from this server to one other local or remote.
bool DoOneToAllButSender (const std::string &prefix, const std::string &command, std::deque< std::string > &params, std::string omit)
 Send a message from this server to all but one other, local or remote.
bool DoOneToAllButSender (const char *prefix, const char *command, std::deque< std::string > &params, std::string omit)
 Send a message from this server to all but one other, local or remote.
bool DoOneToMany (const std::string &prefix, const std::string &command, std::deque< std::string > &params)
 Send a message from this server to all others.
bool DoOneToMany (const char *prefix, const char *command, std::deque< std::string > &params)
 Send a message from this server to all others.
bool DoOneToAllButSenderRaw (const std::string &data, const std::string &omit, const std::string &prefix, const irc::string &command, std::deque< std::string > &params)
 Send a message from this server to all others, without doing any processing on the command (e.g.
void ReadConfiguration (bool rebind)
 Read the spanningtree module's tags from the config file.
void AddThisServer (TreeServer *server, TreeServerList &list)
 Add a server to the server list for GetListOfServersForChannel.
void GetListOfServersForChannel (Channel *c, TreeServerList &list, char status, const CUList &exempt_list)
 Compile a list of servers which contain members of channel c.
TreeServerFindServer (const std::string &ServerName)
 Find a server by name.
TreeServerFindServerID (const std::string &id)
 Find server by SID.
TreeServerBestRouteTo (const std::string &ServerName)
 Find a route to a server by name.
TreeServerFindServerMask (const std::string &ServerName)
 Find a server by glob mask.
bool IsServer (const std::string &ServerName)
 Returns true if this is a server name we recognise.
void DoFailOver (Link *x)
 Attempt to connect to the failover link of link x.
LinkFindLink (const std::string &name)
 Find a link tag from a server name.
void RefreshIPCache ()
 Refresh the IP cache used for allowing inbound connections.

Public Attributes

ModuleSpanningTreeCreator
 Creator module.
bool FlatLinks
 Flatten links and /MAP for non-opers.
bool HideULines
 Hide U-Lined servers in /MAP and /LINKS.
bool AnnounceTSChange
 Announce TS changes to channels on merge.
bool quiet_bursts
 Make snomasks +CQ quiet during bursts and splits.
std::vector< TreeSocket * > Bindings
 Socket bindings for listening sockets.
int PingWarnTime
TreeServerTreeRoot
 This variable represents the root of the server tree.
std::vector< std::stringValidIPs
 IPs allowed to link to us.
server_hash serverlist
 Hash of currently connected servers by name.
server_hash sidlist
 Hash of currently known server ids.
std::map< irc::string, TreeSocket * > burstingserverlist
 Hash of servers currently bursting but not initialized as connected.
std::vector< LinkLinkBlocks
 Holds the data from the <link> tags in the conf.
hookmodules hooks
 List of module pointers which can provide I/O abstraction.
std::vector< std::stringhooknames
 List of module names which can provide I/O abstraction.
bool ChallengeResponse
 True (default) if we are to use challenge-response HMAC to authenticate passwords.
int PingFreq
 Ping frequency of server to server links.

Private Attributes

InspIRCdServerInstance
 Creator server.

Detailed Description

Contains helper functions and variables for this module, and keeps them out of the global namespace.

Definition at line 48 of file utils.h.


Constructor & Destructor Documentation

SpanningTreeUtilities::SpanningTreeUtilities InspIRCd Instance,
ModuleSpanningTree Creator
 

Initialise utility class.

Definition at line 114 of file utils.cpp.

References Bindings, InspIRCd::Config, Creator, DEBUG, ModuleManager::FindInterface(), ServerConfig::GetSID(), hooknames, hooks, LogManager::Log(), InspIRCd::Logs, InspIRCd::Modules, ReadConfiguration(), ServerConfig::ServerDesc, ServerInstance, ServerConfig::ServerName, and TreeRoot.

SpanningTreeUtilities::~SpanningTreeUtilities  ) 
 

Destroy class and free listeners etc.

Definition at line 143 of file utils.cpp.

References Bindings, InspIRCd::BufferedSocketCull(), TreeServer::ChildCount(), BufferedSocket::Close(), SocketEngine::DelFd(), TreeServer::GetChild(), TreeServer::GetSocket(), InspIRCd::SE, ServerInstance, and TreeRoot.


Member Function Documentation

void SpanningTreeUtilities::AddThisServer TreeServer server,
TreeServerList list
 

Add a server to the server list for GetListOfServersForChannel.

Definition at line 164 of file utils.cpp.

Referenced by GetListOfServersForChannel().

TreeServer * SpanningTreeUtilities::BestRouteTo const std::string ServerName  ) 
 

Find a route to a server by name.

This only applies to one-to-one and not one-to-many routing. See the comments for the constructor of TreeServer for more details.

Definition at line 59 of file utils.cpp.

References InspIRCd::Config, InspIRCd::FindNick(), FindServer(), TreeServer::GetName(), TreeServer::GetRoute(), ServerConfig::GetSID(), User::server, ServerInstance, and TreeRoot.

Referenced by DoOneToAllButSender(), DoOneToAllButSenderRaw(), DoOneToOne(), ModuleSpanningTree::DoPingChecks(), TreeSocket::ForceJoin(), GetListOfServersForChannel(), and TreeSocket::ProcessLine().

void SpanningTreeUtilities::DoFailOver Link x  ) 
 

Attempt to connect to the failover link of link x.

Definition at line 590 of file utils.cpp.

References ModuleSpanningTree::ConnectServer(), Creator, DEBUG, Link::FailOver, FindLink(), FindServer(), LogManager::Log(), InspIRCd::Logs, Link::Name, ModuleSpanningTree::RemoteMessage(), and ServerInstance.

Referenced by ModuleSpanningTree::ConnectServer(), TreeSocket::OnError(), ServernameResolver::OnError(), ServernameResolver::OnLookupComplete(), and TreeSocket::OnTimeout().

bool SpanningTreeUtilities::DoOneToAllButSender const char *  prefix,
const char *  command,
std::deque< std::string > &  params,
std::string  omit
 

Send a message from this server to all but one other, local or remote.

Definition at line 322 of file utils.cpp.

References DoOneToAllButSender().

bool SpanningTreeUtilities::DoOneToAllButSender const std::string prefix,
const std::string command,
std::deque< std::string > &  params,
std::string  omit
 

Send a message from this server to all but one other, local or remote.

Definition at line 266 of file utils.cpp.

References BestRouteTo(), TreeServer::ChildCount(), TreeServer::GetChild(), TreeServer::GetName(), TreeServer::GetSocket(), TreeRoot, and TreeSocket::WriteLine().

Referenced by TreeSocket::AddLine(), TreeSocket::ChangeHost(), TreeSocket::ChangeName(), TreeSocket::DelLine(), DoOneToAllButSender(), DoOneToAllButSenderRaw(), TreeSocket::Encap(), TreeSocket::ForceJoin(), TreeSocket::ForceMode(), TreeSocket::ForceNick(), TreeSocket::ForceTopic(), TreeSocket::MetaData(), ModuleSpanningTree::OnRehash(), TreeSocket::OperQuit(), TreeSocket::OperType(), TreeSocket::Outbound_Reply_Server(), TreeSocket::ParseUID(), TreeSocket::ProcessLine(), TreeSocket::RemoteKill(), TreeSocket::RemoteServer(), TreeSocket::ServerVersion(), TreeSocket::ServiceJoin(), TreeSocket::ServicePart(), and TreeSocket::Squit().

bool SpanningTreeUtilities::DoOneToAllButSenderRaw const std::string data,
const std::string omit,
const std::string prefix,
const irc::string command,
std::deque< std::string > &  params
 

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)

Definition at line 193 of file utils.cpp.

References BestRouteTo(), TreeServer::ChildCount(), DoOneToAllButSender(), DoOneToOne(), InspIRCd::FindChan(), InspIRCd::FindNick(), ModeParser::FindPrefix(), FOREACH_MOD, TreeServer::GetChild(), GetListOfServersForChannel(), TreeServer::GetName(), TreeServer::GetSocket(), I_OnBuildExemptList, InspIRCd::Modes, MSG_NOTICE, MSG_PRIVMSG, User::server, ServerInstance, TreeRoot, and TreeSocket::WriteLine().

Referenced by TreeSocket::ProcessLine(), and TreeSocket::ServerMessage().

bool SpanningTreeUtilities::DoOneToMany const char *  prefix,
const char *  command,
std::deque< std::string > &  params
 

Send a message from this server to all others.

Definition at line 315 of file utils.cpp.

References DoOneToMany().

bool SpanningTreeUtilities::DoOneToMany const std::string prefix,
const std::string command,
std::deque< std::string > &  params
 

Send a message from this server to all others.

Definition at line 293 of file utils.cpp.

References TreeServer::ChildCount(), TreeServer::GetChild(), TreeServer::GetSocket(), TreeRoot, and TreeSocket::WriteLine().

Referenced by DoOneToMany(), SpanningTreeProtocolInterface::Introduce(), ModuleSpanningTree::OnAddLine(), ModuleSpanningTree::OnChangeHost(), ModuleSpanningTree::OnChangeName(), ModuleSpanningTree::OnDelLine(), ModuleSpanningTree::OnMode(), ModuleSpanningTree::OnOper(), ModuleSpanningTree::OnPostCommand(), ModuleSpanningTree::OnPostLocalTopicChange(), ModuleSpanningTree::OnRemoteKill(), ModuleSpanningTree::OnSetAway(), ModuleSpanningTree::OnUserInvite(), ModuleSpanningTree::OnUserJoin(), ModuleSpanningTree::OnUserKick(), ModuleSpanningTree::OnUserMessage(), ModuleSpanningTree::OnUserNotice(), ModuleSpanningTree::OnUserPart(), ModuleSpanningTree::OnUserPostNick(), ModuleSpanningTree::OnUserQuit(), ModuleSpanningTree::OnWallops(), SpanningTreeProtocolInterface::SendEncapsulatedData(), SpanningTreeProtocolInterface::SendMetaData(), SpanningTreeProtocolInterface::SendMode(), SpanningTreeProtocolInterface::SendModeNotice(), SpanningTreeProtocolInterface::SendSNONotice(), and SpanningTreeProtocolInterface::SendTopic().

bool SpanningTreeUtilities::DoOneToOne const std::string prefix,
const std::string command,
std::deque< std::string > &  params,
std::string  target
 

Send a message from this server to one other local or remote.

Definition at line 329 of file utils.cpp.

References BestRouteTo(), TreeServer::GetSocket(), and TreeSocket::WriteLine().

Referenced by TreeSocket::Admin(), DoOneToAllButSenderRaw(), TreeSocket::Encap(), ModuleSpanningTree::HandleAdmin(), ModuleSpanningTree::HandleMap(), ModuleSpanningTree::HandleModules(), ModuleSpanningTree::HandleMotd(), ModuleSpanningTree::HandleRemoteWhois(), ModuleSpanningTree::HandleStats(), ModuleSpanningTree::HandleTime(), TreeSocket::LocalPing(), TreeSocket::LocalPong(), TreeSocket::Modules(), TreeSocket::Motd(), cmd_rsquit::NoticeUser(), ModuleSpanningTree::OnUserMessage(), ModuleSpanningTree::OnUserNotice(), TreeSocket::Push(), SpanningTreeProtocolInterface::PushToClient(), TreeSocket::Stats(), TreeSocket::Time(), and TreeSocket::Whois().

Link * SpanningTreeUtilities::FindLink const std::string name  ) 
 

Find a link tag from a server name.

Definition at line 620 of file utils.cpp.

References LinkBlocks, and InspIRCd::Match().

Referenced by DoFailOver(), TreeSocket::OnError(), TreeSocket::OnTimeout(), TreeSocket::ProcessLine(), and TreeSocket::RemoteServer().

TreeServer * SpanningTreeUtilities::FindServer const std::string ServerName  ) 
 

Find a server by name.

(read as: lots).

Definition at line 37 of file utils.cpp.

References FindServerID(), and serverlist.

Referenced by TreeSocket::AddLine(), ModuleSpanningTree::AutoConnectServers(), BestRouteTo(), TreeSocket::DelLine(), DoFailOver(), ModuleSpanningTree::HandleConnect(), TreeSocket::Inbound_Server(), SpanningTreeProtocolInterface::Introduce(), IsServer(), TreeSocket::LocalPong(), TreeSocket::MetaData(), TreeSocket::OnClose(), ModuleSpanningTree::OnGetServerDescription(), ServernameResolver::OnLookupComplete(), ModuleSpanningTree::OnUserQuit(), TreeSocket::OperType(), TreeSocket::Outbound_Reply_Server(), TreeSocket::ParseUID(), TreeSocket::ProcessLine(), TreeSocket::RemoteKill(), TreeSocket::RemoteServer(), SpanningTreeProtocolInterface::SendUserNotice(), SpanningTreeProtocolInterface::SendUserPrivmsg(), TreeSocket::SendUsers(), TreeSocket::ServerMessage(), and TreeSocket::ServerVersion().

TreeServer * SpanningTreeUtilities::FindServerID const std::string id  ) 
 

Find server by SID.

Definition at line 99 of file utils.cpp.

References sidlist.

Referenced by FindServer(), and TreeSocket::Inbound_Server().

TreeServer * SpanningTreeUtilities::FindServerMask const std::string ServerName  ) 
 

Find a server by glob mask.

Theres no find-using-glob method of hash_map [awwww :-(] so instead, we iterate over the list using an iterator and match each one until we get a hit. Yes its slow, deal with it.

Definition at line 89 of file utils.cpp.

References InspIRCd::Match(), and serverlist.

Referenced by cmd_rsquit::Handle(), cmd_rconnect::Handle(), ModuleSpanningTree::HandleAdmin(), ModuleSpanningTree::HandleMap(), ModuleSpanningTree::HandleModules(), ModuleSpanningTree::HandleMotd(), ModuleSpanningTree::HandleSquit(), ModuleSpanningTree::HandleStats(), ModuleSpanningTree::HandleTime(), and ModuleSpanningTree::HandleVersion().

void SpanningTreeUtilities::GetListOfServersForChannel Channel c,
TreeServerList list,
char  status,
const CUList exempt_list
 

Compile a list of servers which contain members of channel c.

Definition at line 171 of file utils.cpp.

References AddThisServer(), BestRouteTo(), Channel::GetAllPrefixChars(), Channel::GetUsers(), and IS_LOCAL.

Referenced by DoOneToAllButSenderRaw(), ModuleSpanningTree::OnUserMessage(), ModuleSpanningTree::OnUserNotice(), and SpanningTreeProtocolInterface::SendChannel().

bool SpanningTreeUtilities::IsServer const std::string ServerName  ) 
 

Returns true if this is a server name we recognise.

Definition at line 109 of file utils.cpp.

References FindServer().

Referenced by TreeSocket::ProcessLine().

void SpanningTreeUtilities::ReadConfiguration bool  rebind  ) 
 

Read the spanningtree module's tags from the config file.

Definition at line 413 of file utils.cpp.

References InspIRCd::AddResolver(), Link::AllowMask, AnnounceTSChange, assign(), Link::AutoConnect, Link::Bind, Bindings, InspIRCd::BufferedSocketCull(), ChallengeResponse, BufferedSocket::Close(), Conf, DEFAULT, SocketEngine::DelFd(), DNS_QUERY_A, DNS_QUERY_AAAA, Link::FailOver, FlatLinks, BufferedSocket::GetState(), irc::portparser::GetToken(), Link::Hidden, Link::HiddenFromStats, HideULines, Link::Hook, hooks, I_LISTENING, Link::IPAddr, LinkBlocks, LogManager::Log(), InspIRCd::Logs, Link::Name, Link::NextConnectTime, PingFreq, PingWarnTime, Link::Port, quiet_bursts, ConfigReader::ReadFlag(), ConfigReader::ReadInteger(), ConfigReader::ReadValue(), Link::RecvPass, InspIRCd::SE, Link::SendPass, ServerInstance, Link::Timeout, and ValidIPs.

Referenced by ModuleSpanningTree::OnRehash(), and SpanningTreeUtilities().

void SpanningTreeUtilities::RefreshIPCache  ) 
 

Refresh the IP cache used for allowing inbound connections.

Definition at line 354 of file utils.cpp.

References InspIRCd::AddResolver(), DEFAULT, DNS_QUERY_A, DNS_QUERY_AAAA, LinkBlocks, LogManager::Log(), InspIRCd::Logs, ServerInstance, and ValidIPs.

Referenced by CacheRefreshTimer::Tick().


Member Data Documentation

bool SpanningTreeUtilities::AnnounceTSChange
 

Announce TS changes to channels on merge.

Definition at line 67 of file utils.h.

Referenced by TreeSocket::ForceJoin(), and ReadConfiguration().

std::vector<TreeSocket*> SpanningTreeUtilities::Bindings
 

Socket bindings for listening sockets.

Definition at line 74 of file utils.h.

Referenced by ModuleSpanningTree::OnStats(), ReadConfiguration(), SpanningTreeUtilities(), and ~SpanningTreeUtilities().

std::map<irc::string,TreeSocket*> SpanningTreeUtilities::burstingserverlist
 

Hash of servers currently bursting but not initialized as connected.

Definition at line 93 of file utils.h.

bool SpanningTreeUtilities::ChallengeResponse
 

True (default) if we are to use challenge-response HMAC to authenticate passwords.

NOTE: This defaults to on, but should be turned off if you are linking to an older version of inspircd.

Definition at line 112 of file utils.h.

Referenced by TreeSocket::Capab(), TreeSocket::ComparePass(), TreeSocket::MakePass(), ReadConfiguration(), and TreeSocket::SendCapabilities().

ModuleSpanningTree* SpanningTreeUtilities::Creator
 

Creator module.

Definition at line 57 of file utils.h.

Referenced by TreeSocket::DoBurst(), DoFailOver(), TreeServer::FinishBurst(), TreeSocket::Inbound_Server(), TreeSocket::MakePass(), TreeSocket::OnClose(), TreeSocket::OnConnected(), TreeSocket::OnError(), ServernameResolver::OnError(), TreeSocket::OnIncomingConnection(), ServernameResolver::OnLookupComplete(), TreeSocket::OnTimeout(), TreeSocket::ProcessLine(), TreeSocket::SendChannelModes(), TreeSocket::SendError(), TreeSocket::SendUsers(), SpanningTreeUtilities(), TreeSocket::Squit(), HandshakeTimer::Tick(), TreeSocket::TreeSocket(), and TreeSocket::~TreeSocket().

bool SpanningTreeUtilities::FlatLinks
 

Flatten links and /MAP for non-opers.

Definition at line 61 of file utils.h.

Referenced by ReadConfiguration(), ModuleSpanningTree::ShowLinks(), and ModuleSpanningTree::ShowMap().

bool SpanningTreeUtilities::HideULines
 

Hide U-Lined servers in /MAP and /LINKS.

Definition at line 64 of file utils.h.

Referenced by ModuleSpanningTree::HandleLusers(), ReadConfiguration(), ModuleSpanningTree::ShowLinks(), and ModuleSpanningTree::ShowMap().

std::vector<std::string> SpanningTreeUtilities::hooknames
 

List of module names which can provide I/O abstraction.

Definition at line 104 of file utils.h.

Referenced by SpanningTreeUtilities().

hookmodules SpanningTreeUtilities::hooks
 

List of module pointers which can provide I/O abstraction.

Definition at line 100 of file utils.h.

Referenced by ModuleSpanningTree::ConnectServer(), ServernameResolver::OnLookupComplete(), ReadConfiguration(), and SpanningTreeUtilities().

std::vector<Link> SpanningTreeUtilities::LinkBlocks
 

Holds the data from the <link> tags in the conf.

Definition at line 96 of file utils.h.

Referenced by ModuleSpanningTree::AutoConnectServers(), FindLink(), ModuleSpanningTree::HandleConnect(), TreeSocket::Inbound_Server(), TreeSocket::OnConnected(), ModuleSpanningTree::OnStats(), TreeSocket::Outbound_Reply_Server(), ReadConfiguration(), RefreshIPCache(), and TreeSocket::TreeSocket().

int SpanningTreeUtilities::PingFreq
 

Ping frequency of server to server links.

Definition at line 116 of file utils.h.

Referenced by ModuleSpanningTree::DoPingChecks(), TreeSocket::ProcessLine(), ReadConfiguration(), and TreeServer::TreeServer().

int SpanningTreeUtilities::PingWarnTime
 

Definition at line 78 of file utils.h.

Referenced by ModuleSpanningTree::DoPingChecks(), and ReadConfiguration().

bool SpanningTreeUtilities::quiet_bursts
 

Make snomasks +CQ quiet during bursts and splits.

Definition at line 71 of file utils.h.

Referenced by ReadConfiguration().

InspIRCd* SpanningTreeUtilities::ServerInstance [private]
 

Creator server.

Definition at line 53 of file utils.h.

Referenced by BestRouteTo(), DoFailOver(), DoOneToAllButSenderRaw(), ReadConfiguration(), RefreshIPCache(), SpanningTreeUtilities(), and ~SpanningTreeUtilities().

server_hash SpanningTreeUtilities::serverlist
 

Hash of currently connected servers by name.

Definition at line 87 of file utils.h.

Referenced by TreeServer::AddHashEntry(), ModuleSpanningTree::CountServs(), TreeServer::DelHashEntry(), ModuleSpanningTree::DoPingChecks(), FindServer(), FindServerMask(), SpanningTreeProtocolInterface::GetServerList(), and ModuleSpanningTree::HandleLusers().

server_hash SpanningTreeUtilities::sidlist
 

Hash of currently known server ids.

Definition at line 90 of file utils.h.

Referenced by FindServerID(), TreeServer::SetID(), and TreeServer::~TreeServer().

TreeServer* SpanningTreeUtilities::TreeRoot
 

This variable represents the root of the server tree.

Definition at line 81 of file utils.h.

Referenced by BestRouteTo(), ModuleSpanningTree::CountLocalServs(), TreeSocket::DoBurst(), DoOneToAllButSender(), DoOneToAllButSenderRaw(), DoOneToMany(), cmd_rsquit::Handle(), ModuleSpanningTree::HandleLinks(), ModuleSpanningTree::HandleLusers(), ModuleSpanningTree::HandleMap(), ModuleSpanningTree::HandleSquit(), ModuleSpanningTree::HandleTime(), ModuleSpanningTree::HandleVersion(), TreeSocket::Outbound_Reply_Server(), TreeSocket::ProcessLine(), ModuleSpanningTree::ShowLinks(), SpanningTreeUtilities(), TreeSocket::Squit(), TreeServer::TreeServer(), and ~SpanningTreeUtilities().

std::vector<std::string> SpanningTreeUtilities::ValidIPs
 

IPs allowed to link to us.

Definition at line 84 of file utils.h.

Referenced by TreeSocket::OnIncomingConnection(), SecurityIPResolver::OnLookupComplete(), ReadConfiguration(), and RefreshIPCache().


The documentation for this class was generated from the following files: