X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmod_proxy65.lua;h=d6e41604555e05d240c268e49b97ab88fbcbe33a;hb=976a7c3d1d43bfce53acec682324ad36697001d2;hp=a0dd72330fb033e5970ffd848173e5d76dbf2fc8;hpb=dea460ee1adda84b8c5715f46ccf118963733437;p=prosody.git diff --git a/plugins/mod_proxy65.lua b/plugins/mod_proxy65.lua index a0dd7233..d6e41604 100644 --- a/plugins/mod_proxy65.lua +++ b/plugins/mod_proxy65.lua @@ -14,6 +14,7 @@ local st = require "util.stanza"; local sha1 = require "util.hashes".sha1; local b64 = require "util.encodings".base64.encode; local server = require "net.server"; +local portmanager = require "core.portmanager"; local sessions, transfers = module:shared("sessions", "transfers"); local max_buffer_size = 4096; @@ -91,9 +92,15 @@ function module.add_host(module) local host, name = module:get_host(), module:get_option_string("name", "SOCKS5 Bytestreams Service"); local proxy_address = module:get_option("proxy65_address", host); - local proxy_port = module:get_option_number("proxy65_port", next(portmanager.get_active_services():search("proxy65", nil)[1])); + local proxy_port = next(portmanager.get_active_services():search("proxy65", nil)[1] or {}); local proxy_acl = module:get_option("proxy65_acl"); + -- COMPAT w/pre-0.9 where proxy65_port was specified the components section of the config + local legacy_config = module:get_option_number("proxy65_port"); + if legacy_config then + module:log("warn", "proxy65_port is deprecated, please put proxy65_ports = { %d } into the global section instead", legacy_config); + end + module:add_identity("proxy", "bytestreams", name); module:add_feature("http://jabber.org/protocol/bytestreams"); @@ -117,9 +124,11 @@ function module.add_host(module) -- check ACL while proxy_acl and #proxy_acl > 0 do -- using 'while' instead of 'if' so we can break out of it local jid = stanza.attr.from; + local allow; for _, acl in ipairs(proxy_acl) do - if jid_compare(jid, acl) then break; end + if jid_compare(jid, acl) then allow = true; break; end end + if allow then break; end module:log("warn", "Denying use of proxy for %s", tostring(stanza.attr.from)); origin.send(st.error_reply(stanza, "auth", "forbidden")); return true;