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

TreeServer Class Reference

Each server in the tree is represented by one class of type TreeServer. More...

#include <treeserver.h>

Inheritance diagram for TreeServer:

Inheritance graph
[legend]
Collaboration diagram for TreeServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TreeServer (SpanningTreeUtilities *Util, InspIRCd *Instance, const std::string &id)
 We don't use this constructor.
 TreeServer (SpanningTreeUtilities *Util, InspIRCd *Instance, std::string Name, std::string Desc, const std::string &id)
 We use this constructor only to create the 'root' item, Utils->TreeRoot, which represents our own server.
 TreeServer (SpanningTreeUtilities *Util, InspIRCd *Instance, std::string Name, std::string Desc, const std::string &id, TreeServer *Above, TreeSocket *Sock, bool Hide)
 When we create a new server, we call this constructor to initialize it.
int QuitUsers (const std::string &reason)
void AddHashEntry ()
 This method is used to add the structure to the hash_map for linear searches.
void DelHashEntry ()
 This method removes the reference to this object from the hash_map which is used for linear searches.
TreeServerGetRoute ()
 Get route.
std::string GetName ()
 Get server name.
std::string GetDesc ()
 Get server description (GECOS).
std::string GetVersion ()
 Get server version string.
void SetNextPingTime (time_t t)
 Set time we are next due to ping this server.
time_t NextPingTime ()
 Get the time we are next due to ping this server.
bool AnsweredLastPing ()
 True if the server answered their last ping.
void SetPingFlag ()
 Set the server as responding to its last ping.
unsigned int GetUserCount ()
 Get the number of users on this server.
void SetUserCount (int diff)
 Increment or decrement the user count by diff.
unsigned int GetOperCount ()
 Gets the numbers of opers on this server.
void SetOperCount (int diff)
 Increment or decrement the oper count by diff.
TreeSocketGetSocket ()
 Get the TreeSocket pointer for local servers.
TreeServerGetParent ()
 Get the parent server.
void SetVersion (const std::string &Version)
 Set the server version string.
unsigned int ChildCount ()
 Return number of child servers.
TreeServerGetChild (unsigned int n)
 Return a child server indexed 0.
void AddChild (TreeServer *Child)
 Add a child server.
bool DelChild (TreeServer *Child)
 Delete a child server, return false if it didn't exist.
bool Tidy ()
 Removes child nodes of this node, and of that node, etc etc.
std::stringGetID ()
 Get server ID.
bool DuplicateID ()
 True on duplicate server ID (server not usable).
void FinishBurst ()
 Marks a server as having finished bursting and performs appropriate actions.
 ~TreeServer ()
 Destructor.

Public Attributes

bool Warned
bool bursting
unsigned long LastPingMsec
 Last ping time in microseconds, used to calculate round trip time.
unsigned long rtt
 Round trip time of last ping.
unsigned long StartBurst
 When we recieved BURST from this server, used to calculate total burst time at ENDBURST.
bool Hidden
 True if this server is hidden.

Private Member Functions

void SetID (const std::string &id)
 Set server ID.

Private Attributes

InspIRCdServerInstance
TreeServerParent
TreeServerRoute
std::vector< TreeServer * > Children
irc::string ServerName
std::string ServerDesc
std::string VersionString
unsigned int ServerUserCount
unsigned int ServerOperCount
TreeSocketSocket
time_t NextPing
bool LastPingWasGood
SpanningTreeUtilitiesUtils
std::string sid
bool DupError

Detailed Description

Each server in the tree is represented by one class of type TreeServer.

A locally connected TreeServer can have a class of type TreeSocket associated with it, for remote servers, the TreeSocket entry will be NULL. Each server also maintains a pointer to its parent (NULL if this server is ours, at the top of the tree) and a pointer to its "Route" (see the comments in the constructors below), and also a dynamic list of pointers to its children which can be iterated recursively if required. Creating or deleting objects of type i* TreeServer automatically maintains the hash_map of TreeServer items, deleting and inserting them as they are created and destroyed.

Definition at line 31 of file treeserver.h.


