]> jfr.im git - solanum.git/blame - extensions/chm_sslonly.c
explicitly show IP in SNO_BANNED snotes
[solanum.git] / extensions / chm_sslonly.c
CommitLineData
80ce25be
VY
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
eeabf33a
EM
13static const char chm_sslonly_desc[] =
14 "Adds channel mode +S that bans non-SSL users from joing a channel";
15
82436efb 16static void h_can_join(void *);
80ce25be
VY
17
18mapi_hfn_list_av1 sslonly_hfnlist[] = {
82436efb 19 { "can_join", h_can_join },
80ce25be
VY
20 { NULL, NULL }
21};
22
19716b9f
JT
23static unsigned int mymode;
24
80ce25be
VY
25static int
26_modinit(void)
27{
19716b9f
JT
28 mymode = cflag_add('S', chm_simple);
29 if (mymode == 0)
30 return -1;
80ce25be
VY
31
32 return 0;
33}
34
80ce25be
VY
35static void
36_moddeinit(void)
37{
19716b9f 38 cflag_orphan('S');
80ce25be
VY
39}
40
581dad19 41DECLARE_MODULE_AV2(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, NULL, NULL, chm_sslonly_desc);
80ce25be
VY
42
43static void
82436efb 44h_can_join(void *data_)
80ce25be 45{
82436efb 46 hook_data_channel *data = data_;
80ce25be
VY
47 struct Client *source_p = data->client;
48 struct Channel *chptr = data->chptr;
49
35eccf49 50 if((chptr->mode.mode & mymode) && !IsSecureClient(source_p)) {
83aa910f
JT
51 /* XXX This is equal to ERR_THROTTLE */
52 sendto_one_numeric(source_p, 480, "%s :Cannot join channel (+S) - SSL/TLS required", chptr->chname);
80ce25be
VY
53 data->approved = ERR_CUSTOM;
54 }
55}
56