diff --git a/doc/reference.conf b/doc/reference.conf index e4a16dbc..58b5fed1 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -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 */ diff --git a/include/client.h b/include/client.h index 7dfc8f14..2d61d5f9 100644 --- a/include/client.h +++ b/include/client.h @@ -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 */ diff --git a/include/s_conf.h b/include/s_conf.h index acc4f1b8..53233ee1 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -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; diff --git a/ircd/client.c b/ircd/client.c index 24738ae0..a06fda58 100644 --- a/ircd/client.c +++ b/ircd/client.c @@ -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: */ diff --git a/ircd/newconf.c b/ircd/newconf.c index d5c07258..33bfd4d1 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -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 }, diff --git a/ircd/packet.c b/ircd/packet.c index ee842955..f0350d5e 100644 --- a/ircd/packet.c +++ b/ircd/packet.c @@ -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 diff --git a/modules/m_info.c b/modules/m_info.c index f6d03659..6742bafb 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -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",