* TreeServer items, deleting and inserting them as they
* are created and destroyed.
*/
-class TreeServer : public classbase
+class TreeServer : public Server
{
TreeServer* Parent; /* Parent entry */
TreeServer* Route; /* Route entry */
std::vector<TreeServer*> Children; /* List of child objects */
- std::string ServerName; /* Server's name */
- std::string ServerDesc; /* Server's description */
std::string VersionString; /* Version string or empty string */
- TreeSocket* Socket; /* For directly connected servers this points at the socket object */
+
+ /** Full version string including patch version and other info
+ */
+ std::string fullversion;
+
+ TreeSocket* Socket; /* Socket used to communicate with this server */
time_t NextPing; /* After this time, the server should be PINGed*/
bool LastPingWasGood; /* True if the server responded to the last PING with a PONG */
std::string sid; /* Server ID */
void AddHashEntry();
public:
+ typedef std::vector<TreeServer*> ChildServers;
FakeUser* const ServerUser; /* User representing this server */
const time_t age;
*/
TreeServer* GetRoute();
- /** Get server name
+ /** Returns true if this server is the tree root (i.e.: us)
*/
- const std::string& GetName() const { return ServerName; }
+ bool IsRoot() const { return (this->Parent == NULL); }
- /** Get server description (GECOS)
+ /** Returns true if this server is locally connected
*/
- const std::string& GetDesc();
+ bool IsLocal() const { return (this->Route == this); }
/** Get server version string
*/
const std::string& GetVersion();
+ /** Get the full version string of this server
+ * @return The full version string of this server, including patch version and other info
+ */
+ const std::string& GetFullVersion() const { return fullversion; }
+
/** Set time we are next due to ping this server
*/
void SetNextPingTime(time_t t);
*/
void SetVersion(const std::string &Version);
- /** Return number of child servers
+ /** Set the full version string
+ * @param verstr The version string to set
*/
- unsigned int ChildCount();
+ void SetFullVersion(const std::string& verstr) { fullversion = verstr; }
- /** Return a child server indexed 0..n
+ /** Sets the description of this server. Called when the description of a remote server changes
+ * and we are notified about it.
+ * @param descstr The description to set
*/
- TreeServer* GetChild(unsigned int n);
+ void SetDesc(const std::string& descstr) { description = descstr; }
+
+ /** Return all child servers
+ */
+ const ChildServers& GetChildren() const { return Children; }
/** Add a child server
*/
* This is used during netsplits to automatically tidy up the
* server tree. It is slow, we don't use it for much else.
*/
- bool Tidy();
+ void Tidy();
/** Get server ID
*/
/** Recursive call for child servers */
void FinishBurstInternal();
+ /** (Re)check the uline state of this server
+ */
+ void CheckULine();
+
CullResult cull();
/** Destructor
* hash maps.
*/
~TreeServer();
+
+ /** Returns the TreeServer the given user is connected to
+ * @param user The user whose server to return
+ * @return The TreeServer this user is connected to.
+ */
+ static TreeServer* Get(User* user)
+ {
+ return static_cast<TreeServer*>(user->server);
+ }
};