view mod_firewall/scripts/spam-blocking.pfw @ 2564:240985f7d1f7

mod_firewall: SUBSCRIBED: Only check roster if 'to' address has a nodepart (fixes traceback)
author Matthew Wild <mwild1@gmail.com>
date Fri, 24 Feb 2017 09:51:43 +0000
parents 56db2ab3b853
children fc53165d8afe
line wrap: on
line source

#### Anti-spam ruleset

#### General rules for all incoming stanzas ####
::deliver

# Pass stanzas that a user sends to their own account
TO SELF?
PASS.

# Pass stanzas that are addressed to a valid full JID
TO FULL JID?
PASS.

# Pass stanzas from contacts
SUBSCRIBED?
PASS.

# Run extra rules that apply to messages only
KIND: message
JUMP_CHAIN=user/check_spam_message

# Run extra rules that apply to presence stanzas only
KIND: presence
JUMP CHAIN=user/check_spam_presence

#### Rules for messages ####
::user/check_spam_message

# Non-chat message types often generate pop-ups in clients,
# so we won't accept them from strangers
NOT TYPE: chat
JUMP CHAIN=user/reject_spam

# This chain can be used by other scripts
# and modules that analyze message content
JUMP CHAIN=user/check_spam_message_content

#### Rules for presence stanzas ####
::user/check_spam_presence

# These may be received if rosters get out of sync, and are harmless
# because they will not be routed to the client unless necessary
TYPE: unsubscribe|unsubscribed
PASS.

# We don't want to receive presence from random strangers,
# but still allow subscription requests
NOT TYPE: subscribe
DROP.

# This chain can be used by other scripts
# and modules to filter subscription requests
JUMP CHAIN=user/check_subscription_request

#### Stanzas reaching this chain will be rejected ####
::user/reject_spam

LOG=Rejecting suspected spam: $(stanza:top_tag())
BOUNCE=policy-violation