]>
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_insecure_desc[] = | |
14 | "Adds channel mode +U that allows non-SSL users to join a channel, " | |
15 | "disallowing them by default"; | |
16 | ||
17 | static void h_can_join(void *); | |
18 | ||
19 | mapi_hfn_list_av1 sslonly_hfnlist[] = { | |
20 | { "can_join", 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 | ||
43 | DECLARE_MODULE_AV2(chm_insecure, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, NULL, NULL, chm_insecure_desc); | |
44 | ||
45 | static void | |
46 | h_can_join(void *data_) | |
47 | { | |
48 | hook_data_channel *data = data_; | |
49 | struct Client *source_p = data->client; | |
50 | struct Channel *chptr = data->chptr; | |
51 | ||
52 | if(!(chptr->mode.mode & mymode) && !IsSecureClient(source_p)) { | |
53 | /* XXX This is equal to ERR_THROTTLE */ | |
54 | sendto_one_numeric(source_p, 480, "%s :Cannot join channel (-U) - SSL/TLS required", chptr->chname); | |
55 | data->approved = ERR_CUSTOM; | |
56 | } | |
57 | } | |
58 |