Modularize nokicks (+Q)

This commit is contained in:
Travis McArthur 2014-06-29 00:52:40 -07:00
parent 866c835a6f
commit fdeb6f06bf
7 changed files with 112 additions and 25 deletions

View file

@ -1628,7 +1628,6 @@ struct liststruct {
#define MODE_LIMIT 0x4000
#define MODE_RGSTR 0x8000
#define MODE_NOCOLOR 0x40000
#define MODE_NOKICKS 0x200000
#define MODE_STRIP 0x400000
#define MODE_MODREG 0x4000000
#define MODE_INVEX 0x8000000

View file

@ -127,6 +127,7 @@ loadmodule "modules/chanmodes/adminonly"; /* +A */
loadmodule "modules/chanmodes/nonotice"; /* +T */
loadmodule "modules/chanmodes/regonly"; /* +R */
loadmodule "modules/chanmodes/nonickchange"; /* +N */
loadmodule "modules/chanmodes/nokick"; /* +Q */
/*** User modes ***/

View file

@ -87,7 +87,6 @@ aCtab cFlagTab[] = {
{MODE_RGSTR, 'r', 0, 0},
{MODE_CHANPROT, 'a', 0, 1},
{MODE_CHANOWNER, 'q', 0, 1},
{MODE_NOKICKS, 'Q', 0, 0},
{MODE_BAN, 'b', 1, 1},
{MODE_EXCEPT, 'e', 1, 0}, /* exception ban */
{MODE_INVEX, 'I', 1, 0}, /* exception ban */

View file

@ -32,7 +32,7 @@ INCLUDES = ../../include/auth.h ../../include/channel.h \
R_MODULES= \
nocolor.so stripcolor.so issecure.so permanent.so jointhrottle.so floodprot.so \
noctcp.so link.so censor.so delayjoin.so noknock.so noinvite.so operonly.so \
adminonly.so nonotice.so regonly.so nonickchange.so
adminonly.so nonotice.so regonly.so nonickchange.so nokick.so
MODULES=$(R_MODULES)
MODULEFLAGS=@MODULEFLAGS@
@ -120,4 +120,8 @@ regonly.so: regonly.c $(INCLUDES)
nonickchange.so: nonickchange.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o nonickchange.so nonickchange.c
-o nonickchange.so nonickchange.c
nokick.so: nokick.c $(INCLUDES)
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \
-o nokick.so nokick.c

View file

@ -0,0 +1,105 @@
/*
* No kicks in channel UnrealIRCd Module (Channel Mode +Q)
* (C) Copyright 2014 Travis McArthur (Heero) and the UnrealIRCd team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "proto.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef _WIN32
#include "version.h"
#endif
ModuleHeader MOD_HEADER(nokick)
= {
"chanmodes/nokick",
"$Id$",
"Channel Mode +Q",
"3.2-b8-1",
NULL
};
Cmode_t EXTCMODE_NOKICK;
static char errMsg[2048];
#define IsNoKick(chptr) (chptr->mode.extmode & EXTCMODE_NOKICK)
DLLFUNC char * nokick_check (aClient* sptr, aClient* who, aChannel *chptr, char* comment, long sptr_flags, long who_flags);
DLLFUNC int MOD_TEST(nokick)(ModuleInfo *modinfo)
{
return MOD_SUCCESS;
}
DLLFUNC int MOD_INIT(nokick)(ModuleInfo *modinfo)
{
CmodeInfo req;
memset(&req, 0, sizeof(req));
req.paracount = 0;
req.flag = 'Q';
req.is_ok = extcmode_default_requirechop;
CmodeAdd(modinfo->handle, req, &EXTCMODE_NOKICK);
HookAddPCharEx(modinfo->handle, HOOKTYPE_CAN_KICK, nokick_check);
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
DLLFUNC int MOD_LOAD(nokick)(int module_load)
{
return MOD_SUCCESS;
}
DLLFUNC int MOD_UNLOAD(nokick)(int module_unload)
{
return MOD_SUCCESS;
}
DLLFUNC char * nokick_check (aClient* sptr, aClient* who, aChannel *chptr, char* comment, long sptr_flags, long who_flags)
{
if (MyClient(sptr) && IsNoKick(chptr))
{
/* As a warning, this is not thread safe... */
ircsnprintf(errMsg,sizeof(errMsg),err_str(ERR_CANNOTDOCOMMAND),
me.name, sptr->name, "KICK",
"channel is +Q");
return errMsg;
}
return 0;
}

View file

@ -165,26 +165,6 @@ CMD_FUNC(m_kick)
}
}
if (chptr->mode.mode & MODE_NOKICKS)
{
if (!op_can_override(sptr))
{
if (!MyClient(sptr))
goto attack; /* lag? yes.. kick crossing +Q... allow */
sendto_one(sptr, err_str(ERR_CANNOTDOCOMMAND),
me.name, sptr->name, "KICK",
"channel is +Q");
goto deny;
}
sendto_snomask(SNO_EYES,
"*** OperOverride -- %s (%s@%s) KICK %s %s (%s)",
sptr->name, sptr->user->username, sptr->user->realhost,
chptr->chname, who->name, comment);
ircd_log(LOG_OVERRIDE,"OVERRIDE: %s (%s@%s) KICK %s %s (%s)",
sptr->name, sptr->user->username, sptr->user->realhost,
chptr->chname, who->name, comment);
goto attack; /* No reason to continue.. */
}
/* Store "who" access flags */
who_flags = get_access(who, chptr);

View file

@ -831,7 +831,6 @@ int do_mode_char(aChannel *chptr, long modetype, char modechar, char *param,
case MODE_TOPICLIMIT:
case MODE_NOPRIVMSGS:
case MODE_MODREG:
case MODE_NOKICKS:
case MODE_INVITEONLY:
goto setthephuckingmode;