From 6db3d039b3d8d55c9e03ebdc776cf1a23dd826c2 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 2 Oct 2008 01:08:58 +0100 Subject: SASL! (but before you get too excited, no resource binding yet. And yes, there are still plenty of rough edges to the code...) ((eg. must move out of xmlhandlers.lua o_O )) --- core/xmlhandlers.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'core/xmlhandlers.lua') diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index 96e3f3ac..b6050c5a 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -27,6 +27,7 @@ function init_xmlhandlers(session) local stanza function xml_handlers:StartElement(name, attr) + log("info", "xmlhandlers", "Start element: " .. name); if stanza and #chardata > 0 then -- We have some character data in the buffer stanza:text(t_concat(chardata)); @@ -41,21 +42,28 @@ function init_xmlhandlers(session) session.streamid = m_random(1000000, 99999999); print(session, session.host, "Client opened stream"); send(""); - send(format("", session.streamid, session.host)); - --send(""); - --send("PLAIN"); + send(format("", session.streamid, session.host)); + send(""); + if not session.username then + send(""); + send("PLAIN"); + send(""); + else + send(""); + end --send [[ ]] - --send(""); + send(""); log("info", "core", "Stream opened successfully"); session.notopen = nil; return; end error("Client failed to open stream successfully"); end - if name ~= "iq" and name ~= "presence" and name ~= "message" then + if curr_ns == "jabber:client" and name ~= "iq" and name ~= "presence" and name ~= "message" then error("Client sent invalid top-level stanza"); end - stanza = st.stanza(name, { to = attr.to, type = attr.type, id = attr.id, xmlns = curr_ns }); + attr.xmlns = curr_ns; + stanza = st.stanza(name, attr); --{ to = attr.to, type = attr.type, id = attr.id, xmlns = curr_ns }); curr_tag = stanza; else attr.xmlns = curr_ns; -- cgit v1.2.3