]> jfr.im git - solanum.git/blame - extensions/drain.c
Note that messages caught in +g/+G are discarded
[solanum.git] / extensions / drain.c
CommitLineData
b674a619
EK
1#include "stdinc.h"
2#include "modules.h"
3#include "hook.h"
4#include "client.h"
b674a619 5#include "s_conf.h"
b674a619
EK
6
7static void check_new_user(void *data);
8mapi_hfn_list_av1 drain_hfnlist[] = {
82436efb 9 { "new_local_user", check_new_user },
b674a619
EK
10 { NULL, NULL }
11};
12
13static const char drain_desc[] = "Prevents new, non-exempt users from connecting to this server.";
14
15DECLARE_MODULE_AV2(drain, NULL, NULL, NULL, NULL,
16 drain_hfnlist, NULL, NULL, drain_desc);
17
18
19static void
20check_new_user(void *vdata)
21{
22 struct Client *source_p = vdata;
23 const char *drain_reason = ConfigFileEntry.drain_reason;
24
b6b40dda
EK
25 if (IsAnyDead(source_p))
26 return;
27
b674a619
EK
28 if (drain_reason == NULL)
29 drain_reason = "This server is not accepting connections.";
30
b6b40dda 31 if (IsExemptKline(source_p))
b674a619
EK
32 return;
33
34 exit_client(source_p, source_p, &me, drain_reason);
35}