From b674a619eb15107a0d95d940665d6a50d5e3da62 Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Wed, 29 Nov 2017 02:56:30 +0000 Subject: [PATCH 1/2] Add extensions/drain This takes the simplest possible approach: load the module and you're in drain mode. --- extensions/Makefile.am | 1 + extensions/drain.c | 38 ++++++++++++++++++++++++++++++++++++++ include/s_conf.h | 2 ++ ircd/newconf.c | 1 + 4 files changed, 42 insertions(+) create mode 100644 extensions/drain.c diff --git a/extensions/Makefile.am b/extensions/Makefile.am index 64cd6e7c..702ecb0e 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -75,4 +75,5 @@ extension_LTLIBRARIES = \ spy_stats_notice.la \ spy_stats_p_notice.la \ spy_trace_notice.la \ + drain.la \ example_module.la diff --git a/extensions/drain.c b/extensions/drain.c new file mode 100644 index 00000000..225a9d73 --- /dev/null +++ b/extensions/drain.c @@ -0,0 +1,38 @@ +#include "stdinc.h" +#include "modules.h" +#include "hook.h" +#include "client.h" +#include "ircd.h" +#include "send.h" +#include "hash.h" +#include "s_conf.h" +#include "s_user.h" +#include "s_serv.h" +#include "numeric.h" + +static void check_new_user(void *data); +mapi_hfn_list_av1 drain_hfnlist[] = { + { "new_local_user", (hookfn) check_new_user }, + { NULL, NULL } +}; + +static const char drain_desc[] = "Prevents new, non-exempt users from connecting to this server."; + +DECLARE_MODULE_AV2(drain, NULL, NULL, NULL, NULL, + drain_hfnlist, NULL, NULL, drain_desc); + + +static void +check_new_user(void *vdata) +{ + struct Client *source_p = vdata; + const char *drain_reason = ConfigFileEntry.drain_reason; + + if (drain_reason == NULL) + drain_reason = "This server is not accepting connections."; + + if(IsExemptKline(source_p)) + return; + + exit_client(source_p, source_p, &me, drain_reason); +} diff --git a/include/s_conf.h b/include/s_conf.h index f158b61e..88a41c3e 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -240,6 +240,8 @@ struct config_file_entry int hide_opers_in_whois; int hide_opers; + + char *drain_reason; }; struct config_channel_entry diff --git a/ircd/newconf.c b/ircd/newconf.c index f63669ec..e3769e7f 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -2799,6 +2799,7 @@ static struct ConfEntry conf_general_table[] = { "hide_opers_in_whois", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_opers_in_whois }, { "hide_opers", CF_YESNO, NULL, 0, &ConfigFileEntry.hide_opers }, { "certfp_method", CF_STRING, conf_set_general_certfp_method, 0, NULL }, + { "drain_reason", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.drain_reason }, { "\0", 0, NULL, 0, NULL } }; From a0d1df9f38a6ce382816ec4b02ea681b573d0719 Mon Sep 17 00:00:00 2001 From: Janik Kleinhoff Date: Tue, 7 Aug 2018 20:39:05 +0000 Subject: [PATCH 2/2] extensions/drain: remove superfluous includes --- extensions/drain.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/extensions/drain.c b/extensions/drain.c index 225a9d73..01d19cdf 100644 --- a/extensions/drain.c +++ b/extensions/drain.c @@ -2,13 +2,7 @@ #include "modules.h" #include "hook.h" #include "client.h" -#include "ircd.h" -#include "send.h" -#include "hash.h" #include "s_conf.h" -#include "s_user.h" -#include "s_serv.h" -#include "numeric.h" static void check_new_user(void *data); mapi_hfn_list_av1 drain_hfnlist[] = {