Changeset

1780:b3e3ad35391a

mod_onions: Small fixes making bounce_sendq match mod_s2s again.
author Thijs Alkemade <me@thijsalkema.de>
date Thu, 13 Aug 2015 18:20:33 +0200
parents 1779:bdf1de953fd9
children 1781:12ac88940fe3
files mod_onions/mod_onions.lua
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mod_onions/mod_onions.lua	Thu Aug 13 18:03:11 2015 +0200
+++ b/mod_onions/mod_onions.lua	Thu Aug 13 18:20:33 2015 +0200
@@ -1,3 +1,6 @@
+local prosody = prosody;
+local core_process_stanza = prosody.core_process_stanza;
+
 local wrapclient = require "net.server".wrapclient;
 local s2s_new_outgoing = require "core.s2smanager".new_outgoing;
 local initialize_filters = require "util.filters".initialize;
@@ -197,10 +200,11 @@
 	host_session.conn = conn;
 end
 
+local bouncy_stanzas = { message = true, presence = true, iq = true };
 local function bounce_sendq(session, reason)
 	local sendq = session.sendq;
 	if not sendq then return; end
-	session.log("info", "sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host));
+	session.log("info", "Sending error replies for "..#sendq.." queued stanzas because of failed outgoing connection to "..tostring(session.to_host));
 	local dummy = {
 		type = "s2sin";
 		send = function(s)
@@ -210,13 +214,13 @@
 	};
 	for i, data in ipairs(sendq) do
 		local reply = data[2];
-		if reply and not(reply.attr.xmlns) then
+		if reply and not(reply.attr.xmlns) and bouncy_stanzas[reply.name] then
 			reply.attr.type = "error";
 			reply:tag("error", {type = "cancel"})
 				:tag("remote-server-not-found", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}):up();
 			if reason then
 				reply:tag("text", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"})
-						:text("Server-to-server connection failed: "..reason):up();
+					:text("Server-to-server connection failed: "..reason):up();
 			end
 			core_process_stanza(dummy, reply);
 		end
@@ -224,14 +228,13 @@
 	end
 	session.sendq = nil;
 end
-
 -- Try to intercept anything to *.onion
 local function route_to_onion(event)
 	local stanza = event.stanza;
 
 	if not event.to_host:find(".onion(.?)$") then
 		if forbid_else then
-	                module:log("debug", event.to_host .. " is not an onion. Blocking it.");
+			module:log("debug", event.to_host .. " is not an onion. Blocking it.");
 			return false;
 		elseif not torify_all then
 			return;