Merge pull request #284 from edk0/drain
Add extensions/drain (port from ircd-seven)
This commit is contained in:
commit
8b7503c89a
4 changed files with 36 additions and 0 deletions
|
@ -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
32
extensions/drain.c
Normal 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);
|
||||
}
|
|
@ -240,6 +240,8 @@ struct config_file_entry
|
|||
|
||||
int hide_opers_in_whois;
|
||||
int hide_opers;
|
||||
|
||||
char *drain_reason;
|
||||
};
|
||||
|
||||
struct config_channel_entry
|
||||
|
|
|
@ -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 }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue