X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fmod_bosh.lua;h=d9c8defd90ead6d891c5948ede45d90e04ce98a0;hb=8551bf5a2ae3d1c8bc47f052f531902fe4f0d919;hp=8c084c9581f66778dbb86db016564877c15b851b;hpb=b3f612032702f6a142c84c092683f3ae91e3712d;p=prosody.git diff --git a/plugins/mod_bosh.lua b/plugins/mod_bosh.lua index 8c084c95..d9c8defd 100644 --- a/plugins/mod_bosh.lua +++ b/plugins/mod_bosh.lua @@ -20,6 +20,8 @@ local logger = require "util.logger"; local log = logger.init("mod_bosh"); local initialize_filters = require "util.filters".initialize; local math_min = math.min; +local xpcall, tostring, type = xpcall, tostring, type; +local traceback = debug.traceback; local xmlns_streams = "http://etherx.jabber.org/streams"; local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; @@ -36,7 +38,7 @@ local bosh_max_wait = module:get_option_number("bosh_max_wait", 120); local consider_bosh_secure = module:get_option_boolean("consider_bosh_secure"); -local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8", ["Connection"] = "keep-alive" }; +local default_headers = { ["Content-Type"] = "text/xml; charset=utf-8" }; local cross_domain = module:get_option("cross_domain_bosh", false); if cross_domain then @@ -292,7 +294,8 @@ function stream_callbacks.streamopened(context, attr) body_attr.hold = tostring(session.bosh_hold); body_attr.authid = sid; body_attr.secure = "true"; - body_attr.ver = '1.6'; from = session.host; + body_attr.ver = '1.6'; + body_attr.from = session.host; body_attr["xmlns:xmpp"] = "urn:xmpp:xbosh"; body_attr["xmpp:version"] = "1.0"; end @@ -321,7 +324,7 @@ function stream_callbacks.streamopened(context, attr) session.log("warn", "rid too large (means a request was lost). Last rid: %d New rid: %s", session.rid, attr.rid); elseif diff <= 0 then -- Repeated, ignore - session.log("debug", "rid repeated (on request %s), ignoring: %s (diff %d)", request.id, session.rid, diff); + session.log("debug", "rid repeated, ignoring: %s (diff %d)", session.rid, diff); context.notopen = nil; context.ignore = true; context.sid = sid; @@ -351,6 +354,7 @@ function stream_callbacks.streamopened(context, attr) end end +local function handleerr(err) log("error", "Traceback[bosh]: %s", traceback(tostring(err), 2)); end function stream_callbacks.handlestanza(context, stanza) if context.ignore then return; end log("debug", "BOSH stanza received: %s\n", stanza:top_tag()); @@ -360,7 +364,9 @@ function stream_callbacks.handlestanza(context, stanza) stanza.attr.xmlns = nil; end stanza = session.filter("stanzas/in", stanza); - core_process_stanza(session, stanza); + if stanza then + return xpcall(function () return core_process_stanza(session, stanza) end, handleerr); + end end end