summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-04-05 21:57:48 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-04-05 21:57:48 +0000
commitaec772bdc98bdcfe35c2fc8e74942403c9efcc4d (patch)
treed53e05bf3ba1642b669fa8a981d06022e8088434 /src/modules/m_spanningtree
parent1997b706416324bded467d7abf34667dfe4b6ff2 (diff)
Add extra /map info (connection uptime, and lag time) to /MAP for opers. Adds feature requested by bug #246
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6737 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/main.cpp19
-rw-r--r--src/modules/m_spanningtree/main.h4
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp3
-rw-r--r--src/modules/m_spanningtree/treeserver.h8
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp1
5 files changed, 34 insertions, 1 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 9cf068f92..673c2cda1 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -137,6 +137,21 @@ void ModuleSpanningTree::HandleLusers(const char** parameters, int pcnt, userrec
return;
}
+const std::string ModuleSpanningTree::MapOperInfo(TreeServer* Current)
+{
+ time_t secs_up = ServerInstance->Time() - Current->age;
+ time_t mins_up = secs_up / 60;
+ time_t hours_up = mins_up / 60;
+ time_t days_up = hours_up / 24;
+ secs_up = secs_up % 60;
+ mins_up = mins_up % 60;
+ hours_up = hours_up % 24;
+ return (" [Up: "+ (days_up ? (ConvToStr(days_up) + "d") : std::string(""))
+ + (hours_up ? (ConvToStr(hours_up) + "h") : std::string(""))
+ + (mins_up ? (ConvToStr(mins_up) + "m") : std::string(""))
+ + ConvToStr(secs_up) + "s Lag: "+ConvToStr(Current->rtt)+"s]");
+}
+
// WARNING: NOT THREAD SAFE - DONT GET ANY SMART IDEAS.
void ModuleSpanningTree::ShowMap(TreeServer* Current, userrec* user, int depth, char matrix[128][80], float &totusers, float &totservers)
{
@@ -167,7 +182,8 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, userrec* user, int depth,
{
percent = ((float)Current->GetUserCount() / (float)ServerInstance->clientlist->size()) * 100;
}
- snprintf(text, 80, "%s %s%5d [%5.2f%%]", Current->GetName().c_str(), spacer, Current->GetUserCount(), percent);
+ const std::string operdata = IS_OPER(user) ? MapOperInfo(Current) : "";
+ snprintf(text, 80, "%s %s%5d [%5.2f%%]%s", Current->GetName().c_str(), spacer, Current->GetUserCount(), percent, operdata.c_str());
totusers += Current->GetUserCount();
totservers++;
strlcpy(&matrix[line][depth],text,80);
@@ -433,6 +449,7 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime)
{
sock->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" PING "+serv->GetName());
serv->SetNextPingTime(curtime + 60);
+ serv->LastPing = curtime;
}
else
{
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 2c5d08c6a..062ee283b 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -123,6 +123,10 @@ class ModuleSpanningTree : public Module
*/
void BroadcastTimeSync();
+ /** Returns oper-specific MAP information
+ */
+ const std::string MapOperInfo(TreeServer* Current);
+
/**
** *** MODULE EVENTS ***
**/
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index 8930a7188..f53e88395 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -22,6 +22,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance) : Server
ServerDesc = "";
VersionString = "";
UserCount = OperCount = 0;
+ rtt = LastPing = 0;
VersionString = ServerInstance->GetVersionString();
}
@@ -38,6 +39,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
VersionString = ServerInstance->GetVersionString();
Route = NULL;
Socket = NULL; /* Fix by brain */
+ rtt = LastPing = 0;
AddHashEntry();
}
@@ -52,6 +54,7 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
UserCount = OperCount = 0;
this->SetNextPingTime(time(NULL) + 60);
this->SetPingFlag();
+ rtt = LastPing = 0;
/* find the 'route' for this server (e.g. the one directly connected
* to the local server, which we can use to reach it)
*
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index 8ce7ae041..1d053112d 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -90,6 +90,14 @@ class TreeServer : public classbase
*/
time_t NextPingTime();
+ /** Time of last ping used to calculate this->rtt below
+ */
+ time_t LastPing;
+
+ /** Round trip time of last ping
+ */
+ time_t rtt;
+
/** True if the server answered their last ping
*/
bool AnsweredLastPing();
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 52b31ec57..7d1e3d99b 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -400,6 +400,7 @@ bool TreeSocket::LocalPong(const std::string &prefix, std::deque<std::string> &p
if (ServerSource)
{
ServerSource->SetPingFlag();
+ ServerSource->rtt = Instance->Time() - ServerSource->LastPing;
}
}
else