From 6b2cf989b6f77ca06d6d46efa3b26c0ea22d76e4 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Thu, 5 Feb 2009 23:43:07 +0100 Subject: [PATCH] Disable autoconnect for a server with excessive TS delta. Note that in some cases (different TS delta settings, heavy lag) it is possible only one of the servers detects the problem and autoconnect may be left enabled. The mechanism used for disabling is the same as /quote set autoconn 0; the A flag in /stats c disappears and a rehash or /quote set autoconn can put it back. --- include/s_newconf.h | 1 + modules/m_svinfo.c | 2 ++ src/s_newconf.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/include/s_newconf.h b/include/s_newconf.h index 916cf77..c0cc561 100644 --- a/include/s_newconf.h +++ b/include/s_newconf.h @@ -223,6 +223,7 @@ extern void attach_server_conf(struct Client *, struct server_conf *); extern void detach_server_conf(struct Client *); extern void set_server_conf_autoconn(struct Client *source_p, const char *name, int newval); +extern void disable_server_conf_autoconn(const char *name); extern struct ConfItem *find_xline(const char *, int); diff --git a/modules/m_svinfo.c b/modules/m_svinfo.c index 3ffb8f4..1adc81d 100644 --- a/modules/m_svinfo.c +++ b/modules/m_svinfo.c @@ -31,6 +31,7 @@ #include "numeric.h" #include "send.h" #include "s_conf.h" +#include "s_newconf.h" #include "logger.h" #include "msg.h" #include "parse.h" @@ -96,6 +97,7 @@ ms_svinfo(struct Client *client_p, struct Client *source_p, int parc, const char log_client_name(source_p, SHOW_IP), (long) rb_current_time(), (long) theirtime, deltat); rb_snprintf(squitreason, sizeof squitreason, "Excessive TS delta (my TS=%ld, their TS=%ld, delta=%d)", (long) rb_current_time(), (long) theirtime, deltat); + disable_server_conf_autoconn(source_p->name); exit_client(source_p, source_p, source_p, squitreason); return 0; } diff --git a/src/s_newconf.c b/src/s_newconf.c index 93f5896..b26be9d 100644 --- a/src/s_newconf.c +++ b/src/s_newconf.c @@ -458,6 +458,24 @@ set_server_conf_autoconn(struct Client *source_p, const char *name, int newval) sendto_one_notice(source_p, ":Can't find %s", name); } +void +disable_server_conf_autoconn(const char *name) +{ + struct server_conf *server_p; + + server_p = find_server_conf(name); + if(server_p != NULL && server_p->flags & SERVER_AUTOCONN) + { + server_p->flags &= ~SERVER_AUTOCONN; + + sendto_realops_snomask(SNO_GENERAL, L_ALL, + "Disabling AUTOCONN for %s because of error", + name); + ilog(L_SERVER, "Disabling AUTOCONN for %s because of error", + name); + } +} + struct ConfItem * find_xline(const char *gecos, int counter) {