aboutsummaryrefslogtreecommitdiffstats
path: root/core/stanza_router.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-10-16 08:34:32 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-10-16 08:34:32 +0500
commit85b44a1dfd59fee9a26527cc759ef72780a1668c (patch)
tree840ac938cfd82e8188706f3817bedeacbe8484c8 /core/stanza_router.lua
parent9cbf9dc9d6978298ac5503e57a725dadd7a55132 (diff)
downloadprosody-85b44a1dfd59fee9a26527cc759ef72780a1668c.tar.gz
prosody-85b44a1dfd59fee9a26527cc759ef72780a1668c.zip
modulemanager, stanza_router: Moved modulemanager.handle_stanza to stanza_router, as a local function handle_unhandled_stanza. modulemanager is no longer a dependency of stanza_router.
Diffstat (limited to 'core/stanza_router.lua')
-rw-r--r--core/stanza_router.lua27
1 files changed, 24 insertions, 3 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index d6dd5306..e2610769 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -12,7 +12,6 @@ local hosts = _G.prosody.hosts;
local tostring = tostring;
local st = require "util.stanza";
local send_s2s = require "core.s2smanager".send_to_host;
-local modules_handle_stanza = require "core.modulemanager".handle_stanza;
local component_handle_stanza = require "core.componentmanager".handle_stanza;
local jid_split = require "util.jid".split;
local jid_prepped_split = require "util.jid".prepped_split;
@@ -20,6 +19,28 @@ local jid_prepped_split = require "util.jid".prepped_split;
local full_sessions = _G.prosody.full_sessions;
local bare_sessions = _G.prosody.bare_sessions;
+local function handle_unhandled_stanza(host, origin, stanza)
+ local name, xmlns, origin_type = stanza.name, stanza.attr.xmlns or "jabber:client", origin.type;
+ if name == "iq" and xmlns == "jabber:client" then
+ if stanza.attr.type == "get" or stanza.attr.type == "set" then
+ xmlns = stanza.tags[1].attr.xmlns or "jabber:client";
+ log("debug", "Stanza of type %s from %s has xmlns: %s", name, origin_type, xmlns);
+ else
+ log("debug", "Discarding %s from %s of type: %s", name, origin_type, stanza.attr.type);
+ return true;
+ end
+ end
+ if stanza.attr.xmlns == nil then
+ log("debug", "Unhandled %s stanza: %s; xmlns=%s", origin.type, stanza.name, xmlns); -- we didn't handle it
+ if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
+ origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
+ end
+ elseif not((name == "features" or name == "error") and xmlns == "http://etherx.jabber.org/streams") then -- FIXME remove check once we handle S2S features
+ log("warn", "Unhandled %s stream element: %s; xmlns=%s: %s", origin.type, stanza.name, xmlns, tostring(stanza)); -- we didn't handle it
+ origin:close("unsupported-stanza-type");
+ end
+end
+
function core_process_stanza(origin, stanza)
(origin.log or log)("debug", "Received[%s]: %s", origin.type, stanza:top_tag())
@@ -114,7 +135,7 @@ function core_process_stanza(origin, stanza)
if h.events.fire_event(event, {origin = origin, stanza = stanza}) then return; end
end
if host and not hosts[host] then host = nil; end -- COMPAT: workaround for a Pidgin bug which sets 'to' to the SRV result
- modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
+ handle_unhandled_stanza(host or origin.host or origin.to_host, origin, stanza);
end
end
@@ -156,7 +177,7 @@ function core_post_stanza(origin, stanza, preevents)
component_handle_stanza(origin, stanza);
return;
end
- modules_handle_stanza(h.host, origin, stanza);
+ handle_unhandled_stanza(h.host, origin, stanza);
else
core_route_stanza(origin, stanza);
end