Mercurial > prosody-hg
comparison plugins/mod_tls.lua @ 99:ba08b8a4eeef
Abstract connections with "connection listeners"
- Added connlistener for xmppclient
- SASL/TLS now use a new session:reset_stream() method
- main.lua on its way to being a bit neater
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 22 Oct 2008 17:36:21 +0100 |
| parents | 5b664c8fef86 |
| children | ef964468f174 |
comparison
equal
deleted
inserted
replaced
| 98:3a2d327c4856 | 99:ba08b8a4eeef |
|---|---|
| 1 | 1 |
| 2 local st = require "util.stanza"; | 2 local st = require "util.stanza"; |
| 3 local send = require "core.sessionmanager".send_to_session; | 3 local send = require "core.sessionmanager".send_to_session; |
| 4 local sm_bind_resource = require "core.sessionmanager".bind_resource; | 4 local sm_bind_resource = require "core.sessionmanager".bind_resource; |
| 5 | |
| 6 local sessions = sessions; | |
| 5 | 7 |
| 6 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; | 8 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; |
| 7 local t_concat, t_insert = table.concat, table.insert; | 9 local t_concat, t_insert = table.concat, table.insert; |
| 8 local tostring = tostring; | 10 local tostring = tostring; |
| 9 | 11 |
| 14 local new_connhandler = require "net.connhandlers".new; | 16 local new_connhandler = require "net.connhandlers".new; |
| 15 | 17 |
| 16 add_handler("c2s_unauthed", "starttls", xmlns_starttls, | 18 add_handler("c2s_unauthed", "starttls", xmlns_starttls, |
| 17 function (session, stanza) | 19 function (session, stanza) |
| 18 if session.conn.starttls then | 20 if session.conn.starttls then |
| 19 print("Wants to do TLS..."); | |
| 20 send(session, st.stanza("proceed", { xmlns = xmlns_starttls })); | 21 send(session, st.stanza("proceed", { xmlns = xmlns_starttls })); |
| 21 session.connhandler = new_connhandler("xmpp-client", session); | 22 -- FIXME: I'm commenting the below, not sure why it was necessary |
| 22 session.notopen = true; | 23 -- sessions[session.conn] = nil; |
| 23 if session.conn.starttls() then | 24 session:reset_stream(); |
| 24 print("Done"); | 25 session.conn.starttls(); |
| 25 else | 26 session.log("info", "TLS negotiation started..."); |
| 26 print("Failed"); | 27 else |
| 27 end | 28 -- FIXME: What reply? |
| 28 | 29 session.log("warn", "Attempt to start TLS, but TLS is not available on this connection"); |
| 29 end | 30 end |
| 30 end); | 31 end); |
| 31 | 32 |
| 32 add_event_hook("stream-features", | 33 add_event_hook("stream-features", |
| 33 function (session, features) | 34 function (session, features) |
