Add extensions/drain

This takes the simplest possible approach: load the module and you're in
drain mode.
This commit is contained in:
Ed Kellett 2017-11-29 02:56:30 +00:00
parent b9da417b4e
commit b674a619eb
No known key found for this signature in database
GPG key ID: CB9986DEF342FABC
4 changed files with 42 additions and 0 deletions

View file

@ -75,4 +75,5 @@ extension_LTLIBRARIES = \
spy_stats_notice.la \
spy_stats_p_notice.la \
spy_trace_notice.la \
drain.la \
example_module.la

38
extensions/drain.c Normal file
View file

@ -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);
}

View file

@ -240,6 +240,8 @@ struct config_file_entry
int hide_opers_in_whois;
int hide_opers;
char *drain_reason;
};
struct config_channel_entry

View file

@ -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 }
};