X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;ds=sidebyside;f=plugins%2Fmod_component.lua;h=871a20e4a28f27a1f01507d5829c29c850d7f7ba;hb=8d15cb8b83eb8a1b287bdd06a32750076d867287;hp=4037ad285af21b590314a3dede23bce61e380725;hpb=dd089432e58b61c3621c0d709e453ca1c286288e;p=prosody.git diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index 4037ad28..871a20e4 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 hosts = prosody.hosts; local log = module._log; @@ -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")); @@ -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 @@ -248,7 +260,7 @@ function listener.onconnect(conn) local session = { type = "component_unauthed", conn = conn, send = function (data) return _send(conn, tostring(data)); end }; -- Logging functions -- - local conn_name = "jcp"..tostring(conn):match("[a-f0-9]+$"); + local conn_name = "jcp"..tostring(session):match("[a-f0-9]+$"); session.log = logger.init(conn_name); session.close = session_close; @@ -295,11 +307,12 @@ 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 = { - pattern = "^<.*:stream.*%sxmlns%s*=%s*(['\"])jabber:component%1.*>"; + pattern = "^<.*:stream.*%sxmlns%s*=%s*(['\"])jabber:component:accept%1.*>"; }; });