2012-01-22 10:46:08 +01:00
|
|
|
/*
|
|
|
|
* Usermode extban type: bans all users with a specific usermode
|
|
|
|
* -- nenolod
|
|
|
|
*/
|
|
|
|
|
2016-07-01 05:04:00 +02:00
|
|
|
#include <ircd/stdinc.h>
|
|
|
|
#include <ircd/modules.h>
|
|
|
|
#include <ircd/hook.h>
|
|
|
|
#include <ircd/client.h>
|
|
|
|
#include <ircd/ircd.h>
|
|
|
|
#include <ircd/send.h>
|
|
|
|
#include <ircd/hash.h>
|
|
|
|
#include <ircd/s_conf.h>
|
|
|
|
#include <ircd/s_user.h>
|
|
|
|
#include <ircd/s_serv.h>
|
|
|
|
#include <ircd/numeric.h>
|
2012-01-22 10:46:08 +01:00
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char extb_desc[] = "Usermode ($m) extban type";
|
|
|
|
|
2012-01-22 10:46:08 +01:00
|
|
|
static int _modinit(void);
|
|
|
|
static void _moddeinit(void);
|
|
|
|
static int eb_usermode(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
|
|
|
|
|
2016-03-07 07:31:41 +01:00
|
|
|
DECLARE_MODULE_AV2(extb_usermode, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
|
2012-01-22 10:46:08 +01:00
|
|
|
|
|
|
|
static int
|
|
|
|
_modinit(void)
|
|
|
|
{
|
2016-03-28 04:05:16 +02:00
|
|
|
extban_table['u'] = eb_usermode;
|
2012-01-22 10:46:08 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_moddeinit(void)
|
|
|
|
{
|
2016-03-28 04:05:16 +02:00
|
|
|
extban_table['u'] = NULL;
|
2012-01-22 10:46:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int eb_usermode(const char *data, struct Client *client_p,
|
|
|
|
struct Channel *chptr, long mode_type)
|
|
|
|
{
|
|
|
|
int dir = MODE_ADD;
|
|
|
|
unsigned int modes_ack = 0, modes_nak = 0;
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
(void)chptr;
|
|
|
|
|
|
|
|
/* $m must have a specified mode */
|
|
|
|
if (data == NULL)
|
2012-01-22 10:58:32 +01:00
|
|
|
return EXTBAN_INVALID;
|
2012-01-22 10:46:08 +01:00
|
|
|
|
|
|
|
for (p = data; *p != '\0'; p++)
|
|
|
|
{
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '+':
|
|
|
|
dir = MODE_ADD;
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
dir = MODE_DEL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
switch (dir)
|
|
|
|
{
|
|
|
|
case MODE_DEL:
|
|
|
|
modes_nak |= user_modes[(unsigned char) *p];
|
|
|
|
break;
|
|
|
|
case MODE_ADD:
|
|
|
|
default:
|
|
|
|
modes_ack |= user_modes[(unsigned char) *p];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-04 15:02:17 +01:00
|
|
|
return ((client_p->umodes & modes_ack) == modes_ack &&
|
|
|
|
!(client_p->umodes & modes_nak)) ?
|
|
|
|
EXTBAN_MATCH : EXTBAN_NOMATCH;
|
2012-01-22 10:46:08 +01:00
|
|
|
}
|