summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-13 14:16:04 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-05-13 14:16:04 +0000
commit7555c1801d81d2f8ac2d4b953135ff980037f6b4 (patch)
treeced01b654c7775a21bbdccceab06023762acba75 /src/modules
parentcb8e65e27064cb632050f1975aec27ed81cbefae (diff)
Poach feature request: If a server does not respond after x seconds to a PING, send a warning to opers via +l snomask.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7010 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_spanningtree/main.cpp7
-rw-r--r--src/modules/m_spanningtree/treeserver.h2
-rw-r--r--src/modules/m_spanningtree/utils.cpp5
-rw-r--r--src/modules/m_spanningtree/utils.h4
4 files changed, 18 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 09574f15f..4dc6eedc0 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -463,6 +463,7 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime)
sock->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" PING "+serv->GetName());
serv->SetNextPingTime(curtime + 60);
serv->LastPing = curtime;
+ serv->Warned = false;
}
else
{
@@ -476,6 +477,12 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime)
return;
}
}
+ else if ((Utils->PingWarnTime) && (!serv->Warned) && (curtime >= serv->NextPingTime() - (60 - Utils->PingWarnTime)) && (!serv->AnsweredLastPing()))
+ {
+ /* The server hasnt responded, send a warning to opers */
+ ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not responded to PING for %d seconds, high latency.", serv->GetName().c_str(), Utils->PingWarnTime);
+ serv->Warned = true;
+ }
}
}
}
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index c65fc0dee..514d6bc07 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -46,6 +46,8 @@ class TreeServer : public classbase
public:
+ bool Warned; /* True if we've warned opers about high latency on this server */
+
/** 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.
*/
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index a27dd5f65..680fe5eb1 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -505,6 +505,11 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
MasterTime = Conf->ReadFlag("timesync", "master", 0);
ChallengeResponse = !Conf->ReadFlag("options", "disablehmac", 0);
quiet_bursts = Conf->ReadFlag("options", "quietbursts", 0);
+ PingWarnTime = Conf->ReadInteger("options", "pingwarning", 0, true);
+
+ if (PingWarnTime < 0 || PingWarnTime > 59)
+ PingWarnTime = 0;
+
LinkBlocks.clear();
ValidIPs.clear();
for (int j =0; j < Conf->Enumerate("link"); j++)
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index f9f61acaf..1c94e264f 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -72,6 +72,10 @@ class SpanningTreeUtilities
/** Socket bindings for listening sockets
*/
std::vector<TreeSocket*> Bindings;
+ /* Number of seconds that a server can go without ping
+ * before opers are warned of high latency.
+ */
+ int PingWarnTime;
/** This variable represents the root of the server tree
*/
TreeServer *TreeRoot;