2007-01-25 07:40:21 +01: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
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
using namespace ircd;
|
|
|
|
|
2016-03-09 08:29:41 +01:00
|
|
|
static const char resv_desc[] =
|
|
|
|
"Provides management of reserved nicknames and channels using (UN)RESV";
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void mo_resv(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void ms_resv(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void me_resv(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void mo_unresv(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void ms_unresv(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
|
|
|
static void me_unresv(struct MsgBuf *, client::client &, client::client &, int, const char **);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
struct Message resv_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"RESV", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_ignore, mg_not_oper, {ms_resv, 4}, {ms_resv, 4}, {me_resv, 5}, {mo_resv, 3}}
|
|
|
|
};
|
2010-01-08 00:19:03 +01:00
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
struct Message unresv_msgtab = {
|
2016-02-19 23:42:40 +01:00
|
|
|
"UNRESV", 0, 0, 0, 0,
|
2007-01-25 07:40:21 +01:00
|
|
|
{mg_ignore, mg_not_oper, {ms_unresv, 3}, {ms_unresv, 3}, {me_unresv, 2}, {mo_unresv, 2}}
|
|
|
|
};
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
mapi_clist_av1 resv_clist[] = { &resv_msgtab, &unresv_msgtab, NULL };
|
|
|
|
|
2016-03-07 08:52:45 +01:00
|
|
|
DECLARE_MODULE_AV2(resv, NULL, NULL, resv_clist, NULL, NULL, NULL, NULL, resv_desc);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void parse_resv(client::client &source, const char *name,
|
2010-03-27 16:13:57 +01:00
|
|
|
const char *reason, int temp_time, int propagated);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void propagate_resv(client::client &source, const char *target,
|
2010-01-08 00:19:03 +01:00
|
|
|
int temp_time, const char *name, const char *reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
static void cluster_resv(client::client &source, int temp_time,
|
2010-01-08 00:19:03 +01:00
|
|
|
const char *name, const char *reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
static void handle_remote_unresv(client::client &source, const char *name);
|
|
|
|
static void remove_resv(client::client &source, const char *name, int propagated);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* mo_resv()
|
|
|
|
* parv[1] = channel/nick to forbid
|
|
|
|
* parv[2] = reason
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_resv(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *reason;
|
|
|
|
const char *target_server = NULL;
|
|
|
|
int temp_time;
|
|
|
|
int loc = 1;
|
2010-03-27 16:13:57 +01:00
|
|
|
int propagated = ConfigFileEntry.use_propagated_bans;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperResv(&source))
|
2007-12-17 02:20:14 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOPRIVS), me.name, source.name, "resv");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-12-17 02:20:14 +01:00
|
|
|
}
|
|
|
|
|
2007-01-25 07:40:21 +01: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-08 00:19:03 +01:00
|
|
|
if((parc >= loc + 2) && (irccmp(parv[loc], "ON") == 0))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperRemoteBan(&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, "remoteban");
|
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
|
|
|
target_server = parv[loc + 1];
|
2007-01-25 07:40:21 +01:00
|
|
|
loc += 2;
|
2010-03-27 16:13:57 +01:00
|
|
|
|
|
|
|
/* Set as local-only. */
|
|
|
|
propagated = 0;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(parc <= loc || EmptyString(parv[loc]))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NEEDMOREPARAMS), me.name, source.name, "RESV");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
reason = parv[loc];
|
|
|
|
|
|
|
|
/* remote resv.. */
|
|
|
|
if(target_server)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_resv(source, target_server, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(match(target_server, me.name) == 0)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2010-03-27 16:13:57 +01:00
|
|
|
else if(!propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_resv(source, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2010-03-27 16:13:57 +01:00
|
|
|
if(propagated && temp_time == 0)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Cannot set a permanent global ban");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2010-03-27 16:13:57 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
parse_resv(source, name, reason, temp_time, propagated);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_resv()
|
|
|
|
* parv[1] = target server
|
|
|
|
* parv[2] = channel/nick to forbid
|
|
|
|
* parv[3] = reason
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
ms_resv(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
/* parv[0] parv[1] parv[2] parv[3]
|
|
|
|
* oper target server resv reason
|
2007-01-25 07:40:21 +01:00
|
|
|
*/
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_resv(source, parv[1], 0, parv[2], parv[3]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!match(parv[1], me.name))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
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
|
|
|
parse_resv(source, parv[2], parv[3], 0, 0);
|
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
|
|
|
me_resv(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* time name 0 :reason */
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
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
|
|
|
parse_resv(source, parv[2], parv[4], atoi(parv[1]), 0);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* parse_resv()
|
|
|
|
*
|
2016-08-23 02:37:07 +02:00
|
|
|
* inputs - &source if error messages wanted
|
2007-01-25 07:40:21 +01:00
|
|
|
* - thing to resv
|
|
|
|
* - reason for resv
|
|
|
|
* outputs -
|
|
|
|
* side effects - will parse the resv and create it if valid
|
|
|
|
*/
|
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
parse_resv(client::client &source, const char *name, const char *reason, int temp_time, int propagated)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf;
|
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!my(source) &&
|
2016-08-23 02:37:07 +02:00
|
|
|
!find_shared_conf(source.username, source.host,
|
|
|
|
source.servptr->name,
|
2010-01-08 00:19:03 +01:00
|
|
|
(temp_time > 0) ? SHARED_TRESV : SHARED_PRESV))
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
|
2016-08-19 01:53:12 +02:00
|
|
|
if(chan::has_prefix(name))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
if(hash_find_resv(name))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source,
|
2010-01-08 00:19:03 +01:00
|
|
|
":A RESV has already been placed on channel: %s", name);
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strlen(name) > CHANNELLEN)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Invalid RESV length: %s", name);
|
2009-05-08 01:23:40 +02:00
|
|
|
return;
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
aconf = make_conf();
|
|
|
|
aconf->status = CONF_RESV_CHANNEL;
|
|
|
|
aconf->port = 0;
|
2010-02-28 00:46:56 +01:00
|
|
|
aconf->created = rb_current_time();
|
2010-01-08 01:14:15 +01:00
|
|
|
aconf->host = rb_strdup(name);
|
2008-04-02 01:26:34 +02: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
|
|
|
|
2010-03-27 16:13:57 +01:00
|
|
|
if(propagated)
|
|
|
|
{
|
|
|
|
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
|
|
|
aconf->lifetime = aconf->hold;
|
|
|
|
replace_old_ban(aconf);
|
|
|
|
rb_dlinkAddAlloc(aconf, &prop_bans);
|
|
|
|
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-27 16:13:57 +01:00
|
|
|
"%s added global %d min. RESV for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60,
|
2010-03-27 16:13:57 +01:00
|
|
|
name, reason);
|
|
|
|
ilog(L_KLINE, "R %s %d %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60, name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added global %d min. RESV [%s]",
|
2010-03-27 16:13:57 +01:00
|
|
|
temp_time / 60, name);
|
|
|
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
|
|
|
":%s BAN R * %s %lu %d %d * :%s",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.id, aconf->host,
|
2010-03-27 16:13:57 +01:00
|
|
|
(unsigned long)aconf->created,
|
|
|
|
(int)(aconf->hold - aconf->created),
|
|
|
|
(int)(aconf->lifetime - aconf->created),
|
|
|
|
reason);
|
|
|
|
}
|
|
|
|
else if(temp_time > 0)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-02 01:53:20 +02:00
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
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. RESV for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60,
|
2010-01-08 00:19:03 +01:00
|
|
|
name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
ilog(L_KLINE, "R %s %d %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60, name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added temporary %d min. RESV [%s]",
|
2010-01-08 00:19:03 +01:00
|
|
|
temp_time / 60, name);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
2010-01-08 01:17:08 +01:00
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 01:17:08 +01:00
|
|
|
"%s added RESV for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name, reason);
|
2010-01-08 01:17:08 +01:00
|
|
|
ilog(L_KLINE, "R %s 0 %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added RESV [%s]", name);
|
2010-01-08 01:17:08 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
bandb_add(BANDB_RESV, &source, aconf->host, NULL, aconf->passwd, NULL, 0);
|
2010-01-08 01:17:08 +01:00
|
|
|
}
|
2010-03-27 16:13:57 +01:00
|
|
|
|
|
|
|
add_to_resv_hash(aconf->host, aconf);
|
2016-08-18 07:33:38 +02:00
|
|
|
chan::resv_chan_forcepart(aconf->host, aconf->passwd, temp_time);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else if(clean_resv_nick(name))
|
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
if(strlen(name) > NICKLEN * 2)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Invalid RESV length: %s", name);
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!valid_wild_card_simple(name))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source,
|
2010-01-08 00:19:03 +01:00
|
|
|
":Please include at least %d non-wildcard "
|
|
|
|
"characters with the resv",
|
|
|
|
ConfigFileEntry.min_nonwildcard_simple);
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-25 18:18:07 +01:00
|
|
|
if(find_nick_resv_mask(name))
|
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
|
|
|
":A RESV has already been placed on nick: %s", name);
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
aconf = make_conf();
|
|
|
|
aconf->status = CONF_RESV_NICK;
|
|
|
|
aconf->port = 0;
|
2010-02-28 00:46:56 +01:00
|
|
|
aconf->created = rb_current_time();
|
2010-01-08 01:14:15 +01:00
|
|
|
aconf->host = rb_strdup(name);
|
2008-04-02 01:26:34 +02: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
|
|
|
|
2010-03-27 16:13:57 +01:00
|
|
|
if(propagated)
|
|
|
|
{
|
|
|
|
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
|
|
|
aconf->lifetime = aconf->hold;
|
|
|
|
replace_old_ban(aconf);
|
|
|
|
rb_dlinkAddAlloc(aconf, &prop_bans);
|
|
|
|
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-27 16:13:57 +01:00
|
|
|
"%s added global %d min. RESV for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60,
|
2010-03-27 16:13:57 +01:00
|
|
|
name, reason);
|
|
|
|
ilog(L_KLINE, "R %s %d %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60, name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added global %d min. RESV [%s]",
|
2010-03-27 16:13:57 +01:00
|
|
|
temp_time / 60, name);
|
|
|
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
|
|
|
":%s BAN R * %s %lu %d %d * :%s",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.id, aconf->host,
|
2010-03-27 16:13:57 +01:00
|
|
|
(unsigned long)aconf->created,
|
|
|
|
(int)(aconf->hold - aconf->created),
|
|
|
|
(int)(aconf->lifetime - aconf->created),
|
|
|
|
reason);
|
|
|
|
}
|
|
|
|
else if(temp_time > 0)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2008-04-02 01:53:20 +02:00
|
|
|
aconf->hold = rb_current_time() + temp_time;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
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. RESV for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60,
|
2010-01-08 00:19:03 +01:00
|
|
|
name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
ilog(L_KLINE, "R %s %d %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), temp_time / 60, name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added temporary %d min. RESV [%s]",
|
2010-01-08 00:19:03 +01:00
|
|
|
temp_time / 60, name);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
2010-01-08 01:17:08 +01:00
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-08 01:17:08 +01:00
|
|
|
"%s added RESV for [%s] [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name, reason);
|
2010-01-08 01:17:08 +01:00
|
|
|
ilog(L_KLINE, "R %s 0 %s %s",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name, reason);
|
|
|
|
sendto_one_notice(&source, ":Added RESV [%s]", name);
|
2010-01-08 01:17:08 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
bandb_add(BANDB_RESV, &source, aconf->host, NULL, aconf->passwd, NULL, 0);
|
2010-01-08 01:17:08 +01:00
|
|
|
}
|
2010-03-27 16:13:57 +01:00
|
|
|
|
|
|
|
rb_dlinkAddAlloc(aconf, &resv_conf_list);
|
2016-08-22 03:57:43 +02:00
|
|
|
client::resv_nick_fnc(aconf->host, aconf->passwd, temp_time);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":You have specified an invalid resv: [%s]", name);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
2010-01-08 00:19:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_resv(client::client &source, const char *target,
|
2010-01-08 00:19:03 +01:00
|
|
|
int temp_time, const char *name, const char *reason)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
if(!temp_time)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_CLUSTER, NOCAPS, "RESV %s %s :%s", target, name, reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_ENCAP, CAP_CLUSTER,
|
|
|
|
"ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, target,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_ENCAP, NOCAPS,
|
|
|
|
"ENCAP %s RESV %d %s 0 :%s", target, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_resv(client::client &source, int temp_time, const char *name, const char *reason)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct remote_conf *shared_p;
|
2008-04-01 22:18:48 +02:00
|
|
|
rb_dlink_node *ptr;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, cluster_conf_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-07-13 07:17:21 +02:00
|
|
|
shared_p = (remote_conf *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, shared_p->server,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_CLUSTER, NOCAPS,
|
|
|
|
"RESV %s %s :%s", shared_p->server, name, reason);
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, shared_p->server,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_ENCAP, CAP_CLUSTER,
|
|
|
|
"ENCAP %s RESV 0 %s 0 :%s",
|
|
|
|
shared_p->server, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
else if(shared_p->flags & SHARED_TRESV)
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_match_servs(&source, shared_p->server,
|
2010-01-08 00:19:03 +01:00
|
|
|
CAP_ENCAP, NOCAPS,
|
|
|
|
"ENCAP %s RESV %d %s 0 :%s",
|
|
|
|
shared_p->server, temp_time, name, reason);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mo_unresv()
|
|
|
|
* parv[1] = channel/nick to unforbid
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
mo_unresv(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-03-27 16:13:57 +01:00
|
|
|
int propagated = 1;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperResv(&source))
|
2007-12-17 02:20:14 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one(&source, form_str(ERR_NOPRIVS), me.name, source.name, "resv");
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-12-17 02:20:14 +01:00
|
|
|
}
|
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
if((parc == 4) && (irccmp(parv[2], "ON") == 0))
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!IsOperRemoteBan(&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, "remoteban");
|
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
|
|
|
propagate_generic(&source, "UNRESV", parv[3], CAP_CLUSTER, "%s", parv[1]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(match(parv[3], me.name) == 0)
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2010-03-27 16:13:57 +01:00
|
|
|
|
|
|
|
propagated = 0;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2010-03-27 16:13:57 +01:00
|
|
|
#if 0
|
2008-04-01 22:18:48 +02:00
|
|
|
else if(rb_dlink_list_length(&cluster_conf_list) > 0)
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_generic(&source, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", parv[1]);
|
2010-03-27 16:13:57 +01:00
|
|
|
#endif
|
|
|
|
/* cluster{} moved to remove_resv */
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
remove_resv(source, parv[1], propagated);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ms_unresv()
|
|
|
|
* parv[1] = target server
|
|
|
|
* parv[2] = resv to remove
|
|
|
|
*/
|
2016-03-09 08:37:03 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
ms_unresv(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
/* parv[0] parv[1] parv[2]
|
|
|
|
* oper target server resv to remove
|
2007-01-25 07:40:21 +01:00
|
|
|
*/
|
2016-08-23 02:37:07 +02:00
|
|
|
propagate_generic(&source, "UNRESV", parv[1], CAP_CLUSTER, "%s", parv[2]);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
if(!match(parv[1], me.name))
|
2016-03-09 08:37:03 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
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
|
|
|
handle_remote_unresv(source, parv[2]);
|
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
|
|
|
me_unresv(struct MsgBuf *msgbuf_p, client::client &client, client::client &source, int parc, const char *parv[])
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
/* name */
|
2016-08-23 04:33:36 +02:00
|
|
|
if(!is_person(source))
|
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
|
|
|
handle_remote_unresv(source, parv[1]);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
handle_remote_unresv(client::client &source, const char *name)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
if(!find_shared_conf(source.username, source.host,
|
|
|
|
source.servptr->name, SHARED_UNRESV))
|
2007-01-25 07:40:21 +01:00
|
|
|
return;
|
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
remove_resv(source, name, 0);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-30 23:35:48 +01:00
|
|
|
static void
|
2016-08-23 02:37:07 +02:00
|
|
|
remove_resv(client::client &source, const char *name, int propagated)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
struct ConfItem *aconf = NULL;
|
2010-03-27 16:13:57 +01:00
|
|
|
rb_dlink_node *ptr;
|
2014-09-21 15:02:43 +02:00
|
|
|
time_t now;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-19 01:53:12 +02:00
|
|
|
if(chan::has_prefix(name))
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
|
|
|
if((aconf = hash_find_resv(name)) == NULL)
|
2007-11-30 23:35:48 +01:00
|
|
|
{
|
2010-03-27 16:13:57 +01:00
|
|
|
if(propagated && rb_dlink_list_length(&cluster_conf_list))
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_generic(&source, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
|
2010-03-27 16:13:57 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":No RESV for %s", name);
|
2007-11-30 23:35:48 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2010-03-27 16:13:57 +01:00
|
|
|
if(aconf->lifetime)
|
|
|
|
{
|
|
|
|
if(!propagated)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Cannot remove global RESV %s on specific servers", name);
|
2010-03-27 16:13:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ptr = rb_dlinkFind(aconf, &prop_bans);
|
|
|
|
if(ptr == NULL)
|
|
|
|
return;
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":RESV for [%s] is removed", name);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-27 16:13:57 +01:00
|
|
|
"%s has removed the global RESV for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
|
|
|
ilog(L_KLINE, "UR %s %s", get_oper_name(&source), name);
|
2014-09-21 15:02:43 +02:00
|
|
|
now = rb_current_time();
|
|
|
|
if(aconf->created < now)
|
|
|
|
aconf->created = now;
|
2010-03-27 16:13:57 +01:00
|
|
|
else
|
|
|
|
aconf->created++;
|
|
|
|
aconf->hold = aconf->created;
|
|
|
|
operhash_delete(aconf->info.oper);
|
2016-08-23 02:37:07 +02:00
|
|
|
aconf->info.oper = operhash_add(get_oper_name(&source));
|
2010-03-27 16:13:57 +01:00
|
|
|
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
|
|
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
|
|
|
":%s BAN R * %s %lu %d %d * :*",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.id, aconf->host,
|
2010-03-27 16:13:57 +01:00
|
|
|
(unsigned long)aconf->created,
|
|
|
|
0,
|
|
|
|
(int)(aconf->lifetime - aconf->created));
|
2014-09-21 15:02:43 +02:00
|
|
|
deactivate_conf(aconf, ptr, now);
|
2010-03-27 16:13:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_generic(&source, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
|
2010-03-27 16:13:57 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":RESV for [%s] is removed", name);
|
|
|
|
ilog(L_KLINE, "UR %s %s", get_oper_name(&source), name);
|
2007-01-25 07:40:21 +01:00
|
|
|
if(!aconf->hold)
|
2010-01-09 22:12:06 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
bandb_del(BANDB_RESV, aconf->host, NULL);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-09 22:12:06 +01:00
|
|
|
"%s has removed the RESV for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
2010-01-09 22:12:06 +01:00
|
|
|
}
|
2007-11-30 23:35:48 +01:00
|
|
|
else
|
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-01-09 22:14:53 +01:00
|
|
|
"%s has removed the temporary RESV for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
2007-11-30 23:35:48 +01:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
del_from_resv_hash(name, aconf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-01 22:18:48 +02:00
|
|
|
RB_DLINK_FOREACH(ptr, resv_conf_list.head)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-07-13 07:17:21 +02:00
|
|
|
aconf = (ConfItem *)ptr->data;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2010-01-08 01:14:15 +01:00
|
|
|
if(irccmp(aconf->host, name))
|
2007-01-25 07:40:21 +01:00
|
|
|
aconf = NULL;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(aconf == NULL)
|
2007-11-30 23:35:48 +01:00
|
|
|
{
|
2010-03-27 16:13:57 +01:00
|
|
|
if(propagated && rb_dlink_list_length(&cluster_conf_list))
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_generic(&source, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
|
2010-03-27 16:13:57 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":No RESV for %s", name);
|
2007-11-30 23:35:48 +01:00
|
|
|
return;
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2010-03-27 16:13:57 +01:00
|
|
|
if(aconf->lifetime)
|
|
|
|
{
|
|
|
|
if(!propagated)
|
|
|
|
{
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":Cannot remove global RESV %s on specific servers", name);
|
2010-03-27 16:13:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ptr = rb_dlinkFind(aconf, &prop_bans);
|
|
|
|
if(ptr == NULL)
|
|
|
|
return;
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":RESV for [%s] is removed", name);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-27 16:13:57 +01:00
|
|
|
"%s has removed the global RESV for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
|
|
|
ilog(L_KLINE, "UR %s %s", get_oper_name(&source), name);
|
2014-09-21 15:02:43 +02:00
|
|
|
now = rb_current_time();
|
|
|
|
if(aconf->created < now)
|
|
|
|
aconf->created = now;
|
2010-03-27 16:13:57 +01:00
|
|
|
else
|
|
|
|
aconf->created++;
|
|
|
|
aconf->hold = aconf->created;
|
|
|
|
operhash_delete(aconf->info.oper);
|
2016-08-23 02:37:07 +02:00
|
|
|
aconf->info.oper = operhash_add(get_oper_name(&source));
|
2010-03-27 16:13:57 +01:00
|
|
|
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
|
|
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
|
|
|
":%s BAN R * %s %lu %d %d * :*",
|
2016-08-23 02:37:07 +02:00
|
|
|
source.id, aconf->host,
|
2010-03-27 16:13:57 +01:00
|
|
|
(unsigned long)aconf->created,
|
|
|
|
0,
|
|
|
|
(int)(aconf->lifetime - aconf->created));
|
2014-09-21 15:02:43 +02:00
|
|
|
deactivate_conf(aconf, ptr, now);
|
2010-03-27 16:13:57 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(propagated && rb_dlink_list_length(&cluster_conf_list) > 0)
|
2016-08-23 02:37:07 +02:00
|
|
|
cluster_generic(&source, "UNRESV", SHARED_UNRESV, CAP_CLUSTER, "%s", name);
|
2010-03-27 16:13:57 +01:00
|
|
|
|
2016-08-23 02:37:07 +02:00
|
|
|
sendto_one_notice(&source, ":RESV for [%s] is removed", name);
|
|
|
|
ilog(L_KLINE, "UR %s %s", get_oper_name(&source), name);
|
2007-01-25 07:40:21 +01:00
|
|
|
if(!aconf->hold)
|
2010-03-27 16:24:13 +01:00
|
|
|
{
|
2010-01-08 00:19:03 +01:00
|
|
|
bandb_del(BANDB_RESV, aconf->host, NULL);
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-27 16:24:13 +01:00
|
|
|
"%s has removed the RESV for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
2010-03-27 16:24:13 +01:00
|
|
|
}
|
2007-11-30 23:35:48 +01:00
|
|
|
else
|
|
|
|
{
|
2016-08-26 13:50:12 +02:00
|
|
|
sendto_realops_snomask(sno::GENERAL, L_ALL,
|
2010-03-27 16:24:13 +01:00
|
|
|
"%s has removed the temporary RESV for: [%s]",
|
2016-08-23 02:37:07 +02:00
|
|
|
get_oper_name(&source), name);
|
2007-11-30 23:35:48 +01:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
/* already have ptr from the loop above.. */
|
2008-04-01 22:54:08 +02:00
|
|
|
rb_dlinkDestroy(ptr, &resv_conf_list);
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|
2007-11-30 23:35:48 +01:00
|
|
|
free_conf(aconf);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2007-11-30 23:35:48 +01:00
|
|
|
return;
|
2007-01-25 07:40:21 +01:00
|
|
|
}
|