aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-01-23 16:25:21 +0000
committerMatthew Wild <mwild1@gmail.com>2012-01-23 16:25:21 +0000
commit3c5d5f95aded549e619dca86b7ff5689413646f9 (patch)
tree6280d6ef7f75c3fc8d85b510287123e7383fe77a
parent3e2d3f18754e6b367ff69b46f138af9770c92b62 (diff)
downloadprosody-3c5d5f95aded549e619dca86b7ff5689413646f9.tar.gz
prosody-3c5d5f95aded549e619dca86b7ff5689413646f9.zip
stanza_router: Replace s2s send logic with firing of a 'route/remote' event
-rw-r--r--core/stanza_router.lua23
1 files changed, 7 insertions, 16 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 4a30279d..54c5a1a6 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -11,7 +11,6 @@ local log = require "util.logger".init("stanzarouter")
local hosts = _G.prosody.hosts;
local tostring = tostring;
local st = require "util.stanza";
-local send_s2s = require "core.s2smanager".send_to_host;
local jid_split = require "util.jid".split;
local jid_prepped_split = require "util.jid".prepped_split;
@@ -184,26 +183,18 @@ function core_route_stanza(origin, stanza)
if hosts[host] then
-- old stanza routing code removed
core_post_stanza(origin, stanza);
- elseif origin.type == "c2s" then
- -- Remote host
+ else
+ log("debug", "Routing to remote...");
if not hosts[from_host] then
log("error", "No hosts[from_host] (please report): %s", tostring(stanza));
- end
- if (not hosts[from_host]) or (not hosts[from_host].disallow_s2s) then
+ else
local xmlns = stanza.attr.xmlns;
- --stanza.attr.xmlns = "jabber:server";
stanza.attr.xmlns = nil;
- log("debug", "sending s2s stanza: %s", tostring(stanza.top_tag and stanza:top_tag()) or stanza);
- send_s2s(origin.host, host, stanza); -- TODO handle remote routing errors
+ local routed = prosody.events.fire_event("route/remote", { origin = origin, stanza = stanza, from_host = from_host, to_host = host }); --FIXME: Should be per-host (shared modules!)
stanza.attr.xmlns = xmlns; -- reset
- else
- core_route_stanza(hosts[from_host], st.error_reply(stanza, "cancel", "not-allowed", "Communication with remote servers is not allowed"));
+ if routed == nil then
+ core_route_stanza(hosts[from_host], st.error_reply(stanza, "cancel", "not-allowed", "Communication with remote domains is not enabled"));
+ end
end
- elseif origin.type == "component" or origin.type == "local" then
- -- Route via s2s for components and modules
- log("debug", "Routing outgoing stanza for %s to %s", from_host, host);
- send_s2s(from_host, host, stanza);
- else
- log("warn", "received %s stanza from unhandled connection type: %s", tostring(stanza.name), tostring(origin.type));
end
end