# HG changeset patch # User Matthew Wild # Date 1686220086 -3600 # Node ID 8226ac08484e334734c5cd645d4a40f6608aca64 # Parent a8f49bf7f8e639cb9ef84792de3108e228ba653d mod_firewall: Add 'FROM FULL JID?' condition diff -r a8f49bf7f8e6 -r 8226ac08484e mod_firewall/README.markdown --- a/mod_firewall/README.markdown Thu Jun 08 11:25:40 2023 +0100 +++ b/mod_firewall/README.markdown Thu Jun 08 11:28:06 2023 +0100 @@ -255,12 +255,13 @@ ### Sender/recipient matching - Condition Matches - ------------- ------------------------------------------------------- - `FROM` The JID in the 'from' attribute matches the given JID. - `TO` The JID in the 'to' attribute matches the given JID. - `TO SELF` The stanza is sent by any of a user's resources to their own bare JID. - `TO FULL JID` The stanza is addressed to a **valid** full JID on the local server (full JIDs include a resource at the end, and only exist for the lifetime of a single session, therefore the recipient **must be online**, or this check will not match). + Condition Matches + --------------- ------------------------------------------------------- + `FROM` The JID in the 'from' attribute matches the given JID. + `TO` The JID in the 'to' attribute matches the given JID. + `TO SELF` The stanza is sent by any of a user's resources to their own bare JID. + `TO FULL JID` The stanza is addressed to a **valid** full JID on the local server (full JIDs include a resource at the end, and only exist for the lifetime of a single session, therefore the recipient **must be online**, or this check will not match). + `FROM FULL JID` The stanza is from a full JID (unlike `TO FULL JID` this check is on the format of the JID only). The TO and FROM conditions both accept wildcards in the JID when it is enclosed in angle brackets ('\<...\>'). For example: diff -r a8f49bf7f8e6 -r 8226ac08484e mod_firewall/conditions.lib.lua --- a/mod_firewall/conditions.lib.lua Thu Jun 08 11:25:40 2023 +0100 +++ b/mod_firewall/conditions.lib.lua Thu Jun 08 11:28:06 2023 +0100 @@ -67,6 +67,10 @@ return compile_jid_match("from", from), { "split_from" }; end +function condition_handlers.FROM_FULL_JID() + return compile_jid_match_part("from_resource", nil), { "split_from" }; +end + function condition_handlers.FROM_EXACTLY(from) local metadeps = {}; return ("from == %s"):format(metaq(from, metadeps)), { "from", unpack(metadeps) };