2007-01-25 06:40:21 +00:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* m_resv.c: Reserves(jupes) a nickname or channel.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001-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
|
|
|
|
*
|
2010-01-07 23:19:03 +00:00
|
|
|
* $Id$
|
2007-01-25 06:40:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdinc.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "channel.h"
|
|
|
|
#include "ircd.h"
|
|
|
|
#include "numeric.h"
|
|
|
|
#include "s_serv.h"
|
|
|
|
#include "send.h"
|
|
|
|
#include "msg.h"
|
|
|
|
#include "parse.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "s_conf.h"
|
|
|
|
#include "s_newconf.h"
|
|
|
|
#include "hash.h"
|
2008-04-03 02:52:01 +00:00
|
|
|
#include "logger.h"
|
2010-01-07 23:19:03 +00:00
|
|
|
#include "bandbi.h"
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
static int mo_resv(struct Client *, struct Client *, int, const char **);
|
|
|
|
static int ms_resv(struct Client *, struct Client *, int, const char **);
|
|
|
|
static int me_resv(struct Client *, struct Client *, int, const char **);
|
|
|
|
static int mo_unresv(struct Client *, struct Client *, int, const char **);
|
|
|
|
static int ms_unresv(struct Client *, struct Client *, int, const char **);
|
|
|
|
static int me_unresv(struct Client *, struct Client *, int, const char **);
|
|
|
|
|
|
|
|
struct Message resv_msgtab = {
|
|
|
|
"RESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
|
|
|
|
{mg_ignore, mg_not_oper, {ms_resv, 4}, {ms_resv, 4}, {me_resv, 5}, {mo_resv, 3}}
|
|
|
|
};
|
2010-01-07 23:19:03 +00:00
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
struct Message unresv_msgtab = {
|
|
|
|
"UNRESV", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
|
|
|
|
{mg_ignore, mg_not_oper, {ms_unresv, 3}, {ms_unresv, 3}, {me_unresv, 2}, {mo_unresv, 2}}
|
|
|
|
};
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
mapi_clist_av1 resv_clist[] = { &resv_msgtab, &unresv_msgtab, NULL };
|
|
|
|
|
|
|
|
DECLARE_MODULE_AV1(resv, NULL, NULL, resv_clist, NULL, NULL, "$Revision$");
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
static void parse_resv(struct Client *source_p, const char *name,
|
2010-01-07 23:19:03 +00:00
|
|
|
const char *reason, int temp_time);
|
2007-01-25 06:40:21 +00:00
|
|
|
static void propagate_resv(struct Client *source_p, const char *target,
|
2010-01-07 23:19:03 +00:00
|
|
|
int temp_time, const char *name, const char *reason);
|
|
|
|
static void cluster_resv(struct Client *source_p, int temp_time,
|
|
|
|
const char *name, const char *reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
static void handle_remote_unresv(struct Client *source_p, const char *name);
|
|
|
|
static void remove_resv(struct Client *source_p, const char *name);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mo_resv()
|
2010-01-07 23:19:03 +00:00
|
|
|
* parv[0] = sender prefix
|
2007-01-25 06:40:21 +00:00
|
|
|
* parv[1] = channel/nick to forbid
|
|
|
|
* parv[2] = reason
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mo_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *reason;
|
|
|
|
const char *target_server = NULL;
|
|
|
|
int temp_time;
|
|
|
|
int loc = 1;
|
|
|
|
|
2007-12-17 01:20:14 +00:00
|
|
|
if(!IsOperResv(source_p))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv");
|
2007-12-17 01:20:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
/* RESV [time] <name> [ON <server>] :<reason> */
|
|
|
|
|
|
|
|
if((temp_time = valid_temp_time(parv[loc])) >= 0)
|
|
|
|
loc++;
|
|
|
|
/* we just set temp_time to -1! */
|
|
|
|
else
|
|
|
|
temp_time = 0;
|
|
|
|
|
|
|
|
name = parv[loc];
|
|
|
|
loc++;
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if((parc >= loc + 2) && (irccmp(parv[loc], "ON") == 0))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(!IsOperRemoteBan(source_p))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
2010-01-07 23:19:03 +00:00
|
|
|
me.name, source_p->name, "remoteban");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
target_server = parv[loc + 1];
|
2007-01-25 06:40:21 +00:00
|
|
|
loc += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parc <= loc || EmptyString(parv[loc]))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "RESV");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
reason = parv[loc];
|
|
|
|
|
|
|
|
/* remote resv.. */
|
|
|
|
if(target_server)
|
|
|
|
{
|
|
|
|
propagate_resv(source_p, target_server, temp_time, name, reason);
|
|
|
|
|
|
|
|
if(match(target_server, me.name) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
2008-04-01 20:18:48 +00:00
|
|
|
else if(rb_dlink_list_length(&cluster_conf_list) > 0)
|
2007-01-25 06:40:21 +00:00
|
|
|
cluster_resv(source_p, temp_time, name, reason);
|
|
|
|
|
|
|
|
parse_resv(source_p, name, reason, temp_time);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_resv()
|
2010-01-07 23:19:03 +00:00
|
|
|
* parv[0] = sender prefix
|
2007-01-25 06:40:21 +00:00
|
|
|
* parv[1] = target server
|
|
|
|
* parv[2] = channel/nick to forbid
|
|
|
|
* parv[3] = reason
|
|
|
|
*/
|
|
|
|
static int
|
2010-01-07 23:19:03 +00:00
|
|
|
ms_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
/* parv[0] parv[1] parv[2] parv[3]
|
|
|
|
* oper target server resv reason
|
2007-01-25 06:40:21 +00:00
|
|
|
*/
|
|
|
|
propagate_resv(source_p, parv[1], 0, parv[2], parv[3]);
|
|
|
|
|
|
|
|
if(!match(parv[1], me.name))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
parse_resv(source_p, parv[2], parv[3], 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-01-07 23:19:03 +00:00
|
|
|
me_resv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
/* time name 0 :reason */
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
parse_resv(source_p, parv[2], parv[4], atoi(parv[1]));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parse_resv()
|
|
|
|
*
|
|
|
|
* inputs - source_p if error messages wanted
|
|
|
|
* - thing to resv
|
|
|
|
* - reason for resv
|
|
|
|
* outputs -
|
|
|
|
* side effects - will parse the resv and create it if valid
|
|
|
|
*/
|
|
|
|
static void
|
2010-01-07 23:19:03 +00:00
|
|
|
parse_resv(struct Client *source_p, const char *name, const char *reason, int temp_time)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
if(!MyClient(source_p) &&
|
2007-01-25 06:40:21 +00:00
|
|
|
!find_shared_conf(source_p->username, source_p->host,
|
2010-01-07 23:19:03 +00:00
|
|
|
source_p->servptr->name,
|
|
|
|
(temp_time > 0) ? SHARED_TRESV : SHARED_PRESV))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if(IsChannelName(name))
|
|
|
|
{
|
|
|
|
if(hash_find_resv(name))
|
|
|
|
{
|
|
|
|
sendto_one_notice(source_p,
|
2010-01-07 23:19:03 +00:00
|
|
|
":A RESV has already been placed on channel: %s", name);
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strlen(name) > CHANNELLEN)
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":Invalid RESV length: %s", name);
|
2009-05-07 23:23:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(strchr(reason, '"'))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":Invalid character '\"' in comment");
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aconf = make_conf();
|
|
|
|
aconf->status = CONF_RESV_CHANNEL;
|
|
|
|
aconf->port = 0;
|
2010-01-08 00:14:15 +00:00
|
|
|
aconf->host = rb_strdup(name);
|
2008-04-01 23:26:34 +00:00
|
|
|
aconf->passwd = rb_strdup(reason);
|
2010-01-08 00:14:15 +00:00
|
|
|
add_to_resv_hash(aconf->host, aconf);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(temp_time > 0)
|
|
|
|
{
|
2008-04-01 23:53:20 +00:00
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
2010-01-07 23:19:03 +00:00
|
|
|
"%s added temporary %d min. RESV for [%s] [%s]",
|
|
|
|
get_oper_name(source_p), temp_time / 60,
|
|
|
|
name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
ilog(L_KLINE, "R %s %d %s %s",
|
2010-01-07 23:19:03 +00:00
|
|
|
get_oper_name(source_p), temp_time / 60, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]",
|
2010-01-07 23:19:03 +00:00
|
|
|
temp_time / 60, name);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-08 00:17:08 +00:00
|
|
|
{
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
|
|
|
"%s added RESV for [%s] [%s]",
|
|
|
|
get_oper_name(source_p), name, reason);
|
|
|
|
ilog(L_KLINE, "R %s 0 %s %s",
|
|
|
|
get_oper_name(source_p), name, reason);
|
|
|
|
sendto_one_notice(source_p, ":Added RESV [%s]", name);
|
|
|
|
|
2010-01-08 00:14:15 +00:00
|
|
|
bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0);
|
2010-01-08 00:17:08 +00:00
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else if(clean_resv_nick(name))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
if(strlen(name) > NICKLEN * 2)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":Invalid RESV length: %s", name);
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strchr(reason, '"'))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":Invalid character '\"' in comment");
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!valid_wild_card_simple(name))
|
|
|
|
{
|
|
|
|
sendto_one_notice(source_p,
|
2010-01-07 23:19:03 +00:00
|
|
|
":Please include at least %d non-wildcard "
|
|
|
|
"characters with the resv",
|
|
|
|
ConfigFileEntry.min_nonwildcard_simple);
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-25 17:18:07 +00:00
|
|
|
if(find_nick_resv_mask(name))
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
sendto_one_notice(source_p,
|
2010-01-07 23:19:03 +00:00
|
|
|
":A RESV has already been placed on nick: %s", name);
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aconf = make_conf();
|
|
|
|
aconf->status = CONF_RESV_NICK;
|
|
|
|
aconf->port = 0;
|
2010-01-08 00:14:15 +00:00
|
|
|
aconf->host = rb_strdup(name);
|
2008-04-01 23:26:34 +00:00
|
|
|
aconf->passwd = rb_strdup(reason);
|
2008-04-01 21:11:11 +00:00
|
|
|
rb_dlinkAddAlloc(aconf, &resv_conf_list);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(temp_time > 0)
|
|
|
|
{
|
2008-04-01 23:53:20 +00:00
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
2010-01-07 23:19:03 +00:00
|
|
|
"%s added temporary %d min. RESV for [%s] [%s]",
|
|
|
|
get_oper_name(source_p), temp_time / 60,
|
|
|
|
name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
ilog(L_KLINE, "R %s %d %s %s",
|
2010-01-07 23:19:03 +00:00
|
|
|
get_oper_name(source_p), temp_time / 60, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
sendto_one_notice(source_p, ":Added temporary %d min. RESV [%s]",
|
2010-01-07 23:19:03 +00:00
|
|
|
temp_time / 60, name);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-08 00:17:08 +00:00
|
|
|
{
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
|
|
|
"%s added RESV for [%s] [%s]",
|
|
|
|
get_oper_name(source_p), name, reason);
|
|
|
|
ilog(L_KLINE, "R %s 0 %s %s",
|
|
|
|
get_oper_name(source_p), name, reason);
|
|
|
|
sendto_one_notice(source_p, ":Added RESV [%s]", name);
|
|
|
|
|
2010-01-08 00:14:15 +00:00
|
|
|
bandb_add(BANDB_RESV, source_p, aconf->host, NULL, aconf->passwd, NULL, 0);
|
2010-01-08 00:17:08 +00:00
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one_notice(source_p, ":You have specified an invalid resv: [%s]", name);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
static void
|
2007-01-25 06:40:21 +00:00
|
|
|
propagate_resv(struct Client *source_p, const char *target,
|
2010-01-07 23:19:03 +00:00
|
|
|
int temp_time, const char *name, const char *reason)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
if(!temp_time)
|
|
|
|
{
|
|
|
|
sendto_match_servs(source_p, target,
|
2010-01-07 23:19:03 +00:00
|
|
|
CAP_CLUSTER, NOCAPS, "RESV %s %s :%s", target, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
sendto_match_servs(source_p, target,
|
2010-01-07 23:19:03 +00:00
|
|
|
CAP_ENCAP, CAP_CLUSTER,
|
|
|
|
"ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
sendto_match_servs(source_p, target,
|
2010-01-07 23:19:03 +00:00
|
|
|
CAP_ENCAP, NOCAPS,
|
|
|
|
"ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-01-07 23:19:03 +00:00
|
|
|
cluster_resv(struct Client *source_p, int temp_time, const char *name, const char *reason)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct remote_conf *shared_p;
|
2008-04-01 20:18:48 +00:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2008-04-01 20:18:48 +00:00
|
|
|
RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
shared_p = ptr->data;
|
|
|
|
|
|
|
|
/* old protocol cant handle temps, and we dont really want
|
|
|
|
* to convert them to perm.. --fl
|
|
|
|
*/
|
|
|
|
if(!temp_time)
|
|
|
|
{
|
|
|
|
if(!(shared_p->flags & SHARED_PRESV))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sendto_match_servs(source_p, shared_p->server,
|
2010-01-07 23:19:03 +00:00
|
|
|
CAP_CLUSTER, NOCAPS,
|
|
|
|
"RESV %s %s :%s", shared_p->server, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
sendto_match_servs(source_p, shared_p->server,
|
2010-01-07 23:19:03 +00:00
|
|
|
CAP_ENCAP, CAP_CLUSTER,
|
|
|
|
"ENCAP %s RESV 0 %s 0 :%s",
|
|
|
|
shared_p->server, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
else if(shared_p->flags & SHARED_TRESV)
|
|
|
|
sendto_match_servs(source_p, shared_p->server,
|
2010-01-07 23:19:03 +00:00
|
|
|
CAP_ENCAP, NOCAPS,
|
|
|
|
"ENCAP %s RESV %d %s 0 :%s",
|
|
|
|
shared_p->server, temp_time, name, reason);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mo_unresv()
|
2010-01-07 23:19:03 +00:00
|
|
|
* parv[0] = sender prefix
|
2007-01-25 06:40:21 +00:00
|
|
|
* parv[1] = channel/nick to unforbid
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mo_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
2007-12-17 01:20:14 +00:00
|
|
|
if(!IsOperResv(source_p))
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "resv");
|
2007-12-17 01:20:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-25 06:40:21 +00:00
|
|
|
if((parc == 4) && (irccmp(parv[2], "ON") == 0))
|
|
|
|
{
|
|
|
|
if(!IsOperRemoteBan(source_p))
|
|
|
|
{
|
|
|
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
2010-01-07 23:19:03 +00:00
|
|
|
me.name, source_p->name, "remoteban");
|
2007-01-25 06:40:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-07 23:19:03 +00:00
|
|
|
propagate_generic(source_p, "UNRESV", parv[3], CAP_CLUSTER, "%s", parv[1]);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(match(parv[3], me.name) == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
2008-04-01 20:18:48 +00:00
|
|
|
else if(rb_dlink_list_length(&cluster_conf_list) > 0)
|
2010-01-07 23:19:03 +00:00
|
|
|
cluster_generic(source_p, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", parv[1]);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
remove_resv(source_p, parv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_unresv()
|
2010-01-07 23:19:03 +00:00
|
|
|
* parv[0] = sender prefix
|
2007-01-25 06:40:21 +00:00
|
|
|
* parv[1] = target server
|
|
|
|
* parv[2] = resv to remove
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ms_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
2010-01-07 23:19:03 +00:00
|
|
|
/* parv[0] parv[1] parv[2]
|
|
|
|
* oper target server resv to remove
|
2007-01-25 06:40:21 +00:00
|
|
|
*/
|
2010-01-07 23:19:03 +00:00
|
|
|
propagate_generic(source_p, "UNRESV", parv[1], CAP_CLUSTER, "%s", parv[2]);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(!match(parv[1], me.name))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
handle_remote_unresv(source_p, parv[2]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
me_unresv(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
|
|
|
{
|
|
|
|
/* name */
|
|
|
|
if(!IsPerson(source_p))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
handle_remote_unresv(source_p, parv[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
handle_remote_unresv(struct Client *source_p, const char *name)
|
|
|
|
{
|
|
|
|
if(!find_shared_conf(source_p->username, source_p->host,
|
2010-01-07 23:19:03 +00:00
|
|
|
source_p->servptr->name, SHARED_UNRESV))
|
2007-01-25 06:40:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
remove_resv(source_p, name);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-30 22:35:48 +00:00
|
|
|
static void
|
|
|
|
remove_resv(struct Client *source_p, const char *name)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf = NULL;
|
|
|
|
|
|
|
|
if(IsChannelName(name))
|
|
|
|
{
|
|
|
|
if((aconf = hash_find_resv(name)) == NULL)
|
2007-11-30 22:35:48 +00:00
|
|
|
{
|
|
|
|
sendto_one_notice(source_p, ":No RESV for %s", name);
|
|
|
|
return;
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(!aconf->hold)
|
2010-01-07 23:19:03 +00:00
|
|
|
bandb_del(BANDB_RESV, aconf->host, NULL);
|
2007-11-30 22:35:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sendto_one_notice(source_p, ":RESV for [%s] is removed", name);
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
2010-01-07 23:19:03 +00:00
|
|
|
"%s has removed the RESV for: [%s]",
|
|
|
|
get_oper_name(source_p), name);
|
2007-11-30 22:35:48 +00:00
|
|
|
ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
del_from_resv_hash(name, aconf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-01 20:18:48 +00:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2008-04-01 20:18:48 +00:00
|
|
|
RB_DLINK_FOREACH(ptr, resv_conf_list.head)
|
2007-01-25 06:40:21 +00:00
|
|
|
{
|
|
|
|
aconf = ptr->data;
|
|
|
|
|
2010-01-08 00:14:15 +00:00
|
|
|
if(irccmp(aconf->host, name))
|
2007-01-25 06:40:21 +00:00
|
|
|
aconf = NULL;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(aconf == NULL)
|
2007-11-30 22:35:48 +00:00
|
|
|
{
|
|
|
|
sendto_one_notice(source_p, ":No RESV for %s", name);
|
|
|
|
return;
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
|
|
|
|
if(!aconf->hold)
|
2010-01-07 23:19:03 +00:00
|
|
|
bandb_del(BANDB_RESV, aconf->host, NULL);
|
2007-11-30 22:35:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sendto_one_notice(source_p, ":RESV for [%s] is removed", name);
|
|
|
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
2010-01-07 23:19:03 +00:00
|
|
|
"%s has removed the RESV for: [%s]",
|
|
|
|
get_oper_name(source_p), name);
|
2007-11-30 22:35:48 +00:00
|
|
|
ilog(L_KLINE, "UR %s %s", get_oper_name(source_p), name);
|
|
|
|
}
|
2007-01-25 06:40:21 +00:00
|
|
|
/* already have ptr from the loop above.. */
|
2008-04-01 20:54:08 +00:00
|
|
|
rb_dlinkDestroy(ptr, &resv_conf_list);
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|
2007-11-30 22:35:48 +00:00
|
|
|
free_conf(aconf);
|
2007-01-25 06:40:21 +00:00
|
|
|
|
2007-11-30 22:35:48 +00:00
|
|
|
return;
|
2007-01-25 06:40:21 +00:00
|
|
|
}
|