]> jfr.im git - solanum.git/blob - extensions/drain.c
225a9d73ad2a9872385d3f1dfad94d1bbb3e285f
[solanum.git] / extensions / drain.c
1 #include "stdinc.h"
2 #include "modules.h"
3 #include "hook.h"
4 #include "client.h"
5 #include "ircd.h"
6 #include "send.h"
7 #include "hash.h"
8 #include "s_conf.h"
9 #include "s_user.h"
10 #include "s_serv.h"
11 #include "numeric.h"
12
13 static void check_new_user(void *data);
14 mapi_hfn_list_av1 drain_hfnlist[] = {
15 { "new_local_user", (hookfn) check_new_user },
16 { NULL, NULL }
17 };
18
19 static const char drain_desc[] = "Prevents new, non-exempt users from connecting to this server.";
20
21 DECLARE_MODULE_AV2(drain, NULL, NULL, NULL, NULL,
22 drain_hfnlist, NULL, NULL, drain_desc);
23
24
25 static void
26 check_new_user(void *vdata)
27 {
28 struct Client *source_p = vdata;
29 const char *drain_reason = ConfigFileEntry.drain_reason;
30
31 if (drain_reason == NULL)
32 drain_reason = "This server is not accepting connections.";
33
34 if(IsExemptKline(source_p))
35 return;
36
37 exit_client(source_p, source_p, &me, drain_reason);
38 }