X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmod_component.lua;h=16084a78a69b08f8bf79221f67bfdaec85fba69b;hb=99b003b1917a8ab0b561f7fb98d28d1fad8f8dc8;hp=09b0d2b3d190ba505e57795416802c179c785735;hpb=3ae615c0ceb94fa1f6439b8ab971561fa660f058;p=prosody.git diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index 09b0d2b3..16084a78 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -18,6 +18,8 @@ local jid_split = require "util.jid".split; local new_xmpp_stream = require "util.xmppstream".new; local uuid_gen = require "util.uuid".generate; +local core_process_stanza = prosody.core_process_stanza; + local log = module._log; @@ -43,7 +45,7 @@ function module.add_host(module) local function handle_component_auth(event) local session, stanza = event.origin, event.stanza; - if session.type ~= "component" then return; end + if session.type ~= "component_unauthed" then return; end if (not session.host) or #stanza.tags > 0 then (session.log or log)("warn", "Invalid component handshake for host: %s", session.host); @@ -91,6 +93,18 @@ function module.add_host(module) stanza.attr.xmlns = nil; send(stanza); else + if stanza.name == "iq" and stanza.attr.type == "get" and stanza.attr.to == module.host then + local query = stanza.tags[1]; + local node = query.attr.node; + if query.name == "query" and query.attr.xmlns == "http://jabber.org/protocol/disco#info" and (not node or node == "") then + local name = module:get_option_string("name"); + if name then + event.origin.send(st.reply(stanza):tag("query", { xmlns = "http://jabber.org/protocol/disco#info" }) + :tag("identity", { category = "component", type = "generic", name = module:get_option_string("name", "Prosody") })) + return true; + end + end + end module:log("warn", "Component not connected, bouncing error for: %s", stanza:top_tag()); if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then event.origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); @@ -124,7 +138,7 @@ local xmlns_xmpp_streams = "urn:ietf:params:xml:ns:xmpp-streams"; function stream_callbacks.error(session, error, data, data2) if session.destroyed then return; end - module:log("warn", "Error processing component stream: "..tostring(error)); + module:log("warn", "Error processing component stream: %s", tostring(error)); if error == "no-stream" then session:close("invalid-namespace"); elseif error == "parse-error" then @@ -169,8 +183,6 @@ function stream_callbacks.streamclosed(session) session:close(); end -local core_process_stanza = core_process_stanza; - function stream_callbacks.handlestanza(session, stanza) -- Namespaces are icky. if not stanza.attr.xmlns and stanza.name == "handshake" then @@ -295,8 +307,9 @@ function listener.ondisconnect(conn, err) end end -module:add_item("net-provider", { +module:provides("net", { name = "component"; + private = true; listener = listener; default_port = 5347; multiplex = {