Merge pull request #284 from edk0/drain

Add extensions/drain (port from ircd-seven)
This commit is contained in:
Aaron Jones 2019-09-14 21:21:38 +00:00 committed by GitHub
commit 8b7503c89a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 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

32
extensions/drain.c Normal file
View file

@ -0,0 +1,32 @@
#include "stdinc.h"
#include "modules.h"
#include "hook.h"
#include "client.h"
#include "s_conf.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 }
};