]>
Commit | Line | Data |
---|---|---|
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 "s_conf.h" | |
8 | #include "s_user.h" | |
9 | #include "s_serv.h" | |
10 | #include "numeric.h" | |
11 | #include "chmode.h" | |
12 | ||
13 | static const char chm_sslonly_desc[] = | |
14 | "Adds channel mode +S that bans non-SSL users from joing a channel"; | |
15 | ||
16 | static void h_can_join(hook_data_channel *); | |
17 | ||
18 | mapi_hfn_list_av1 sslonly_hfnlist[] = { | |
19 | { "can_join", (hookfn) h_can_join }, | |
20 | { NULL, NULL } | |
21 | }; | |
22 | ||
23 | static unsigned int mymode; | |
24 | ||
25 | static int | |
26 | _modinit(void) | |
27 | { | |
28 | mymode = cflag_add('S', chm_simple); | |
29 | if (mymode == 0) | |
30 | return -1; | |
31 | ||
32 | return 0; | |
33 | } | |
34 | ||
35 | static void | |
36 | _moddeinit(void) | |
37 | { | |
38 | cflag_orphan('S'); | |
39 | } | |
40 | ||
41 | DECLARE_MODULE_AV2(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, NULL, NULL, chm_sslonly_desc); | |
42 | ||
43 | static void | |
44 | h_can_join(hook_data_channel *data) | |
45 | { | |
46 | struct Client *source_p = data->client; | |
47 | struct Channel *chptr = data->chptr; | |
48 | ||
49 | if((chptr->mode.mode & mymode) && !IsSSLClient(source_p)) { | |
50 | /* XXX This is equal to ERR_THROTTLE */ | |
51 | sendto_one_numeric(source_p, 480, "%s :Cannot join channel (+S) - SSL/TLS required", chptr->chname); | |
52 | data->approved = ERR_CUSTOM; | |
53 | } | |
54 | } | |
55 |