Constructor & Destructor Documentation

TreeServer::TreeServer SpanningTreeUtilities Util,
InspIRCd Instance,
const std::string id
 

We don't use this constructor.

Its a dummy, and won't cause any insertion of the TreeServer into the hash_map. See below for the two we DO use.

Definition at line 26 of file treeserver.cpp.

References bursting, DupError, InspIRCd::GetVersionString(), Hidden, Parent, rtt, ServerDesc, ServerInstance, ServerName, ServerOperCount, ServerUserCount, SetID(), StartBurst, VersionString, and Warned.

TreeServer::TreeServer SpanningTreeUtilities Util,
InspIRCd Instance,
std::string  Name,
std::string  Desc,
const std::string id
 

We use this constructor only to create the 'root' item, Utils->TreeRoot, which represents our own server.

Therefore, it has no route, no parent, and no socket associated with it. Its version string is our own local version.

Definition at line 44 of file treeserver.cpp.

References AddHashEntry(), bursting, DupError, InspIRCd::GetVersionString(), Hidden, Parent, Route, rtt, ServerInstance, ServerOperCount, ServerUserCount, SetID(), Socket, StartBurst, VersionString, and Warned.

TreeServer::TreeServer SpanningTreeUtilities Util,
InspIRCd Instance,
std::string  Name,
std::string  Desc,
const std::string id,
TreeServer Above,
TreeSocket Sock,
bool  Hide
 

When we create a new server, we call this constructor to initialize it.

This constructor initializes the server's Route and Parent, and sets up its ping counters so that it will be pinged one minute from now.

Definition at line 64 of file treeserver.cpp.

References AddHashEntry(), bursting, DEBUG, DupError, GetParent(), LogManager::Log(), InspIRCd::Logs, SpanningTreeUtilities::PingFreq, Route, rtt, ServerInstance, ServerOperCount, ServerUserCount, SetID(), SetNextPingTime(), SetPingFlag(), StartBurst, InspIRCd::Time(), SpanningTreeUtilities::TreeRoot, Utils, VersionString, and Warned.

TreeServer::~TreeServer  ) 
 

Destructor.

Definition at line 363 of file treeserver.cpp.

References DelHashEntry(), GetID(), SpanningTreeUtilities::sidlist, and Utils.


Member Function Documentation

void TreeServer::AddChild TreeServer Child  ) 
 

Add a child server.

Definition at line 322 of file treeserver.cpp.

References Children.

Referenced by TreeSocket::Outbound_Reply_Server(), TreeSocket::ProcessLine(), and TreeSocket::RemoteServer().

void TreeServer::AddHashEntry  ) 
 

This method is used to add the structure to the hash_map for linear searches.

It is only called by the constructors.

Definition at line 203 of file treeserver.cpp.

References SpanningTreeUtilities::serverlist, ServerName, and Utils.

Referenced by TreeServer().

bool TreeServer::AnsweredLastPing  ) 
 

True if the server answered their last ping.

Definition at line 255 of file treeserver.cpp.

References LastPingWasGood.

Referenced by ModuleSpanningTree::DoPingChecks().

unsigned int TreeServer::ChildCount  ) 
 

Return number of child servers.

Definition at line 300 of file treeserver.cpp.

References Children.

Referenced by ModuleSpanningTree::CountLocalServs(), SpanningTreeUtilities::DoOneToAllButSender(), SpanningTreeUtilities::DoOneToAllButSenderRaw(), SpanningTreeUtilities::DoOneToMany(), and SpanningTreeUtilities::~SpanningTreeUtilities().

bool TreeServer::DelChild TreeServer Child  ) 
 

Delete a child server, return false if it didn't exist.

Definition at line 327 of file treeserver.cpp.

References Children.

Referenced by TreeSocket::Squit().

void TreeServer::DelHashEntry  ) 
 

This method removes the reference to this object from the hash_map which is used for linear searches.

It is only called by the default destructor.

Definition at line 214 of file treeserver.cpp.

References SpanningTreeUtilities::serverlist, and Utils.

