2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_dline.c: Bans/unbans a user.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2005 ircd-ratbox development 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 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
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char dline_desc[] = "Provides the DLINE facility to ban users via IP address";
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void mo_dline(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void me_dline(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void mo_undline(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void me_undline(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
struct Message dline_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"DLINE", 0, 0, 0, 0,
|
2013-09-23 11:34:30 +02:00
|
|
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_dline, 4}, {mo_dline, 2}}
|
2007-01-25 07:40:21 +01:00
|
|
|
};
|
2010-01-08 00:19:03 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
struct Message undline_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"UNDLINE", 0, 0, 0, 0,
|
2013-09-23 11:34:30 +02:00
|
|
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_undline, 2}, {mo_undline, 2}}
|
2007-01-25 07:40:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
mapi_clist_av1 dline_clist[] = { &dline_msgtab, &undline_msgtab, NULL };
|
2010-01-08 00:19:03 +01:00
|
|
|
|
2016-03-07 08:59:08 +01:00
|
|
|
DECLARE_MODULE_AV2(dline, NULL, NULL, dline_clist, NULL, NULL, NULL, NULL, dline_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static bool remove_temp_dline(struct ConfItem *);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void apply_dline(client::client &, const char *, int, char *);
|
|
|
|
static void apply_undline(client::client &, const char *);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* mo_dline()
|
2014-03-03 05:25:47 +01:00
|
|
|
*
|
2007-01-25 07:40:21 +01:00
|
|
|
* parv[1] - dline to add
|
|
|
|
* parv[2] - reason
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_dline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
char def[] = "No Reason";
|
|
|
|
const char *dlhost;
|
|
|
|
char *reason = def;
|
|
|
|
char cidr_form_host[HOSTLEN + 1];
|
|
|
|
int tdline_time = 0;
|
2008-04-20 09:26:37 +02:00
|
|
|
const char *target_server = NULL;
|
2007-01-25 07:40:21 +01:00
|
|
|
int loc = 1;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperK(&source))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOPRIVS), me.name, source.name, "kline");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if((tdline_time = valid_temp_time(parv[loc])) >= 0)
|
|
|
|
loc++;
|
|
|
|
|
|
|
|
dlhost = parv[loc];
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(cidr_form_host, dlhost, sizeof(cidr_form_host));
|
2008-04-20 09:26:37 +02:00
|
|
|
loc++;
|
|
|
|
|
2011-06-25 11:34:34 +02:00
|
|
|
/* would break the protocol */
|
|
|
|
if (*dlhost == ':')
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Invalid D-Line");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2011-06-25 11:34:34 +02:00
|
|
|
}
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
if(parc >= loc + 2 && !irccmp(parv[loc], "ON"))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperRemoteBan(&source))
|
2008-04-23 18:32:46 +02:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOPRIVS),
|
|
|
|
me.name, source.name, "remoteban");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-23 18:32:46 +02:00
|
|
|
}
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
target_server = parv[loc + 1];
|
2008-04-20 09:26:37 +02:00
|
|
|
loc += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parc >= loc + 1 && !EmptyString(parv[loc]))
|
|
|
|
reason = LOCAL_COPY(parv[loc]);
|
|
|
|
|
|
|
|
if(target_server != NULL)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target_server,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_ENCAP, NOCAPS,
|
|
|
|
"ENCAP %s DLINE %d %s :%s",
|
|
|
|
target_server, tdline_time, dlhost, reason);
|
2008-04-20 09:26:37 +02:00
|
|
|
|
|
|
|
if(!match(target_server, me.name))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_dline(source, dlhost, tdline_time, reason);
|
2008-04-20 09:26:37 +02:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
client::check_dlines();
|
2008-04-20 09:26:37 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2008-04-20 09:26:37 +02:00
|
|
|
/* mo_undline()
|
|
|
|
*
|
|
|
|
* parv[1] = dline to remove
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_undline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2008-04-20 09:26:37 +02:00
|
|
|
{
|
|
|
|
const char *cidr;
|
|
|
|
const char *target_server = NULL;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperK(&source))
|
2008-04-20 09:26:37 +02:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOPRIVS), me.name, source.name, "unkline");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2010-01-08 00:19:03 +01:00
|
|
|
}
|
|
|
|
|
2008-04-20 09:26:37 +02:00
|
|
|
cidr = parv[1];
|
|
|
|
|
|
|
|
if(parc >= 4 && !irccmp(parv[2], "ON"))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperRemoteBan(&source))
|
2008-04-23 18:32:46 +02:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOPRIVS),
|
|
|
|
me.name, source.name, "remoteban");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-23 18:32:46 +02:00
|
|
|
}
|
|
|
|
|
2008-04-20 09:26:37 +02:00
|
|
|
target_server = parv[3];
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target_server,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_ENCAP, NOCAPS, "ENCAP %s UNDLINE %s", target_server, cidr);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2008-04-20 09:26:37 +02:00
|
|
|
if(!match(target_server, me.name))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_undline(source, cidr);
|
2008-04-20 09:26:37 +02:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
me_dline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char **parv)
|
2008-04-20 15:47:53 +02:00
|
|
|
{
|
|
|
|
int tdline_time = atoi(parv[1]);
|
|
|
|
/* Since this is coming over a server link, assume that the originating
|
|
|
|
* server did the relevant permission/sanity checks...
|
|
|
|
*/
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-20 15:47:53 +02:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!find_shared_conf(source.username, source.host,
|
|
|
|
source.servptr->name,
|
2010-01-08 00:19:03 +01:00
|
|
|
tdline_time > 0 ? SHARED_TDLINE : SHARED_PDLINE))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-20 15:47:53 +02:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_dline(source, parv[2], tdline_time, LOCAL_COPY(parv[3]));
|
2008-04-20 15:47:53 +02:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
client::check_dlines();
|
2008-04-20 15:47:53 +02:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
me_undline(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char **parv)
|
2008-04-20 15:47:53 +02:00
|
|
|
{
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-20 15:47:53 +02:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!find_shared_conf(source.username, source.host,
|
|
|
|
source.servptr->name, SHARED_UNDLINE))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-20 15:47:53 +02:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_undline(source, parv[1]);
|
2008-04-20 09:26:37 +02:00
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_dline(client::client &source, const char *dlhost, int tdline_time, char *reason)
|
2008-04-20 09:26:37 +02:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
char *oper_reason;
|
|
|
|
struct rb_sockaddr_storage daddr;
|
|
|
|
int t = AF_INET, ty, b;
|
|
|
|
const char *creason;
|
|
|
|
|
2015-04-20 07:55:20 +02:00
|
|
|
ty = parse_netmask(dlhost, &daddr, &b);
|
2008-04-20 09:26:37 +02:00
|
|
|
if(ty == HM_HOST)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, ":%s NOTICE %s :Invalid D-Line", me.name, source.name);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-20 09:26:37 +02:00
|
|
|
}
|
|
|
|
#ifdef RB_IPV6
|
|
|
|
if(ty == HM_IPV6)
|
|
|
|
t = AF_INET6;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
t = AF_INET;
|
|
|
|
|
|
|
|
/* This means dlines wider than /16 cannot be set remotely */
|
2016-08-23 02:37:07 +02:00
|
|
|
if(IsOperAdmin(&source))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-20 09:26:37 +02:00
|
|
|
if(b < 8)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source,
|
2010-01-08 00:19:03 +01:00
|
|
|
":For safety, bitmasks less than 8 require conf access.");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-20 09:26:37 +02:00
|
|
|
if(b < 16)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source,
|
2010-01-08 00:19:03 +01:00
|
|
|
":Dline bitmasks less than 16 are for admins only.");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-02 17:37:50 +02:00
|
|
|
if(ConfigFileEntry.non_redundant_klines)
|
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
if((aconf = find_dline((struct sockaddr *) &daddr, t)) != NULL)
|
2008-04-02 17:37:50 +02:00
|
|
|
{
|
|
|
|
int bx;
|
|
|
|
parse_netmask(aconf->host, NULL, &bx);
|
|
|
|
if(b >= bx)
|
|
|
|
{
|
|
|
|
creason = aconf->passwd ? aconf->passwd : "<No Reason>";
|
|
|
|
if(IsConfExemptKline(aconf))
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source,
|
2008-04-02 17:37:50 +02:00
|
|
|
":%s NOTICE %s :[%s] is (E)d-lined by [%s] - %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
me.name, source.name, dlhost, aconf->host,
|
2010-01-08 00:19:03 +01:00
|
|
|
creason);
|
2008-04-02 17:37:50 +02:00
|
|
|
else
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source,
|
2008-04-02 17:37:50 +02:00
|
|
|
":%s NOTICE %s :[%s] already D-lined by [%s] - %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
me.name, source.name, dlhost, aconf->host,
|
2010-01-08 00:19:03 +01:00
|
|
|
creason);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2008-04-02 17:37:50 +02:00
|
|
|
}
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2008-04-04 01:18:47 +02:00
|
|
|
rb_set_time();
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
aconf = make_conf();
|
|
|
|
aconf->status = CONF_DLINE;
|
2010-02-28 00:46:56 +01:00
|
|
|
aconf->created = rb_current_time();
|
2008-04-02 01:26:34 +02:00
|
|
|
aconf->host = rb_strdup(dlhost);
|
2010-02-28 16:27:06 +01:00
|
|
|
aconf->passwd = rb_strdup(reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
aconf->info.oper = operhash_add(get_oper_name(&source));
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2011-12-30 18:29:58 +01:00
|
|
|
if(strlen(reason) > BANREASONLEN)
|
|
|
|
reason[BANREASONLEN] = '\0';
|
|
|
|
|
2008-07-27 12:43:49 +02:00
|
|
|
/* Look for an oper reason */
|
|
|
|
if((oper_reason = strchr(reason, '|')) != NULL)
|
|
|
|
{
|
|
|
|
*oper_reason = '\0';
|
|
|
|
oper_reason++;
|
|
|
|
|
|
|
|
if(!EmptyString(oper_reason))
|
|
|
|
aconf->spasswd = rb_strdup(oper_reason);
|
|
|
|
}
|
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
if(tdline_time > 0)
|
|
|
|
{
|
2008-04-02 01:53:20 +02:00
|
|
|
aconf->hold = rb_current_time() + tdline_time;
|
2007-01-25 07:40:21 +01:00
|
|
|
add_temp_dline(aconf);
|
|
|
|
|
|
|
|
if(EmptyString(oper_reason))
|
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:19:03 +01:00
|
|
|
"%s added temporary %d min. D-Line for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), tdline_time / 60,
|
2010-01-08 00:19:03 +01:00
|
|
|
aconf->host, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
ilog(L_KLINE, "D %s %d %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), tdline_time / 60, aconf->host, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:19:03 +01:00
|
|
|
"%s added temporary %d min. D-Line for [%s] [%s|%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), tdline_time / 60,
|
2010-01-08 00:19:03 +01:00
|
|
|
aconf->host, reason, oper_reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
ilog(L_KLINE, "D %s %d %s %s|%s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), tdline_time / 60,
|
2010-01-08 00:19:03 +01:00
|
|
|
aconf->host, reason, oper_reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, ":%s NOTICE %s :Added temporary %d min. D-Line for [%s]",
|
|
|
|
me.name, source.name, tdline_time / 60, aconf->host);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-26 08:18:58 +02:00
|
|
|
add_conf_by_address(aconf->host, CONF_DLINE, NULL, NULL, aconf);
|
2010-01-08 00:19:03 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
bandb_add(BANDB_DLINE, &source, aconf->host, NULL,
|
2010-01-08 00:19:03 +01:00
|
|
|
reason, EmptyString(aconf->spasswd) ? NULL : aconf->spasswd, 0);
|
2010-01-08 00:37:52 +01:00
|
|
|
|
|
|
|
if(EmptyString(oper_reason))
|
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:37:52 +01:00
|
|
|
"%s added D-Line for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), aconf->host, reason);
|
2010-01-08 00:37:52 +01:00
|
|
|
ilog(L_KLINE, "D %s 0 %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), aconf->host, reason);
|
2010-01-08 00:37:52 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:37:52 +01:00
|
|
|
"%s added D-Line for [%s] [%s|%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), aconf->host, reason, oper_reason);
|
2010-01-08 00:37:52 +01:00
|
|
|
ilog(L_KLINE, "D %s 0 %s %s|%s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source),
|
2010-01-08 00:37:52 +01:00
|
|
|
aconf->host, reason, oper_reason);
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
apply_undline(client::client &source, const char *cidr)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
char buf[BUFSIZE];
|
2008-04-20 09:26:37 +02:00
|
|
|
struct ConfItem *aconf;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(parse_netmask(cidr, NULL, NULL) == HM_HOST)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Invalid D-Line");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2007-11-30 01:14:12 +01:00
|
|
|
aconf = find_exact_conf_by_address(cidr, CONF_DLINE, NULL);
|
|
|
|
if(aconf == NULL)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":No D-Line for %s", cidr);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-11-30 01:14:12 +01:00
|
|
|
}
|
|
|
|
|
2008-04-20 06:40:40 +02:00
|
|
|
rb_strlcpy(buf, aconf->host, sizeof buf);
|
2007-11-30 01:14:12 +01:00
|
|
|
if(remove_temp_dline(aconf))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source,
|
2007-01-25 07:40:21 +01:00
|
|
|
":%s NOTICE %s :Un-dlined [%s] from temporary D-lines",
|
2016-08-23 02:37:07 +02:00
|
|
|
me.name, source.name, buf);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 00:19:03 +01:00
|
|
|
"%s has removed the temporary D-Line for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), buf);
|
|
|
|
ilog(L_KLINE, "UD %s %s", get_oper_name(&source), buf);
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
bandb_del(BANDB_DLINE, aconf->host, NULL);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, ":%s NOTICE %s :D-Line for [%s] is removed", me.name, source.name,
|
2010-01-08 00:19:03 +01:00
|
|
|
aconf->host);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL, "%s has removed the D-Line for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), aconf->host);
|
|
|
|
ilog(L_KLINE, "UD %s %s", get_oper_name(&source), aconf->host);
|
2008-04-20 16:05:17 +02:00
|
|
|
delete_one_address_conf(aconf->host, aconf);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* remove_temp_dline()
|
|
|
|
*
|
2007-11-30 01:14:12 +01:00
|
|
|
* inputs - confitem to undline
|
2016-03-09 08:37:03 +01:00
|
|
|
* outputs - true if removed, false otherwise.
|
2007-01-25 07:40:21 +01:00
|
|
|
* side effects - tries to undline anything that matches
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static bool
|
2007-11-30 01:14:12 +01:00
|
|
|
remove_temp_dline(struct ConfItem *aconf)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-01 22:18:48 +02:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
int i;
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
for(i = 0; i < LAST_TEMP_TYPE; i++)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, temp_dlines[i].head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
if(aconf == ptr->data)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-01 22:54:08 +02:00
|
|
|
rb_dlinkDestroy(ptr, &temp_dlines[i]);
|
2007-01-25 07:40:21 +01:00
|
|
|
delete_one_address_conf(aconf->host, aconf);
|
2016-03-09 08:37:03 +01:00
|
|
|
return true;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-09 08:37:03 +01:00
|
|
|
return false;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|