plugins/mod_proxy65.lua
branch0.11
changeset 9649 cc642c9c5ad5
parent 9149 6bd3602a70e2
parent 9647 bb8486491b48
child 10115 0f335815244f
child 11559 65dcc175ef5b
--- a/plugins/mod_proxy65.lua	Sun Nov 25 14:47:36 2018 +0100
+++ b/plugins/mod_proxy65.lua	Mon Nov 26 19:48:07 2018 +0100
@@ -93,7 +93,6 @@
 	local host, name = module:get_host(), module:get_option_string("name", "SOCKS5 Bytestreams Service");
 
 	local proxy_address = module:get_option_string("proxy65_address", host);
-	local proxy_port = next(portmanager.get_active_services():search("proxy65", nil)[1] or {});
 	local proxy_acl = module:get_option_array("proxy65_acl");
 
 	-- COMPAT w/pre-0.9 where proxy65_port was specified in the components section of the config
@@ -123,6 +122,13 @@
 			return true;
 		end
 
+		local proxy_port = next(portmanager.get_active_services():search("proxy65", nil)[1] or {});
+		if not proxy_port then
+			module:log("warn", "Not listening on any port");
+			origin.send(st.error_reply(stanza, "wait", "item-not-found", "Not listening on any port"));
+			return true;
+		end
+
 		local sid = stanza.tags[1].attr.sid;
 		origin.send(st.reply(stanza):tag("query", {xmlns="http://jabber.org/protocol/bytestreams", sid=sid})
 			:tag("streamhost", {jid=host, host=proxy_address, port=("%d"):format(proxy_port)}));