From 33736ea75f5e27e1137abbe3dfedf856c064b7ef Mon Sep 17 00:00:00 2001 From: JD Horelick Date: Sun, 4 Jul 2010 15:27:34 -0400 Subject: [PATCH] Tweak auto-accept: * does not apply to NOTICE (as those may well be automated) * mirrors +g behaviour so that no useless accept entries are added for services * respects max_accept, if it would be exceeded the message is dropped with numeric 494 * check moved up so this is checked before floodcount/tgchange Pulled from Charybdis upstream changeset 1388:b1ef26176350 done by jilles. --- include/numeric.h | 2 ++ modules/core/m_message.c | 37 ++++++++++++++++++++++++++----------- src/messages.tab | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/numeric.h b/include/numeric.h index 5813775..0105be4 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -308,6 +308,8 @@ extern const char *form_str(int); #define ERR_KICKNOREJOIN 495 +#define ERR_OWNMODE 494 /* from bahamut -- jilles */ + #define ERR_UMODEUNKNOWNFLAG 501 #define ERR_USERSDONTMATCH 502 diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 162cef6..dd41852 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -739,6 +739,32 @@ msg_client(int p_or_n, const char *command, if(MyClient(source_p)) { + /* + * XXX: Controversial? Allow target users to send replies + * through a +g. Rationale is that people can presently use +g + * as a way to taunt users, e.g. harass them and hide behind +g + * as a way of griefing. --nenolod + */ + if(p_or_n != NOTICE && MyClient(source_p) && + IsSetCallerId(source_p) && + !accept_message(target_p, source_p) && + !IsOper(target_p)) + { + if(rb_dlink_list_length(&source_p->localClient->allow_list) < + ConfigFileEntry.max_accept) + { + rb_dlinkAddAlloc(target_p, &source_p->localClient->allow_list); + rb_dlinkAddAlloc(source_p, &target_p->on_allow_list); + } + else + { + sendto_one_numeric(source_p, ERR_OWNMODE, + form_str(ERR_OWNMODE), + target_p->name, "+g"); + return; + } + } + /* reset idle time for message only if its not to self * and its not a notice */ if(p_or_n != NOTICE) @@ -783,17 +809,6 @@ msg_client(int p_or_n, const char *command, sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY), target_p->name, target_p->user->away); - /* - * XXX: Controversial? Allow target users to send replies through a +g. - * Rationale is that people can presently use +g as a way to taunt users, - * e.g. harass them and hide behind +g as a way of griefing. --nenolod - */ - if(MyClient(source_p) && IsSetCallerId(source_p) && !accept_message(target_p, source_p)) - { - rb_dlinkAddAlloc(target_p, &source_p->localClient->allow_list); - rb_dlinkAddAlloc(source_p, &target_p->on_allow_list); - } - if(MyClient(target_p)) { if (IsSetNoCTCP(target_p) && p_or_n != NOTICE && *text == '\001' && strncasecmp(text + 1, "ACTION", 6)) diff --git a/src/messages.tab b/src/messages.tab index b8fc7d7..bb64fa3 100644 --- a/src/messages.tab +++ b/src/messages.tab @@ -515,7 +515,7 @@ static const char * replies[] = { /* 491 ERR_NOOPERHOST, */ ":No appropriate operator blocks were found for your host", /* 492 ERR_NOCTCP */ ":Can't send CTCP to %s (+C set)", /* 493 */ NULL, -/* 494 */ NULL, +/* 494 ERR_OWNMODE, */ "%s :cannot answer you while you are %s, your message was not sent", /* 495 ERR_KICKNOREJOIN */ ":%s 495 %s %s :Cannot rejoin channel so soon after being kicked (+J set)", /* 496 */ NULL, /* 497 */ NULL,