Remove +/- from the BAN message, instead indicating unban with duration=0.
A kline must now last at least one second since its creation time. Also add better logic for bans that have already expired when they come in.
This commit is contained in:
parent
f54e1a8fd6
commit
cedb7d05b4
3 changed files with 42 additions and 45 deletions
|
@ -47,7 +47,7 @@ static int ms_ban(struct Client *client_p, struct Client *source_p, int parc, co
|
||||||
|
|
||||||
struct Message ban_msgtab = {
|
struct Message ban_msgtab = {
|
||||||
"BAN", 0, 0, 0, MFLG_SLOW,
|
"BAN", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_ignore, {ms_ban, 10}, {ms_ban, 10}, mg_ignore, mg_ignore}
|
{mg_unreg, mg_ignore, {ms_ban, 9}, {ms_ban, 9}, mg_ignore, mg_ignore}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 ban_clist[] = { &ban_msgtab, NULL };
|
mapi_clist_av1 ban_clist[] = { &ban_msgtab, NULL };
|
||||||
|
@ -55,15 +55,14 @@ DECLARE_MODULE_AV1(ban, NULL, NULL, ban_clist, NULL, NULL, "$Revision: 1349 $");
|
||||||
|
|
||||||
/* ms_ban()
|
/* ms_ban()
|
||||||
*
|
*
|
||||||
* parv[1] - +/-
|
* parv[1] - type
|
||||||
* parv[2] - type
|
* parv[2] - username mask or *
|
||||||
* parv[3] - username mask or *
|
* parv[3] - hostname mask
|
||||||
* parv[4] - hostname mask
|
* parv[4] - creation TS
|
||||||
* parv[5] - creation TS
|
* parv[5] - duration (relative to creation)
|
||||||
* parv[6] - duration (relative to creation)
|
* parv[6] - lifetime (relative to creation)
|
||||||
* parv[7] - lifetime (relative to creation)
|
* parv[7] - oper or *
|
||||||
* parv[8] - oper or *
|
* parv[8] - reason (possibly with |operreason)
|
||||||
* parv[9] - reason (possibly with |operreason)
|
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
|
@ -76,21 +75,14 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
char *p;
|
char *p;
|
||||||
int act;
|
int act;
|
||||||
|
|
||||||
if (strcmp(parv[1], "+") && strcmp(parv[1], "-"))
|
if (strlen(parv[1]) != 1)
|
||||||
{
|
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
|
||||||
"Unknown BAN operation %s from %s",
|
|
||||||
parv[1], source_p->name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (strlen(parv[2]) != 1)
|
|
||||||
{
|
{
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
||||||
"Unknown BAN type %s from %s",
|
"Unknown BAN type %s from %s",
|
||||||
parv[2], source_p->name);
|
parv[1], source_p->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
switch (parv[2][0])
|
switch (parv[1][0])
|
||||||
{
|
{
|
||||||
case 'K':
|
case 'K':
|
||||||
ntype = CONF_KILL;
|
ntype = CONF_KILL;
|
||||||
|
@ -99,17 +91,17 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
default:
|
default:
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
||||||
"Unknown BAN type %s from %s",
|
"Unknown BAN type %s from %s",
|
||||||
parv[2], source_p->name);
|
parv[1], source_p->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
created = atol(parv[5]);
|
created = atol(parv[4]);
|
||||||
hold = created + atoi(parv[6]);
|
hold = created + atoi(parv[5]);
|
||||||
lifetime = created + atoi(parv[7]);
|
lifetime = created + atoi(parv[6]);
|
||||||
if (!strcmp(parv[8], "*"))
|
if (!strcmp(parv[7], "*"))
|
||||||
oper = IsServer(source_p) ? source_p->name : get_oper_name(source_p);
|
oper = IsServer(source_p) ? source_p->name : get_oper_name(source_p);
|
||||||
else
|
else
|
||||||
oper = parv[8];
|
oper = parv[7];
|
||||||
ptr = find_prop_ban(ntype, parv[3], parv[4]);
|
ptr = find_prop_ban(ntype, parv[2], parv[3]);
|
||||||
if (ptr != NULL)
|
if (ptr != NULL)
|
||||||
{
|
{
|
||||||
aconf = ptr->data;
|
aconf = ptr->data;
|
||||||
|
@ -124,7 +116,8 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
aconf->host);
|
aconf->host);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
act = !(aconf->status & CONF_ILLEGAL) || !strcmp(parv[1], "+");
|
act = !(aconf->status & CONF_ILLEGAL) || (hold != created &&
|
||||||
|
hold > rb_current_time());
|
||||||
if (lifetime > aconf->lifetime)
|
if (lifetime > aconf->lifetime)
|
||||||
aconf->lifetime = lifetime;
|
aconf->lifetime = lifetime;
|
||||||
/* already expired, hmm */
|
/* already expired, hmm */
|
||||||
|
@ -148,12 +141,12 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
aconf->status = CONF_ILLEGAL | ntype;
|
aconf->status = CONF_ILLEGAL | ntype;
|
||||||
aconf->lifetime = lifetime;
|
aconf->lifetime = lifetime;
|
||||||
rb_dlinkAddAlloc(aconf, &prop_bans);
|
rb_dlinkAddAlloc(aconf, &prop_bans);
|
||||||
act = !strcmp(parv[1], "+");
|
act = hold != created && hold > rb_current_time();
|
||||||
}
|
}
|
||||||
aconf->flags &= ~CONF_FLAGS_MYOPER;
|
aconf->flags &= ~CONF_FLAGS_MYOPER;
|
||||||
aconf->flags |= CONF_FLAGS_TEMPORARY;
|
aconf->flags |= CONF_FLAGS_TEMPORARY;
|
||||||
aconf->user = ntype == CONF_KILL ? rb_strdup(parv[3]) : NULL;
|
aconf->user = ntype == CONF_KILL ? rb_strdup(parv[2]) : NULL;
|
||||||
aconf->host = rb_strdup(parv[4]);
|
aconf->host = rb_strdup(parv[3]);
|
||||||
aconf->info.oper = operhash_add(oper);
|
aconf->info.oper = operhash_add(oper);
|
||||||
aconf->created = created;
|
aconf->created = created;
|
||||||
aconf->hold = hold;
|
aconf->hold = hold;
|
||||||
|
@ -165,7 +158,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
aconf->passwd = rb_strndup(parv[parc - 1], p - parv[parc - 1] + 1);
|
aconf->passwd = rb_strndup(parv[parc - 1], p - parv[parc - 1] + 1);
|
||||||
aconf->spasswd = rb_strdup(p + 1);
|
aconf->spasswd = rb_strdup(p + 1);
|
||||||
}
|
}
|
||||||
if (!strcmp(parv[1], "+"))
|
if (act && hold != created)
|
||||||
{
|
{
|
||||||
/* Keep the notices in sync with modules/m_kline.c etc. */
|
/* Keep the notices in sync with modules/m_kline.c etc. */
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||||
|
@ -173,18 +166,18 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
IsServer(source_p) ? source_p->name : get_oper_name(source_p),
|
IsServer(source_p) ? source_p->name : get_oper_name(source_p),
|
||||||
(hold - rb_current_time()) / 60,
|
(hold - rb_current_time()) / 60,
|
||||||
stype,
|
stype,
|
||||||
strcmp(parv[8], "*") ? " from " : "",
|
strcmp(parv[7], "*") ? " from " : "",
|
||||||
strcmp(parv[8], "*") ? parv[8] : "",
|
strcmp(parv[7], "*") ? parv[7] : "",
|
||||||
aconf->user ? aconf->user : "",
|
aconf->user ? aconf->user : "",
|
||||||
aconf->user ? "@" : "",
|
aconf->user ? "@" : "",
|
||||||
aconf->host,
|
aconf->host,
|
||||||
parv[parc - 1]);
|
parv[parc - 1]);
|
||||||
aconf->status &= ~CONF_ILLEGAL;
|
ilog(L_KLINE, "%s %s %d %s %s %s", parv[1],
|
||||||
ilog(L_KLINE, "%s %s %d %s %s %s", parv[2],
|
|
||||||
IsServer(source_p) ? source_p->name : get_oper_name(source_p),
|
IsServer(source_p) ? source_p->name : get_oper_name(source_p),
|
||||||
(hold - rb_current_time()) / 60,
|
(hold - rb_current_time()) / 60,
|
||||||
aconf->user, aconf->host,
|
aconf->user, aconf->host,
|
||||||
parv[parc - 1]);
|
parv[parc - 1]);
|
||||||
|
aconf->status &= ~CONF_ILLEGAL;
|
||||||
}
|
}
|
||||||
else if (act)
|
else if (act)
|
||||||
{
|
{
|
||||||
|
@ -195,9 +188,9 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
aconf->user ? aconf->user : "",
|
aconf->user ? aconf->user : "",
|
||||||
aconf->user ? "@" : "",
|
aconf->user ? "@" : "",
|
||||||
aconf->host,
|
aconf->host,
|
||||||
strcmp(parv[8], "*") ? " on behalf of " : "",
|
strcmp(parv[7], "*") ? " on behalf of " : "",
|
||||||
strcmp(parv[8], "*") ? parv[8] : "");
|
strcmp(parv[7], "*") ? parv[7] : "");
|
||||||
ilog(L_KLINE, "U%s %s %s %s", parv[2],
|
ilog(L_KLINE, "U%s %s %s %s", parv[1],
|
||||||
IsServer(source_p) ? source_p->name : get_oper_name(source_p),
|
IsServer(source_p) ? source_p->name : get_oper_name(source_p),
|
||||||
aconf->user, aconf->host);
|
aconf->user, aconf->host);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +219,7 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
||||||
":%s BAN %s %s %s %s %s %s %s %s :%s",
|
":%s BAN %s %s %s %s %s %s %s :%s",
|
||||||
source_p->id,
|
source_p->id,
|
||||||
parv[1],
|
parv[1],
|
||||||
parv[2],
|
parv[2],
|
||||||
|
@ -235,7 +228,6 @@ ms_ban(struct Client *client_p, struct Client *source_p, int parc, const char *p
|
||||||
parv[5],
|
parv[5],
|
||||||
parv[6],
|
parv[6],
|
||||||
parv[7],
|
parv[7],
|
||||||
parv[8],
|
|
||||||
parv[parc - 1]);
|
parv[parc - 1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -584,6 +584,11 @@ apply_prop_kline(struct Client *source_p, struct ConfItem *aconf,
|
||||||
/* Force creation time to increase. */
|
/* Force creation time to increase. */
|
||||||
if(oldconf->created >= aconf->created)
|
if(oldconf->created >= aconf->created)
|
||||||
aconf->created = oldconf->created + 1;
|
aconf->created = oldconf->created + 1;
|
||||||
|
/* Leave at least one second of validity. */
|
||||||
|
if(aconf->hold <= aconf->created)
|
||||||
|
aconf->hold = aconf->created + 1;
|
||||||
|
if(aconf->lifetime < aconf->hold)
|
||||||
|
aconf->lifetime = aconf->hold;
|
||||||
/* Tell deactivate_conf() to destroy it. */
|
/* Tell deactivate_conf() to destroy it. */
|
||||||
oldconf->lifetime = rb_current_time();
|
oldconf->lifetime = rb_current_time();
|
||||||
deactivate_conf(oldconf, ptr);
|
deactivate_conf(oldconf, ptr);
|
||||||
|
@ -617,7 +622,7 @@ apply_prop_kline(struct Client *source_p, struct ConfItem *aconf,
|
||||||
tkline_time / 60, aconf->user, aconf->host);
|
tkline_time / 60, aconf->user, aconf->host);
|
||||||
|
|
||||||
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
||||||
":%s BAN + K %s %s %lu %d %d * :%s%s%s",
|
":%s BAN K %s %s %lu %d %d * :%s%s%s",
|
||||||
source_p->id, aconf->user, aconf->host,
|
source_p->id, aconf->user, aconf->host,
|
||||||
(unsigned long)aconf->created,
|
(unsigned long)aconf->created,
|
||||||
(int)(aconf->hold - aconf->created),
|
(int)(aconf->hold - aconf->created),
|
||||||
|
@ -922,11 +927,12 @@ remove_prop_kline(struct Client *source_p, struct ConfItem *aconf)
|
||||||
aconf->created = rb_current_time();
|
aconf->created = rb_current_time();
|
||||||
else
|
else
|
||||||
aconf->created++;
|
aconf->created++;
|
||||||
|
aconf->hold = aconf->created;
|
||||||
operhash_delete(aconf->info.oper);
|
operhash_delete(aconf->info.oper);
|
||||||
aconf->info.oper = operhash_add(get_oper_name(source_p));
|
aconf->info.oper = operhash_add(get_oper_name(source_p));
|
||||||
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
|
||||||
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
|
||||||
":%s BAN - K %s %s %lu %d %d * :*",
|
":%s BAN K %s %s %lu %d %d * :*",
|
||||||
source_p->id, aconf->user, aconf->host,
|
source_p->id, aconf->user, aconf->host,
|
||||||
(unsigned long)aconf->created,
|
(unsigned long)aconf->created,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -438,9 +438,8 @@ burst_ban(struct Client *client_p)
|
||||||
oper = operbuf;
|
oper = operbuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sendto_one(client_p, ":%s BAN %c %s %s %s %lu %d %d %s :%s%s%s",
|
sendto_one(client_p, ":%s BAN %s %s %s %lu %d %d %s :%s%s%s",
|
||||||
me.id,
|
me.id,
|
||||||
aconf->status & CONF_ILLEGAL ? '-' : '+',
|
|
||||||
type,
|
type,
|
||||||
aconf->user ? aconf->user : "*", aconf->host,
|
aconf->user ? aconf->user : "*", aconf->host,
|
||||||
(unsigned long)aconf->created,
|
(unsigned long)aconf->created,
|
||||||
|
|
Loading…
Reference in a new issue