]> jfr.im git - solanum.git/blame - extensions/chm_insecure.c
m_shedding: user shedding module based on oftc-hybrid
[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
82436efb 17static void h_can_join(void *);
eeabf33a 18
c4e9deae 19mapi_hfn_list_av1 sslonly_hfnlist[] = {
82436efb 20 { "can_join", h_can_join },
c4e9deae
AC
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
82436efb 46h_can_join(void *data_)
c4e9deae 47{
82436efb 48 hook_data_channel *data = data_;
c4e9deae
AC
49 struct Client *source_p = data->client;
50 struct Channel *chptr = data->chptr;
51
35eccf49 52 if(!(chptr->mode.mode & mymode) && !IsSecureClient(source_p)) {
c4e9deae
AC
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