error("proxy65 should be loaded as a component, please see http://prosody.im/doc/components", 0);
end
-local jid_split, jid_join, jid_compare = require "util.jid".split, require "util.jid".join, require "util.jid".compare;
+local jid_split, jid_join = require "util.jid".split, require "util.jid".join;
local st = require "util.stanza";
local componentmanager = require "core.componentmanager";
local config_get = require "core.configmanager".get;
local err_reply = replies_cache.stream_host_err;
local sid = stanza.tags[1].attr.sid;
local allow = false;
- local jid = stanza.attr.from;
+ local jid_node, jid_host, jid_resource = jid_split(stanza.attr.from);
+
+ if stanza.attr.from == nil then
+ jid_node = origin.username;
+ jid_host = origin.host;
+ jid_resource = origin.resource;
+ end
if proxy_acl and #proxy_acl > 0 then
- for _, acl in ipairs(proxy_acl) do
- if jid_compare(jid, acl) then allow = true; end
+ if host ~= nil then -- at least a domain is needed.
+ for _, acl in ipairs(proxy_acl) do
+ local acl_node, acl_host, acl_resource = jid_split(acl);
+ if ((acl_node ~= nil and acl_node == jid_node) or acl_node == nil) and
+ ((acl_host ~= nil and acl_host == jid_host) or acl_host == nil) and
+ ((acl_resource ~= nil and acl_resource == jid_resource) or acl_resource == nil) then
+ allow = true;
+ end
+ end
end
else
allow = true;
replies_cache.stream_host = reply;
end
else
- module:log("warn", "Denying use of proxy for %s", tostring(jid));
+ module:log("warn", "Denying use of proxy for %s", tostring(jid_join(jid_node, jid_host, jid_resource)));
if err_reply == nil then
err_reply = st.iq({type="error", from=host})
:query("http://jabber.org/protocol/bytestreams")
return reply, from, to, sid;
end
-function handle_to_domain(event)
- local origin, stanza = event.origin, event.stanza;
+function handle_to_domain(origin, stanza)
local to_node, to_host, to_resource = jid_split(stanza.attr.to);
if to_node == nil then
local type = stanza.attr.type;
end
return;
end
-module:hook("iq/host", handle_to_domain);
if not connlisteners.register(module.host .. ':proxy65', connlistener) then
module:log("error", "mod_proxy65: Could not establish a connection listener. Check your configuration please.");
end
connlisteners.start(module.host .. ':proxy65');
-component = componentmanager.register_component(host, function() end);
+component = componentmanager.register_component(host, handle_to_domain);