Referenced by ~TreeServer().

bool TreeServer::DuplicateID  ) 
 

True on duplicate server ID (server not usable).

Definition at line 166 of file treeserver.cpp.

References DupError.

Referenced by TreeSocket::Outbound_Reply_Server(), TreeSocket::ProcessLine(), and TreeSocket::RemoteServer().

void TreeServer::FinishBurst  ) 
 

Marks a server as having finished bursting and performs appropriate actions.

Definition at line 142 of file treeserver.cpp.

References XLineManager::ApplyLines(), bursting, SpanningTreeUtilities::Creator, Event::Send(), ServerInstance, ServerName, InspIRCd::SNO, StartBurst, Utils, SnomaskManager::WriteToSnoMask(), and InspIRCd::XLines.

Referenced by TreeSocket::ProcessLine().

TreeServer * TreeServer::GetChild unsigned int  n  ) 
 

Return a child server indexed 0.

.n

Definition at line 305 of file treeserver.cpp.

References Children.

Referenced by SpanningTreeUtilities::DoOneToAllButSender(), SpanningTreeUtilities::DoOneToAllButSenderRaw(), SpanningTreeUtilities::DoOneToMany(), TreeSocket::SendServers(), ModuleSpanningTree::ShowLinks(), ModuleSpanningTree::ShowMap(), TreeSocket::SquitServer(), and SpanningTreeUtilities::~SpanningTreeUtilities().

std::string TreeServer::GetDesc  ) 
 

Get server description (GECOS).

Definition at line 234 of file treeserver.cpp.

References ServerDesc.

Referenced by ModuleSpanningTree::OnGetServerDescription(), TreeSocket::SendServers(), and ModuleSpanningTree::ShowLinks().

std::string & TreeServer::GetID  ) 
 

Get server ID.

Definition at line 137 of file treeserver.cpp.

References sid.

Referenced by ModuleSpanningTree::DoPingChecks(), TreeSocket::Inbound_Server(), TreeSocket::ProcessLine(), TreeSocket::SendServers(), TreeSocket::SendUsers(), ModuleSpanningTree::ShowMap(), and ~TreeServer().

std::string TreeServer::GetName  ) 
 

Get server name.

Definition at line 229 of file treeserver.cpp.

References ServerName.

Referenced by TreeSocket::AddLine(), SpanningTreeUtilities::BestRouteTo(), TreeSocket::DelLine(), TreeSocket::DoBurst(), SpanningTreeUtilities::DoOneToAllButSender(), SpanningTreeUtilities::DoOneToAllButSenderRaw(), ModuleSpanningTree::DoPingChecks(), SpanningTreeProtocolInterface::GetServerList(), ModuleSpanningTree::HandleAdmin(), ModuleSpanningTree::HandleConnect(), ModuleSpanningTree::HandleMap(), ModuleSpanningTree::HandleModules(), ModuleSpanningTree::HandleMotd(), ModuleSpanningTree::HandleStats(), ModuleSpanningTree::HandleTime(), TreeSocket::Inbound_Server(), TreeSocket::Outbound_Reply_Server(), TreeSocket::ParseUID(), TreeSocket::ProcessLine(), TreeSocket::RemoteKill(), TreeSocket::RemoteServer(), TreeSocket::SendServers(), TreeSocket::ServerMessage(), ModuleSpanningTree::ShowLinks(), ModuleSpanningTree::ShowMap(), and TreeSocket::Squit().

unsigned int TreeServer::GetOperCount  ) 
 

Gets the numbers of opers on this server.

Definition at line 280 of file treeserver.cpp.

References ServerOperCount.

TreeServer * TreeServer::GetParent  ) 
 

Get the parent server.

For the root node, this returns NULL.

Definition at line 290 of file treeserver.cpp.

References Parent.

Referenced by cmd_rsquit::Handle(), ModuleSpanningTree::HandleConnect(), TreeSocket::Inbound_Server(), TreeSocket::Outbound_Reply_Server(), ModuleSpanningTree::ShowLinks(), TreeSocket::Squit(), and TreeServer().

