changeset 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
parents 939f8fc84d49
children 19698c5f3ab3
files mod_host_guard/mod_host_guard.lua
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_host_guard/mod_host_guard.lua	Sun May 27 01:37:25 2012 +0000
+++ b/mod_host_guard/mod_host_guard.lua	Sun May 27 02:44:06 2012 +0000
@@ -29,12 +29,13 @@
 end
 
 local function rr_hook (event)
-	local from_host, to_host = event.from_host, event.to_host
+	local from_host, to_host, send, stanza = event.from_host, event.to_host, event.origin.send, event.stanza
 
 	if guard_blockall:contains(from_host) and not guard_ball_wl:contains(to_host) or
 	   guard_block_bl:contains(to_host) and guard_protect:contains(from_host) then
 	     module:log("info", "attempted to connect to a filtered remote host %s", to_host)
-	     return false
+	     if stanza.attr.type ~= "error" then send(error_reply(event.stanza, "cancel", "policy-violation", "Communicating with a filtered remote server is not allowed.")) end
+	     return true
 	end
 
 	return nil