Warn opers about unresponsive servers

This commit is contained in:
David Schultz 2023-06-13 09:13:42 -05:00 committed by GitHub
parent fe83a33526
commit d1c028f212
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 0 deletions

View file

@ -1315,6 +1315,13 @@ general {
*/
ping_cookie = no;
/* ping warn time: how long to wait after pinging a server before starting
* to complain it is unresponsive. Note that the ping check interval is 30
* seconds, so the first complaint will come at the next check after this
* time has passed.
*/
ping_warn_time = 15 seconds;
/* connect timeout: sets how long we should wait for a connection
* request to succeed
*/

View file

@ -419,6 +419,7 @@ struct ListClient
#define FLAGS_EXEMPTSHIDE 0x04000000
#define FLAGS_EXEMPTJUPE 0x08000000
#define FLAGS_IDENTIFIED 0x10000000 /* owns their current nick */
#define FLAGS_PINGWARN 0x20000000 /* whether we've warned about this client being unresponsive */
/* flags for local clients, this needs stuff moved from above to here at some point */

View file

@ -204,6 +204,7 @@ struct config_file_entry
int operspy_admin_only;
int pace_wait;
int pace_wait_simple;
int ping_warn_time;
int short_motd;
int no_oper_flood;
int hide_server;

View file

@ -420,6 +420,27 @@ check_pings_list(rb_dlink_list * list)
client_p->localClient->lasttime = rb_current_time() - ping;
sendto_one(client_p, "PING :%s", me.name);
}
else if (ConfigFileEntry.ping_warn_time > 0 && (IsServer(client_p) || IsHandshake(client_p)) &&
(rb_current_time() - client_p->localClient->lasttime) >= (ping + ConfigFileEntry.ping_warn_time))
{
/*
* if we haven't heard from a server in a while,
* warn opers that something could be wrong...
*
* we'll do this about every 30 seconds until
* the server either becomes responsive or
* pings out. whichever comes first.
*/
client_p->flags |= FLAGS_PINGWARN;
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"Warning: No response from %s for %ld seconds",
client_p->name,
(rb_current_time() - client_p->localClient->lasttime - ping));
ilog(L_SERVER,
"Warning: No response from %s for %ld seconds",
log_client_name(client_p, HIDE_IP),
(rb_current_time() - client_p->localClient->lasttime - ping));
}
}
/* ping_timeout: */

View file

@ -2751,6 +2751,7 @@ static struct ConfEntry conf_general_table[] =
{ "pace_wait", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait },
{ "pace_wait_simple", CF_TIME, NULL, 0, &ConfigFileEntry.pace_wait_simple },
{ "ping_cookie", CF_YESNO, NULL, 0, &ConfigFileEntry.ping_cookie },
{ "ping_warn_time", CF_TIME, NULL, 0, &ConfigFileEntry.ping_warn_time },
{ "reject_after_count", CF_INT, NULL, 0, &ConfigFileEntry.reject_after_count },
{ "reject_ban_time", CF_TIME, NULL, 0, &ConfigFileEntry.reject_ban_time },
{ "reject_duration", CF_TIME, NULL, 0, &ConfigFileEntry.reject_duration },

View file

@ -272,6 +272,23 @@ read_packet(rb_fde_t * F, void *data)
client_p->localClient->lasttime = rb_current_time();
client_p->flags &= ~FLAGS_PINGSENT;
if (client_p->flags & FLAGS_PINGWARN)
{
/*
* if we warned about this server being unresponsive
* before, let's let everyone know there's no need
* to panic
*/
client_p->flags &= ~FLAGS_PINGWARN;
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"Received response from previously unresponsive link %s",
client_p->name);
ilog(L_SERVER,
"Received response from previously unresponsive link %s",
log_client_name(client_p, HIDE_IP));
}
/*
* Before we even think of parsing what we just read, stick
* it on the end of the receive queue and do it when its

View file

@ -421,6 +421,11 @@ static struct InfoStruct info_table[] = {
"Require ping cookies to connect",
INFO_INTBOOL(&ConfigFileEntry.ping_cookie),
},
{
"ping_warn_time",
"Amount of time between warnings about unresponsive servers",
INFO_DECIMAL(&ConfigFileEntry.ping_warn_time),
},
{
"reject_after_count",
"Client rejection threshold setting",