Mercurial > prosody-modules
comparison mod_firewall/conditions.lib.lua @ 2928:b0d92332b87f
mod_firewall: Add special case for $local zone (fixes #1090)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 12 Mar 2018 12:26:15 +0100 |
parents | b1cdcbcd1c90 |
children | df6227e288e5 |
comparison
equal
deleted
inserted
replaced
2927:7953b7dde6e7 | 2928:b0d92332b87f |
---|---|
85 assert(type, "Expected 'type' value to match against"); | 85 assert(type, "Expected 'type' value to match against"); |
86 return compile_comparison_list("(type or (name == 'message' and 'normal') or (name == 'presence' and 'available'))", type), { "type", "name" }; | 86 return compile_comparison_list("(type or (name == 'message' and 'normal') or (name == 'presence' and 'available'))", type), { "type", "name" }; |
87 end | 87 end |
88 | 88 |
89 local function zone_check(zone, which) | 89 local function zone_check(zone, which) |
90 local zone_var = zone; | |
91 if zone == "$local" then zone_var = "_local" end | |
90 local which_not = which == "from" and "to" or "from"; | 92 local which_not = which == "from" and "to" or "from"; |
91 return ("(zone_%s[%s_host] or zone_%s[%s] or zone_%s[bare_%s]) " | 93 return ("(zone_%s[%s_host] or zone_%s[%s] or zone_%s[bare_%s]) " |
92 .."and not(zone_%s[%s_host] or zone_%s[%s] or zone_%s[bare_%s])" | 94 .."and not(zone_%s[%s_host] or zone_%s[%s] or zone_%s[bare_%s])" |
93 ) | 95 ) |
94 :format(zone, which, zone, which, zone, which, | 96 :format(zone_var, which, zone_var, which, zone_var, which, |
95 zone, which_not, zone, which_not, zone, which_not), { | 97 zone_var, which_not, zone_var, which_not, zone_var, which_not), { |
96 "split_to", "split_from", "bare_to", "bare_from", "zone:"..zone | 98 "split_to", "split_from", "bare_to", "bare_from", "zone:"..zone |
97 }; | 99 }; |
98 end | 100 end |
99 | 101 |
100 function condition_handlers.ENTERING(zone) | 102 function condition_handlers.ENTERING(zone) |