TreeServer * TreeServer::GetRoute  ) 
 

Get route.

The 'route' is defined as the locally- connected server which can be used to reach this server.

Definition at line 224 of file treeserver.cpp.

References Route.

Referenced by SpanningTreeUtilities::BestRouteTo().

TreeSocket * TreeServer::GetSocket  ) 
 

Get the TreeSocket pointer for local servers.

For remote servers, this returns NULL.

Definition at line 285 of file treeserver.cpp.

References Socket.

Referenced by SpanningTreeUtilities::DoOneToAllButSender(), SpanningTreeUtilities::DoOneToAllButSenderRaw(), SpanningTreeUtilities::DoOneToMany(), SpanningTreeUtilities::DoOneToOne(), ModuleSpanningTree::DoPingChecks(), TreeSocket::ForceJoin(), cmd_rsquit::Handle(), ModuleSpanningTree::HandleSquit(), TreeSocket::ProcessLine(), SpanningTreeProtocolInterface::SendUserNotice(), SpanningTreeProtocolInterface::SendUserPrivmsg(), and SpanningTreeUtilities::~SpanningTreeUtilities().

unsigned int TreeServer::GetUserCount  ) 
 

Get the number of users on this server.

Definition at line 265 of file treeserver.cpp.

References ServerUserCount.

Referenced by ModuleSpanningTree::ShowMap().

std::string TreeServer::GetVersion  ) 
 

Get server version string.

Definition at line 239 of file treeserver.cpp.

References VersionString.

Referenced by ModuleSpanningTree::HandleVersion(), and TreeSocket::SendServers().

time_t TreeServer::NextPingTime  ) 
 

Get the time we are next due to ping this server.

Definition at line 250 of file treeserver.cpp.

References NextPing.

Referenced by ModuleSpanningTree::DoPingChecks().

int TreeServer::QuitUsers const std::string reason  ) 
 

Definition at line 171 of file treeserver.cpp.

References UserManager::clientlist, InspIRCd::Config, InspIRCd::GlobalCulls, ServerConfig::HideSplits, IS_LOCAL, CullList::MakeSilent(), UserManager::QuitUser(), ServerInstance, and InspIRCd::Users.

Referenced by TreeSocket::SquitServer().

void TreeServer::SetID const std::string id  )  [private]
 

Set server ID.

Parameters:
id Server ID
Exceptions:
CoreException on duplicate ID

Definition at line 155 of file treeserver.cpp.

References DEBUG, DupError, LogManager::Log(), InspIRCd::Logs, ServerInstance, sid, SpanningTreeUtilities::sidlist, and Utils.

Referenced by TreeServer().

void TreeServer::SetNextPingTime time_t  t  ) 
 

Set time we are next due to ping this server.

Definition at line 244 of file treeserver.cpp.

References LastPingWasGood, and NextPing.

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

void TreeServer::SetOperCount int  diff  ) 
 

Increment or decrement the oper count by diff.

Definition at line 275 of file treeserver.cpp.

References ServerOperCount.

void TreeServer::SetPingFlag  ) 
 

Set the server as responding to its last ping.

Definition at line 260 of file treeserver.cpp.

References LastPingWasGood.

Referenced by TreeSocket::LocalPong(), TreeSocket::ProcessLine(), and TreeServer().

void TreeServer::SetUserCount int  diff  ) 
 

Increment or decrement the user count by diff.

Definition at line 270 of file treeserver.cpp.

References ServerUserCount.

Referenced by SpanningTreeProtocolInterface::Introduce(), and ModuleSpanningTree::OnUserQuit().

void TreeServer::SetVersion const std::string Version  ) 
 

Set the server version string.

Definition at line 295 of file treeserver.cpp.

References VersionString.

Referenced by TreeSocket::ServerVersion().

bool TreeServer::Tidy  ) 
 

Removes child nodes of this node, and of that node, etc etc.

This is used during netsplits to automatically tidy up the server tree. It is slow, we don't use it for much else.

Definition at line 344 of file treeserver.cpp.

References Children, and Tidy().

