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