aboutsummaryrefslogtreecommitdiffstats
path: root/core/stanza_router.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-01-14 22:35:01 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-01-14 22:35:01 +0500
commitbf2469eb7c5fbc117c77305420b7721723665e39 (patch)
tree1fb030afa271810e07441cdd935b6373fc237e56 /core/stanza_router.lua
parent06ffda18818e1d0f0e2c41eb59468586f6da9dec (diff)
downloadprosody-bf2469eb7c5fbc117c77305420b7721723665e39.tar.gz
prosody-bf2469eb7c5fbc117c77305420b7721723665e39.zip
stanza_router: Fixed error replies for unhandled stanzas
Diffstat (limited to 'core/stanza_router.lua')
-rw-r--r--core/stanza_router.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index fe374912..52028653 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -48,6 +48,11 @@ local s_find = string.find;
local jid_split = require "util.jid".split;
local print = print;
+local function checked_error_reply(origin, stanza)
+ if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server" or not stanza.attr.xmlns) and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
+ origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
+ end
+end
function core_process_stanza(origin, stanza)
(origin.log or log)("debug", "Received[%s]: %s", origin.type, stanza:pretty_print()) --top_tag())
@@ -133,24 +138,19 @@ function core_handle_stanza(origin, stanza)
handle_normal_presence(origin, stanza, core_route_stanza);
else
log("warn", "Unhandled c2s presence: %s", tostring(stanza));
- if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" then
- origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
- end
+ checked_error_reply(origin, stanza);
end
else
log("warn", "Unhandled c2s stanza: %s", tostring(stanza));
- if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
- origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
- end
+ checked_error_reply(origin, stanza);
end
else -- s2s stanzas
log("warn", "Unhandled s2s stanza: %s", tostring(stanza));
- if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
- origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
- end
+ checked_error_reply(origin, stanza);
end
else
log("warn", "Unhandled %s stanza: %s", origin.type, tostring(stanza));
+ checked_error_reply(origin, stanza);
end
end