21 |
21 |
22 local st = require "util.stanza"; |
22 local st = require "util.stanza"; |
23 local sm_bind_resource = require "core.sessionmanager".bind_resource; |
23 local sm_bind_resource = require "core.sessionmanager".bind_resource; |
24 local jid |
24 local jid |
25 local base64 = require "util.encodings".base64; |
25 local base64 = require "util.encodings".base64; |
|
26 |
|
27 local gettime = require "socket".gettime; |
26 |
28 |
27 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; |
29 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; |
28 local t_concat, t_insert = table.concat, table.insert; |
30 local t_concat, t_insert = table.concat, table.insert; |
29 local tostring = tostring; |
31 local tostring = tostring; |
30 local jid_split = require "util.jid".split |
32 local jid_split = require "util.jid".split |
62 session.sasl_handler = nil; |
64 session.sasl_handler = nil; |
63 session:reset_stream(); |
65 session:reset_stream(); |
64 end |
66 end |
65 end |
67 end |
66 |
68 |
67 local function password_callback(node, host, mechanism, raw_host) |
69 local function password_callback(node, host, mechanism) |
68 local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords |
70 local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords |
69 local func = function(x) return x; end; |
71 local func = function(x) return x; end; |
70 if password then |
72 if password then |
71 if mechanism == "PLAIN" then |
73 if mechanism == "PLAIN" then |
72 return func, password; |
74 return func, password; |
73 elseif mechanism == "DIGEST-MD5" then |
75 elseif mechanism == "DIGEST-MD5" then |
74 return func, md5(node..":"..raw_host..":"..password); |
76 return func, md5(node..":"..host..":"..password); |
75 end |
77 end |
76 end |
78 end |
77 return func, nil; |
79 return func, nil; |
78 end |
80 end |
79 |
81 |
140 else |
142 else |
141 session.send(st.reply(stanza) |
143 session.send(st.reply(stanza) |
142 :tag("bind", { xmlns = xmlns_bind}) |
144 :tag("bind", { xmlns = xmlns_bind}) |
143 :tag("jid"):text(session.full_jid)); |
145 :tag("jid"):text(session.full_jid)); |
144 end |
146 end |
|
147 |
|
148 session.log("******", "Connection took "..tostring(session.conntimetotal).." seconds"); |
145 end); |
149 end); |
146 |
150 |
147 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session", |
151 module:add_iq_handler("c2s", "urn:ietf:params:xml:ns:xmpp-session", |
148 function (session, stanza) |
152 function (session, stanza) |
149 log("debug", "Client tried to bind to a resource"); |
153 log("debug", "Client tried to bind to a resource"); |