]> jfr.im git - solanum.git/blame - extensions/chm_insecure.c
extensions/extb_ssl.c: make certfp parameter case-insensitive
[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
581dad19
EM
13static 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
17static void h_can_join(hook_data_channel *);
18
c4e9deae
AC
19mapi_hfn_list_av1 sslonly_hfnlist[] = {
20 { "can_join", (hookfn) h_can_join },
21 { NULL, NULL }
22};
23
24static unsigned int mymode;
25
26static 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
37static void
38_moddeinit(void)
39{
40 cflag_orphan('U');
41}
42
581dad19 43DECLARE_MODULE_AV2(chm_insecure, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, NULL, NULL, chm_insecure_desc);
c4e9deae
AC
44
45static void
46h_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