aboutsummaryrefslogtreecommitdiffstats
path: root/core/xmlhandlers.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-10-02 01:08:58 +0100
committerMatthew Wild <mwild1@gmail.com>2008-10-02 01:08:58 +0100
commit6db3d039b3d8d55c9e03ebdc776cf1a23dd826c2 (patch)
tree2d39390e5a9289101ba6910992084f09647ccfeb /core/xmlhandlers.lua
parentf1cc4eb60fc94093602025044af230f10634efe4 (diff)
downloadprosody-6db3d039b3d8d55c9e03ebdc776cf1a23dd826c2.tar.gz
prosody-6db3d039b3d8d55c9e03ebdc776cf1a23dd826c2.zip
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 <stream:features> out of xmlhandlers.lua o_O ))
Diffstat (limited to 'core/xmlhandlers.lua')
-rw-r--r--core/xmlhandlers.lua20
1 files changed, 14 insertions, 6 deletions
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("<?xml version='1.0'?>");
- send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s'>", session.streamid, session.host));
- --send("<stream:features>");
- --send("<mechanism>PLAIN</mechanism>");
+ send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s' version='1.0'>", session.streamid, session.host));
+ send("<stream:features>");
+ if not session.username then
+ send("<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>");
+ send("<mechanism>PLAIN</mechanism>");
+ send("</mechanisms>");
+ else
+ send("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required/></bind>");
+ end
--send [[<register xmlns="http://jabber.org/features/iq-register"/> ]]
- --send("</stream:features>");
+ send("</stream:features>");
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;