Cleaned up NACLantispam code in llviewermessage
parent
a0f8d6b64a
commit
e53b8b3b9a
|
|
@ -2013,7 +2013,10 @@ void LLOfferInfo::initRespondFunctionMap()
|
|||
void inventory_offer_handler(LLOfferInfo* info)
|
||||
{
|
||||
// NaCl - Antispam Registry
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_INVENTORY,info->mFromID)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_INVENTORY, info->mFromID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
// If muted, don't even go through the messaging stuff. Just curtail the offer here.
|
||||
|
|
@ -2542,31 +2545,41 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
|
|||
//msg->getData("MessageBlock", "Count", &count);
|
||||
msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, name);
|
||||
msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message);
|
||||
|
||||
// NaCl - Newline flood protection
|
||||
LLViewerObject* obj=gObjectList.findObject(from_id);
|
||||
bool doCheck=true;
|
||||
if(from_id.isNull())
|
||||
doCheck=false;
|
||||
if(gAgent.getID() == from_id)
|
||||
doCheck=false;
|
||||
if(obj)
|
||||
if(obj->permYouOwner())
|
||||
doCheck=false;
|
||||
if(doCheck)
|
||||
static LLCachedControl<bool> useAntiSpam(gSavedSettings, "UseAntiSpam");
|
||||
if (useAntiSpam)
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES);
|
||||
if((std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines) && gSavedSettings.getBOOL("UseAntiSpam"))
|
||||
bool doCheck = true;
|
||||
if (from_id.isNull() || gAgentID == from_id)
|
||||
{
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id);
|
||||
LLSD args;
|
||||
llinfos << "[antispam] blocked owner due to too many newlines: " << from_id << llendl;
|
||||
args["MESSAGE"] = llformat("AntiSpam: Blocked %s for sending message with %ud lines.",from_id.asString().c_str(),(U32)_NACL_AntiSpamNewlines);
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
return;
|
||||
doCheck = false;
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
LLViewerObject* obj = gObjectList.findObject(from_id);
|
||||
if (obj && obj->permYouOwner())
|
||||
{
|
||||
doCheck = false;
|
||||
}
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings, "_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(message.begin(), message.end(), NEWLINES);
|
||||
if ((std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines))
|
||||
{
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_IM, from_id);
|
||||
LLSD args;
|
||||
llinfos << "[antispam] blocked owner due to too many newlines: " << from_id << llendl;
|
||||
args["MESSAGE"] = llformat("AntiSpam: Blocked %s for sending message with %ud lines.", from_id.asString().c_str(), (U32)_NACL_AntiSpamNewlines);
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
msg->getU32Fast(_PREHASH_MessageBlock, _PREHASH_ParentEstateID, parent_estate_id);
|
||||
msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_RegionID, region_id);
|
||||
msg->getVector3Fast(_PREHASH_MessageBlock, _PREHASH_Position, position);
|
||||
|
|
@ -2574,9 +2587,12 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
|
|||
binary_bucket_size = msg->getSizeFast(_PREHASH_MessageBlock, _PREHASH_BinaryBucket);
|
||||
EInstantMessage dialog = (EInstantMessage)d;
|
||||
// NaCl - Antispam Registry
|
||||
if(dialog != IM_TYPING_START && dialog != IM_TYPING_STOP)
|
||||
if (dialog != IM_TYPING_START && dialog != IM_TYPING_STOP)
|
||||
{
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_IM, from_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
|
|
@ -3802,7 +3818,10 @@ void process_offer_callingcard(LLMessageSystem* msg, void**)
|
|||
LLUUID source_id;
|
||||
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, source_id);
|
||||
// NaCl - Antispam Registry
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CALLING_CARD,source_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CALLING_CARD, source_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// NaCl End
|
||||
LLUUID tid;
|
||||
msg->getUUIDFast(_PREHASH_AgentBlock, _PREHASH_TransactionID, tid);
|
||||
|
|
@ -3935,15 +3954,21 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
|
|||
chat.mChatType = (EChatType)type_temp;
|
||||
|
||||
// NaCL - Antispam Registry
|
||||
if(chat.mChatType != CHAT_TYPE_START && chat.mChatType != CHAT_TYPE_STOP)
|
||||
if (chat.mChatType != CHAT_TYPE_START && chat.mChatType != CHAT_TYPE_STOP)
|
||||
{
|
||||
if(owner_id.isNull())
|
||||
if (owner_id.isNull())
|
||||
{
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,from_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT, from_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT, owner_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
|
@ -4050,27 +4075,36 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
|
|||
|
||||
color.setVec(1.f,1.f,1.f,1.f);
|
||||
msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, mesg);
|
||||
// NaCl - Newline flood protection
|
||||
LLViewerObject* obj=gObjectList.findObject(from_id);
|
||||
bool doCheck=true;
|
||||
if(from_id.isNull())
|
||||
doCheck=false;
|
||||
if(gAgent.getID() == from_id)
|
||||
doCheck=false;
|
||||
if(obj)
|
||||
if(obj->permYouOwner())
|
||||
doCheck=false;
|
||||
if(doCheck)
|
||||
|
||||
// NaCl - Newline flood protection
|
||||
static LLCachedControl<bool> useAntiSpam(gSavedSettings, "UseAntiSpam");
|
||||
if (useAntiSpam)
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings,"_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES);
|
||||
if(std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines)
|
||||
bool doCheck = true;
|
||||
if (from_id.isNull() || gAgentID == from_id)
|
||||
{
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id);
|
||||
LLSD args;
|
||||
args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString();
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
return;
|
||||
doCheck = false;
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
LLViewerObject* obj = gObjectList.findObject(from_id);
|
||||
if (obj && obj->permYouOwner())
|
||||
{
|
||||
doCheck = false;
|
||||
}
|
||||
}
|
||||
if (doCheck)
|
||||
{
|
||||
static LLCachedControl<U32> _NACL_AntiSpamNewlines(gSavedSettings, "_NACL_AntiSpamNewlines");
|
||||
boost::sregex_iterator iter(mesg.begin(), mesg.end(), NEWLINES);
|
||||
if (std::abs(std::distance(iter, boost::sregex_iterator())) > _NACL_AntiSpamNewlines)
|
||||
{
|
||||
NACLAntiSpamRegistry::blockOnQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT, owner_id);
|
||||
LLSD args;
|
||||
args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString();
|
||||
LLNotificationsUtil::add("SystemMessageTip", args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
|
@ -5486,25 +5520,30 @@ void process_sound_trigger(LLMessageSystem *msg, void **)
|
|||
}
|
||||
|
||||
// NaCl - Antispam Registry
|
||||
bool bDoSpamCheck=1;
|
||||
std::string sSound=sound_id.asString();
|
||||
static LLCachedControl<U32> _NACL_AntiSpamSoundMulti(gSavedSettings,"_NACL_AntiSpamSoundMulti");
|
||||
bool bDoSpamCheck = true;
|
||||
std::string sSound = sound_id.asString();
|
||||
static LLCachedControl<U32> _NACL_AntiSpamSoundMulti(gSavedSettings, "_NACL_AntiSpamSoundMulti");
|
||||
static LLCachedControl<bool> FSPlayCollisionSounds(gSavedSettings, "FSPlayCollisionSounds");
|
||||
for(int i=0;i< COLLISION_SOUNDS_SIZE;i++) //AO: Should probably do this as a hashmap O(1) instead of O(n)
|
||||
for (S32 i = 0; i < COLLISION_SOUNDS_SIZE; i++) //AO: Should probably do this as a hashmap O(1) instead of O(n)
|
||||
{
|
||||
if(COLLISION_SOUNDS[i] == sSound)
|
||||
if (COLLISION_SOUNDS[i] == sSound)
|
||||
{
|
||||
if(!FSPlayCollisionSounds)
|
||||
if (!FSPlayCollisionSounds)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bDoSpamCheck=0;
|
||||
bDoSpamCheck = false;
|
||||
}
|
||||
}
|
||||
if(bDoSpamCheck)
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,object_id, _NACL_AntiSpamSoundMulti))
|
||||
if (bDoSpamCheck)
|
||||
{
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND, object_id, _NACL_AntiSpamSoundMulti))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ParentID, parent_id);
|
||||
msg->getU64Fast(_PREHASH_SoundData, _PREHASH_Handle, region_handle);
|
||||
msg->getVector3Fast(_PREHASH_SoundData, _PREHASH_Position, pos_local);
|
||||
|
|
@ -5579,21 +5618,27 @@ void process_preload_sound(LLMessageSystem *msg, void **user_data)
|
|||
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_id);
|
||||
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
|
||||
|
||||
if(FSWSAssetBlacklist::getInstance()->isBlacklisted(sound_id,LLAssetType::AT_SOUND)){
|
||||
if (FSWSAssetBlacklist::getInstance()->isBlacklisted(sound_id, LLAssetType::AT_SOUND))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// NaCl - Antispam Registry
|
||||
static LLCachedControl<U32> _NACL_AntiSpamSoundPreloadMulti(gSavedSettings,"_NACL_AntiSpamSoundPreloadMulti");
|
||||
if(owner_id.isNull())
|
||||
static LLCachedControl<U32> _NACL_AntiSpamSoundPreloadMulti(gSavedSettings, "_NACL_AntiSpamSoundPreloadMulti");
|
||||
if (owner_id.isNull())
|
||||
{
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD,object_id,_NACL_AntiSpamSoundPreloadMulti))
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD, object_id, _NACL_AntiSpamSoundPreloadMulti))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD,owner_id,_NACL_AntiSpamSoundPreloadMulti))
|
||||
{
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD, owner_id, _NACL_AntiSpamSoundPreloadMulti))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
// <FS:ND> Protect against corrupted sounds
|
||||
|
|
@ -5642,10 +5687,13 @@ void process_attached_sound(LLMessageSystem *msg, void **user_data)
|
|||
}
|
||||
|
||||
// NaCl - Antispam Registry
|
||||
static LLCachedControl<U32> _NACL_AntiSpamSoundMulti(gSavedSettings,"_NACL_AntiSpamSoundMulti");
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,object_id, _NACL_AntiSpamSoundMulti))
|
||||
return;
|
||||
static LLCachedControl<U32> _NACL_AntiSpamSoundMulti(gSavedSettings, "_NACL_AntiSpamSoundMulti");
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND, object_id, _NACL_AntiSpamSoundMulti))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
msg->getF32Fast(_PREHASH_DataBlock, _PREHASH_Gain, gain);
|
||||
msg->getU8Fast(_PREHASH_DataBlock, _PREHASH_Flags, flags);
|
||||
|
||||
|
|
@ -7335,7 +7383,10 @@ void notify_cautioned_script_question(const LLSD& notification, const LLSD& resp
|
|||
{
|
||||
// NaCl - Antispam Registry
|
||||
LLUUID task_id = notification["payload"]["task_id"].asUUID();
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,task_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, task_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// NaCl End
|
||||
// only continue if at least some permissions were requested
|
||||
if (orig_questions)
|
||||
|
|
@ -7551,14 +7602,24 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
|
|||
msg->getUUIDFast(_PREHASH_Data, _PREHASH_TaskID, taskid );
|
||||
// itemid -> script asset key of script requesting permissions
|
||||
msg->getUUIDFast(_PREHASH_Data, _PREHASH_ItemID, itemid );
|
||||
|
||||
// NaCl - Antispam Registry
|
||||
if(taskid.isNull())
|
||||
if (taskid.isNull())
|
||||
{
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,itemid)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, itemid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,taskid)) return;
|
||||
{
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, taskid))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectName, object_name);
|
||||
msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectOwner, owner_name);
|
||||
msg->getS32Fast(_PREHASH_Data, _PREHASH_Questions, questions );
|
||||
|
|
@ -8316,7 +8377,10 @@ void process_script_dialog(LLMessageSystem* msg, void**)
|
|||
LLUUID object_id;
|
||||
msg->getUUID("Data", "ObjectID", object_id);
|
||||
// NaCl - Antispam Registry
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,object_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, object_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// NaCl End
|
||||
|
||||
// For compability with OS grids first check for presence of extended packet before fetching data.
|
||||
|
|
@ -8325,7 +8389,10 @@ void process_script_dialog(LLMessageSystem* msg, void**)
|
|||
{
|
||||
msg->getUUID("OwnerData", "OwnerID", owner_id);
|
||||
// NaCl - Antispam Registry
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,owner_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, owner_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// NaCl End
|
||||
}
|
||||
|
||||
|
|
@ -8463,12 +8530,20 @@ void process_load_url(LLMessageSystem* msg, void**)
|
|||
msg->getUUID( "Data", "ObjectID", object_id);
|
||||
msg->getUUID( "Data", "OwnerID", owner_id);
|
||||
// NaCl - Antispam Registry
|
||||
if(owner_id.isNull())
|
||||
if (owner_id.isNull())
|
||||
{
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,object_id)) return;
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, object_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,owner_id)) return;
|
||||
{
|
||||
if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, owner_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// NaCl End
|
||||
msg->getBOOL( "Data", "OwnerIsGroup", owner_is_group);
|
||||
msg->getString("Data", "Message", 256, message);
|
||||
|
|
|
|||
Loading…
Reference in New Issue