Fix up a mistake in antispam logic where only the user, not any other residents might be blocked.
Adds can_block() to NACLantispam.cpp to unify the blocking checks, so mistakes like this shouldn't happen again. Best viewed without space changes.
This commit is contained in:
@@ -23,6 +23,14 @@
|
||||
#include <time.h>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
bool can_block(const LLUUID& id)
|
||||
{
|
||||
if (id.isNull() || gAgent.getID() == id) return false; //Can't block system or self.
|
||||
if (const LLViewerObject* obj = gObjectList.findObject(id)) //From an object,
|
||||
return !obj->permYouOwner(); //not own object.
|
||||
return true;
|
||||
}
|
||||
|
||||
U32 NACLAntiSpamRegistry::globalAmount;
|
||||
U32 NACLAntiSpamRegistry::globalTime;
|
||||
bool NACLAntiSpamRegistry::bGlobalQueue;
|
||||
@@ -308,10 +316,8 @@ void NACLAntiSpamRegistry::blockGlobalEntry(LLUUID& source)
|
||||
bool NACLAntiSpamRegistry::checkQueue(U32 name, LLUUID& source, U32 multiplier)
|
||||
//returns true if blocked
|
||||
{
|
||||
if(source.isNull() || gAgent.getID() == source) return false;
|
||||
LLViewerObject *obj=gObjectList.findObject(source);
|
||||
if(obj && obj->permYouOwner()) return false;
|
||||
|
||||
if (!can_block(source)) return false;
|
||||
|
||||
int result;
|
||||
if(bGlobalQueue)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,6 @@
|
||||
#include "aicurl.h"
|
||||
#include "aihttptimeoutpolicy.h"
|
||||
|
||||
#include "NACLantispam.h" // for NaCl Antispam Registry
|
||||
|
||||
#ifdef TOGGLE_HACKED_GODLIKE_VIEWER
|
||||
BOOL gHackGodmode = FALSE;
|
||||
|
||||
@@ -182,6 +182,7 @@
|
||||
|
||||
// NaCl - Antispam Registry
|
||||
#include "NACLantispam.h"
|
||||
bool can_block(const LLUUID& id);
|
||||
// NaCl - Newline flood protection
|
||||
#include <boost/regex.hpp>
|
||||
static const boost::regex NEWLINES("\\n{1}");
|
||||
@@ -1956,27 +1957,22 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
|
||||
msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message);
|
||||
// NaCl - Newline flood protection
|
||||
static LLCachedControl<bool> AntiSpamEnabled(gSavedSettings,"AntiSpamEnabled",false);
|
||||
if(AntiSpamEnabled){
|
||||
LLViewerObject* obj=gObjectList.findObject(from_id);
|
||||
if(!from_id.isNull() //Not from nothing.
|
||||
&& gAgent.getID() != from_id //Not from self.
|
||||
&& !(obj && obj->permYouOwner())) //Not from own object.
|
||||
if (AntiSpamEnabled && can_block(from_id))
|
||||
{
|
||||
static LLCachedControl<U32> SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES);
|
||||
if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines)
|
||||
{
|
||||
static LLCachedControl<U32> SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES);
|
||||
if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines)
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id);
|
||||
llinfos << "[antispam] blocked owner due to too many newlines: " << from_id << llendl;
|
||||
if(gSavedSettings.getBOOL("AntiSpamNotify"))
|
||||
{
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id);
|
||||
llinfos << "[antispam] blocked owner due to too many newlines: " << from_id << llendl;
|
||||
if(gSavedSettings.getBOOL("AntiSpamNotify"))
|
||||
{
|
||||
LLSD args;
|
||||
args["SOURCE"] = from_id.asString();
|
||||
args["AMOUNT"] = boost::lexical_cast<std::string>(SpamNewlines);
|
||||
LLNotificationsUtil::add("AntiSpamNewlineFlood", args);
|
||||
}
|
||||
return;
|
||||
LLSD args;
|
||||
args["SOURCE"] = from_id.asString();
|
||||
args["AMOUNT"] = boost::lexical_cast<std::string>(SpamNewlines);
|
||||
LLNotificationsUtil::add("AntiSpamNewlineFlood", args);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
@@ -3540,25 +3536,20 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
|
||||
|
||||
// NaCl - Newline flood protection
|
||||
static LLCachedControl<bool> AntiSpamEnabled(gSavedSettings,"AntiSpamEnabled",false);
|
||||
if(AntiSpamEnabled){
|
||||
LLViewerObject* obj=gObjectList.findObject(from_id);
|
||||
if(!(from_id.isNull()) //Not from nothing.
|
||||
|| !(gAgent.getID() != from_id) //Not from self.
|
||||
|| !(obj && obj->permYouOwner())) //Not from own object.
|
||||
if (AntiSpamEnabled && can_block(from_id))
|
||||
{
|
||||
static LLCachedControl<U32> SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES);
|
||||
if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines)
|
||||
{
|
||||
static LLCachedControl<U32> SpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES);
|
||||
if((U32)std::abs(std::distance(iter, boost::sregex_iterator())) > SpamNewlines)
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id);
|
||||
if(gSavedSettings.getBOOL("AntiSpamNotify"))
|
||||
{
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id);
|
||||
if(gSavedSettings.getBOOL("AntiSpamNotify"))
|
||||
{
|
||||
LLSD args;
|
||||
args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString();
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
}
|
||||
return;
|
||||
LLSD args;
|
||||
args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString();
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
Reference in New Issue
Block a user