Made AntiSpam better

AntiSpamNotify setting to turn off notifications, which seemed to become a new form of spam, otherwise.
Add tool_tips to UI explaining how to make the system less sensitive.
Made defaults for antispam a lot less sensitive, so users used to the old antispam defaults won't likely need to configure the new panel.
Pull in license from NaCl... (Why wasn't it already there, Ruby?!)
Fixed spaces being where tabs should be...
Added in selective Dialog disabling, instead of just all, nice little feature in itself.
Potentially fixed a bug where sounds would be blocked when they shouldn't be... but, if this still happens, I'll put in a debug setting to disable sound antispam.
This commit is contained in:
Lirusaito
2012-07-25 09:03:41 -04:00
parent 89be317a00
commit 3190814265
7 changed files with 311 additions and 135 deletions

View File

@@ -1638,7 +1638,7 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD&
void inventory_offer_handler(LLOfferInfo* info, BOOL from_task)
{
//Until throttling is implmented, busy mode should reject inventory instead of silently
//Until throttling is implemented, busy mode should reject inventory instead of silently
//accepting it. SEE SL-39554
if (gAgent.getBusy())
{
@@ -1648,7 +1648,7 @@ void inventory_offer_handler(LLOfferInfo* info, BOOL from_task)
// NaCl - Antispam Registry
static LLCachedControl<bool> antispam(gSavedSettings,"_NACL_Antispam");
if(antispam || NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_INVENTORY,info->mFromID))
if(antispam || gSavedSettings.getBOOL("AntiSpamItemOffers") || 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.
@@ -1933,24 +1933,27 @@ 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);
if(!from_id.isNull() //Not from nothing.
&& gAgent.getID() != from_id //Not from self.
&& !(obj && obj->permYouOwner())) //Not from own object.
{
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);
LLSD args;
args["MESSAGE"] = "Message: Blocked newline flood from "+from_id.asString();
LLNotificationsUtil::add("SystemMessageTip", args);
return;
}
}
// NaCl End
// NaCl - Newline flood protection
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.
{
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);
if(gSavedSettings.getBOOL("AntiSpamNotify"))
{
LLSD args;
args["MESSAGE"] = "Message: Blocked newline flood from "+from_id.asString();
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);
@@ -1959,10 +1962,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
EInstantMessage dialog = (EInstantMessage)d;
// NaCl - Antispam Registry
if((dialog != IM_TYPING_START && dialog != IM_TYPING_STOP)
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id))
return;
// NaCl End
if((dialog != IM_TYPING_START && dialog != IM_TYPING_STOP)
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_IM,from_id))
return;
// NaCl End
// make sure that we don't have an empty or all-whitespace name
LLStringUtil::trim(name);
@@ -2427,7 +2430,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
case IM_GROUP_NOTICE_REQUESTED:
{
// NaCl - Antispam
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamGroupNotices"))
return;
// NaCl End
LL_INFOS("Messaging") << "Received IM_GROUP_NOTICE message." << LL_ENDL;
@@ -2526,7 +2529,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
case IM_GROUP_INVITATION:
{
// NaCl - Antispam
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamGroupInvites"))
return;
// NaCl End
//if (!is_linden && (is_busy || is_muted))
@@ -2574,7 +2577,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
// Someone has offered us some inventory.
{
// NaCl - Antispam
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamItemOffers"))
return;
// NaCl End
LLOfferInfo* info = new LLOfferInfo;
@@ -2829,10 +2832,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
}
break;
case IM_FROM_TASK_AS_ALERT:
// NaCl - Antispam
if(antispam)
return;
// NaCl End
// NaCl - Antispam
if(antispam || (!is_owned_by_me && gSavedSettings.getBOOL("AntiSpamAlerts")))
return;
// NaCl End
if (is_busy && !is_owned_by_me)
{
return;
@@ -2870,7 +2873,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
case IM_LURE_USER:
{
if(antispam) return; //NaCl Antispam
if(antispam || gSavedSettings.getBOOL("AntiSpamTeleports")) return; //NaCl Antispam
// [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c
// If the lure sender is a specific @accepttp exception they will override muted and busy status
bool fRlvSummon = (rlv_handler_t::isEnabled()) && (gRlvHandler.isException(RLV_BHVR_ACCEPTTP, from_id));
@@ -3011,10 +3014,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
case IM_GOTO_URL:
{
// NaCl - Antispam
if(antispam)
return;
// NaCl End
LLSD args;
// n.b. this is for URLs sent by the system, not for
// URLs sent by scripts (i.e. llLoadURL)
@@ -3040,7 +3039,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
case IM_FRIENDSHIP_OFFERED:
{
// NaCl - Antispam
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamFriendshipOffers"))
return;
// NaCl End
LLSD payload;
@@ -3179,7 +3178,7 @@ void process_offer_callingcard(LLMessageSystem* msg, void**)
{
// NaCl - Antispam
static LLCachedControl<bool> antispam(gSavedSettings,"_NACL_Antispam");
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamFriendshipOffers"))
return;
// NaCl End
// someone has offered to form a friendship
@@ -3189,9 +3188,9 @@ void process_offer_callingcard(LLMessageSystem* msg, void**)
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, source_id);
// NaCl - Antispam Registry
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CALLING_CARD,source_id))
return;
// NaCl End
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CALLING_CARD,source_id))
return;
// NaCl End
LLUUID tid;
msg->getUUIDFast(_PREHASH_AgentBlock, _PREHASH_TransactionID, tid);
@@ -3379,13 +3378,12 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
msg->getU8("ChatData", "ChatType", type_temp);
chat.mChatType = (EChatType)type_temp;
// NaCL - Antispam Registry
if((chat.mChatType != CHAT_TYPE_START && chat.mChatType != CHAT_TYPE_STOP) //Chat type isn't typing
&&((owner_id.isNull() && NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,from_id)) //Spam from an object?
||(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id)))) //Spam from a resident?
return;
// NaCl End
// NaCL - Antispam Registry
if((chat.mChatType != CHAT_TYPE_START && chat.mChatType != CHAT_TYPE_STOP) //Chat type isn't typing
&&((owner_id.isNull() && NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,from_id)) //Spam from an object?
||(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_CHAT,owner_id)))) //Spam from a resident?
return;
// NaCl End
msg->getU8Fast(_PREHASH_ChatData, _PREHASH_Audible, audible_temp);
chat.mAudible = (EChatAudible)audible_temp;
@@ -3507,23 +3505,26 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, mesg);
// NaCl - Newline flood protection
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.
{
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);
LLSD args;
args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString();
LLNotificationsUtil::add("SystemMessageTip", args);
return;
}
}
// NaCl End
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.
{
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"))
{
LLSD args;
args["MESSAGE"] = "Chat: Blocked newline flood from "+owner_id.asString();
LLNotificationsUtil::add("SystemMessageTip", args);
}
return;
}
}
// NaCl End
static std::map<LLUUID, bool> sChatObjectAuth;
@@ -4850,19 +4851,18 @@ void process_sound_trigger(LLMessageSystem *msg, void **)
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ObjectID, object_id);
// NaCl - Antispam Registry
/*if(owner_id.isNull())
{*/
bool bDoSpamCheck=1;
std::string sSound=sound_id.asString();
static LLCachedControl<U32> _NACL_AntiSpamSoundMulti(gSavedSettings,"_NACL_AntiSpamSoundMulti");
for(int i=0;i< COLLISION_SOUNDS_SIZE;i++)
if(COLLISION_SOUNDS[i] == sSound)
bDoSpamCheck=0;
static LLCachedControl<U32> _NACL_AntiSpamSoundMulti(gSavedSettings,"_NACL_AntiSpamSoundMulti");
if(owner_id.isNull())
{
bool bDoSpamCheck=1;
std::string sSound=sound_id.asString();
for(int i=0;i< COLLISION_SOUNDS_SIZE;i++)
if(COLLISION_SOUNDS[i] == sSound)
bDoSpamCheck=0;
if(bDoSpamCheck)
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,object_id, _NACL_AntiSpamSoundMulti,true)) return;
/*}
else
if(NACLAntiSpamRegistry::checkQueue("Soundspam",owner_id)) return;*/
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,object_id, _NACL_AntiSpamSoundMulti)) return;
}
else if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,owner_id, _NACL_AntiSpamSoundMulti)) return;
// NaCl End
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ParentID, parent_id);
@@ -4928,13 +4928,13 @@ 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);
// NaCl - Antispam Registry
static LLCachedControl<U32> _NACL_AntiSpamSoundPreloadMulti(gSavedSettings,"_NACL_AntiSpamSoundPreloadMulti");
if((owner_id.isNull()
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD,object_id,_NACL_AntiSpamSoundPreloadMulti))
|| NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD,owner_id,_NACL_AntiSpamSoundPreloadMulti))
return;
// NaCl End
// NaCl - Antispam Registry
static LLCachedControl<U32> _NACL_AntiSpamSoundPreloadMulti(gSavedSettings,"_NACL_AntiSpamSoundPreloadMulti");
if((owner_id.isNull()
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD,object_id,_NACL_AntiSpamSoundPreloadMulti))
|| NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD,owner_id,_NACL_AntiSpamSoundPreloadMulti))
return;
// NaCl End
LLViewerObject *objectp = gObjectList.findObject(object_id);
if (!objectp) return;
@@ -4972,12 +4972,12 @@ void process_attached_sound(LLMessageSystem *msg, void **user_data)
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_id);
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
// NaCl - Antispam Registry
if(/*owner_id.isNull()
&&*/ NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,object_id))
/*|| (NACLAntiSpamRegistry::checkQueue("Soundspam",owner_id))*/
return;
// NaCl End
// NaCl - Antispam Registry
if((owner_id.isNull()
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,object_id))
|| NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SOUND,owner_id))
return;
// NaCl End
msg->getF32Fast(_PREHASH_DataBlock, _PREHASH_Gain, gain);
msg->getU8Fast(_PREHASH_DataBlock, _PREHASH_Flags, flags);
@@ -6243,7 +6243,7 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
{
// NaCl - Antispam
static LLCachedControl<bool> antispam(gSavedSettings,"_NACL_Antispam");
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamScripts"))
return;
// NaCl End
// *TODO: Translate owner name -> [FIRST] [LAST]
@@ -6261,12 +6261,12 @@ void process_script_question(LLMessageSystem *msg, void **user_data)
// itemid -> script asset key of script requesting permissions
msg->getUUIDFast(_PREHASH_Data, _PREHASH_ItemID, itemid );
// NaCl - Antispam Registry
if((taskid.isNull()
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,itemid))
|| NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,taskid))
return;
// NaCl End
// NaCl - Antispam Registry
if((taskid.isNull()
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,itemid))
|| 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);
@@ -6928,7 +6928,7 @@ void process_script_dialog(LLMessageSystem* msg, void**)
{
// NaCl - Antispam
static LLCachedControl<bool> antispam(gSavedSettings,"_NACL_Antispam");
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamScripts"))
return;
// NaCl End
S32 i;
@@ -6938,9 +6938,9 @@ void process_script_dialog(LLMessageSystem* msg, void**)
msg->getUUID("Data", "ObjectID", object_id);
// NaCl - Antispam Registry
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,object_id))
return;
// NaCl End
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.
LLUUID owner_id;
@@ -6948,11 +6948,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;
// NaCl End
// NaCl - Antispam Registry
if(NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,owner_id))
return;
// NaCl End
}
if (LLMuteList::getInstance()->isMuted(object_id) || LLMuteList::getInstance()->isMuted(owner_id))
@@ -7110,7 +7109,7 @@ void process_load_url(LLMessageSystem* msg, void**)
{
// NaCl - Antispam
static LLCachedControl<bool> antispam(gSavedSettings,"_NACL_Antispam");
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamScripts"))
return;
// NaCl End
LLUUID object_id;
@@ -7124,12 +7123,12 @@ 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()
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,object_id))
|| NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,owner_id))
return;
// NaCl End
// NaCl - Antispam Registry
if((owner_id.isNull()
&& NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,object_id))
|| 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);
@@ -7205,7 +7204,7 @@ void process_script_teleport_request(LLMessageSystem* msg, void**)
{
// NaCl - Antispam
static LLCachedControl<bool> antispam(gSavedSettings,"_NACL_Antispam");
if(antispam)
if(antispam || gSavedSettings.getBOOL("AntiSpamScripts"))
return;
// NaCl End
if (!gSavedSettings.getBOOL("ScriptsCanShowUI")) return;