Referenced by TreeSocket::Squit(), and Tidy().


Member Data Documentation

bool TreeServer::bursting
 

Definition at line 58 of file treeserver.h.

Referenced by TreeSocket::AddLine(), FinishBurst(), TreeSocket::OperType(), TreeSocket::Outbound_Reply_Server(), TreeSocket::ParseUID(), TreeSocket::ProcessLine(), and TreeServer().

std::vector<TreeServer*> TreeServer::Children [private]
 

Definition at line 36 of file treeserver.h.

Referenced by AddChild(), ChildCount(), DelChild(), GetChild(), and Tidy().

bool TreeServer::DupError [private]
 

Definition at line 47 of file treeserver.h.

Referenced by DuplicateID(), SetID(), and TreeServer().

bool TreeServer::Hidden
 

True if this server is hidden.

Definition at line 131 of file treeserver.h.

Referenced by TreeSocket::Outbound_Reply_Server(), ModuleSpanningTree::ShowLinks(), ModuleSpanningTree::ShowMap(), and TreeServer().

unsigned long TreeServer::LastPingMsec
 

Last ping time in microseconds, used to calculate round trip time.

Definition at line 119 of file treeserver.h.

Referenced by ModuleSpanningTree::DoPingChecks(), and TreeSocket::LocalPong().

bool TreeServer::LastPingWasGood [private]
 

Definition at line 44 of file treeserver.h.

Referenced by AnsweredLastPing(), SetNextPingTime(), and SetPingFlag().

time_t TreeServer::NextPing [private]
 

Definition at line 43 of file treeserver.h.

Referenced by NextPingTime(), and SetNextPingTime().

TreeServer* TreeServer::Parent [private]
 

Definition at line 34 of file treeserver.h.

Referenced by GetParent(), and TreeServer().

TreeServer* TreeServer::Route [private]
 

Definition at line 35 of file treeserver.h.

Referenced by GetRoute(), and TreeServer().

unsigned long TreeServer::rtt
 

Round trip time of last ping.

Definition at line 123 of file treeserver.h.

Referenced by TreeSocket::LocalPong(), ModuleSpanningTree::MapOperInfo(), and TreeServer().

std::string TreeServer::ServerDesc [private]
 

Definition at line 38 of file treeserver.h.

Referenced by GetDesc(), and TreeServer().

InspIRCd* TreeServer::ServerInstance [private]
 

Definition at line 33 of file treeserver.h.

Referenced by FinishBurst(), QuitUsers(), SetID(), and TreeServer().

irc::string TreeServer::ServerName [private]
 

Definition at line 37 of file treeserver.h.

Referenced by AddHashEntry(), FinishBurst(), GetName(), and TreeServer().

unsigned int TreeServer::ServerOperCount [private]
 

Definition at line 41 of file treeserver.h.

Referenced by GetOperCount(), SetOperCount(), and TreeServer().

unsigned int TreeServer::ServerUserCount [private]
 

Definition at line 40 of file treeserver.h.

Referenced by GetUserCount(), SetUserCount(), and TreeServer().

std::string TreeServer::sid [private]
 

Definition at line 46 of file treeserver.h.

Referenced by GetID(), and SetID().

TreeSocket* TreeServer::Socket [private]
 

Definition at line 42 of file treeserver.h.

Referenced by GetSocket(), and TreeServer().

unsigned long TreeServer::StartBurst
 

When we recieved BURST from this server, used to calculate total burst time at ENDBURST.

Definition at line 127 of file treeserver.h.

Referenced by FinishBurst(), and TreeServer().

SpanningTreeUtilities* TreeServer::Utils [private]
 

Definition at line 45 of file treeserver.h.

Referenced by AddHashEntry(), DelHashEntry(), FinishBurst(), SetID(), TreeServer(), and ~TreeServer().

std::string TreeServer::VersionString [private]
 

Definition at line 39 of file treeserver.h.

Referenced by GetVersion(), SetVersion(), and TreeServer().

bool TreeServer::Warned
 

Definition at line 57 of file treeserver.h.

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


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