X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmod_component.lua;h=297609d830d1a55ffab5c797477cef2c9e83fd19;hb=ed5838b20029fc151b02ddbc9eb73807707d5189;hp=3eaacb8eaf123994cea5237db7163c11b51cf5a4;hpb=6ac3f1382a0b99e13f28bb68f58650bdca777d35;p=prosody.git diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index 3eaacb8e..297609d8 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -25,6 +25,8 @@ local hosts = prosody.hosts; local log = module._log; +local opt_keepalives = module:get_option_boolean("component_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); + local sessions = module:shared("sessions"); function module.add_host(module) @@ -86,7 +88,7 @@ function module.add_host(module) return true; end - module:hook("stanza/jabber:component:accept:handshake", handle_component_auth); + module:hook("stanza/jabber:component:accept:handshake", handle_component_auth, -1); -- Handle stanzas addressed to this component local function handle_stanza(event) @@ -175,9 +177,7 @@ function stream_callbacks.streamopened(session, attr) session.streamid = uuid_gen(); session.notopen = nil; -- Return stream header - session.send(""); - session.send(st.stanza("stream:stream", { xmlns=xmlns_component, - ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.host }):top_tag()); + session:open_stream(); end function stream_callbacks.streamclosed(session) @@ -270,6 +270,10 @@ function listener.onconnect(conn) session.log = logger.init(conn_name); session.close = session_close; + if opt_keepalives then + conn:setoption("keepalive", opt_keepalives); + end + session.log("info", "Incoming Jabber component connection"); local stream = new_xmpp_stream(session, stream_callbacks);