PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
/*
* CIDR ban. Copyright Zach Stein
*
* 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 2
* of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* See README for instructions
*
* m_cidrban.c, ChickServ
*/
#include <string.h>
#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 STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
ModuleHeader MOD_HEADER(m_regexcept)
= {
"m_cidrban",
"v0.2",
"ExtBan ~C",
"3.2.3",
NULL
};
Extban *extbanC;
/* this one can remain the same */
char *extban_modeC_conv_param(char *para)
{
char *p =strtok(para,"~C:");
if (strstr(para,"~C:~")) {
return NULL;
}
for (; *p; p++) {
if (isalpha(*p)) {
return NULL;
}
} // prevent a segfault
static char retbuf[64];
strlcpy(retbuf, para, sizeof(retbuf));
return retbuf;
};
int extban_modeC_is_banned(aClient *sptr, aChannel *chptr, char *xban, int type)
{
struct irc_netmask tmp;
struct irc_netmask *nmask;
if (xban != NULL) {
char *tempchar = strtok(xban,"~C:");
tmp.type = parse_netmask(tempchar, &tmp);
if (tmp.type != HM_HOST)
{
nmask = MyMallocEx(sizeof(struct irc_netmask));
bcopy(&tmp, nmask, sizeof(struct irc_netmask));
if (match_ip(sptr->ip,NULL, NULL, nmask)) {
free(nmask);
return 1;
}
}
}
/* well the first thing we need is what the CIDR is */
if (&nmask != NULL)
free(nmask);
return 0;
}
DLLFUNC int MOD_INIT(m_cidrban)(ModuleInfo *modinfo)
{
ExtbanInfo req;
memset(&req, 0, sizeof(ExtbanInfo));
req.flag = 'C';
req.conv_param = extban_modeC_conv_param;
req.is_banned = extban_modeC_is_banned;
extbanC = ExtbanAdd(modinfo->handle, req);
if (!extbanC)
{
config_error("m_regexcept module: adding extban ~C failed! module NOT loaded");
return MOD_FAILED;
}
return MOD_SUCCESS;
}
DLLFUNC int MOD_LOAD(m_regexcept)(int module_load)
{
return MOD_SUCCESS;
}
DLLFUNC int MOD_UNLOAD(m_regexcept)(int module_unload)
{
/* This is unexpected as of RC2, but might work in the future... */
ExtbanDel(extbanC);
return MOD_SUCCESS;
}