Software /
code /
prosody-modules
Comparison
mod_host_guard/mod_host_guard.lua @ 684:27529031890b
mod_host_guard: now a proper error is returned when stanzas are routed to a filtered remote server (thanks Zash)
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Sun, 27 May 2012 02:44:06 +0000 |
parent | 683:939f8fc84d49 |
child | 685:19698c5f3ab3 |
comparison
equal
deleted
inserted
replaced
683:939f8fc84d49 | 684:27529031890b |
---|---|
27 | 27 |
28 return nil | 28 return nil |
29 end | 29 end |
30 | 30 |
31 local function rr_hook (event) | 31 local function rr_hook (event) |
32 local from_host, to_host = event.from_host, event.to_host | 32 local from_host, to_host, send, stanza = event.from_host, event.to_host, event.origin.send, event.stanza |
33 | 33 |
34 if guard_blockall:contains(from_host) and not guard_ball_wl:contains(to_host) or | 34 if guard_blockall:contains(from_host) and not guard_ball_wl:contains(to_host) or |
35 guard_block_bl:contains(to_host) and guard_protect:contains(from_host) then | 35 guard_block_bl:contains(to_host) and guard_protect:contains(from_host) then |
36 module:log("info", "attempted to connect to a filtered remote host %s", to_host) | 36 module:log("info", "attempted to connect to a filtered remote host %s", to_host) |
37 return false | 37 if stanza.attr.type ~= "error" then send(error_reply(event.stanza, "cancel", "policy-violation", "Communicating with a filtered remote server is not allowed.")) end |
38 return true | |
38 end | 39 end |
39 | 40 |
40 return nil | 41 return nil |
41 end | 42 end |
42 | 43 |