]>
Commit | Line | Data |
---|---|---|
c4e9deae AC |
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 | ||
581dad19 EM |
13 | static const char chm_insecure_desc[] = |
14 | "Adds channel mode +U that allows non-SSL users to join a channel, " | |
15 | "disallowing them by default"; | |
c4e9deae | 16 | |
eeabf33a EM |
17 | static void h_can_join(hook_data_channel *); |
18 | ||
c4e9deae AC |
19 | mapi_hfn_list_av1 sslonly_hfnlist[] = { |
20 | { "can_join", (hookfn) h_can_join }, | |
21 | { NULL, NULL } | |
22 | }; | |
23 | ||
24 | static unsigned int mymode; | |
25 | ||
26 | static int | |
27 | _modinit(void) | |
28 | { | |
29 | mymode = cflag_add('U', chm_simple); | |
30 | if (mymode == 0) | |
31 | return -1; | |
32 | ||
33 | return 0; | |
34 | } | |
35 | ||
36 | ||
37 | static void | |
38 | _moddeinit(void) | |
39 | { | |
40 | cflag_orphan('U'); | |
41 | } | |
42 | ||
581dad19 | 43 | DECLARE_MODULE_AV2(chm_insecure, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, NULL, NULL, chm_insecure_desc); |
c4e9deae AC |
44 | |
45 | static void | |
46 | h_can_join(hook_data_channel *data) | |
47 | { | |
48 | struct Client *source_p = data->client; | |
49 | struct Channel *chptr = data->chptr; | |
50 | ||
51 | if(!(chptr->mode.mode & mymode) && !IsSSLClient(source_p)) { | |
52 | /* XXX This is equal to ERR_THROTTLE */ | |
53 | sendto_one_numeric(source_p, 480, "%s :Cannot join channel (-U) - SSL/TLS required", chptr->chname); | |
54 | data->approved = ERR_CUSTOM; | |
55 | } | |
56 | } | |
57 |