Software /
code /
prosody
Comparison
plugins/mod_tls.lua @ 69:5b664c8fef86
forgot to commit mod_tls, oops :)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 07 Oct 2008 23:13:30 +0100 |
child | 99:ba08b8a4eeef |
comparison
equal
deleted
inserted
replaced
68:ceb7a55676a4 | 69:5b664c8fef86 |
---|---|
1 | |
2 local st = require "util.stanza"; | |
3 local send = require "core.sessionmanager".send_to_session; | |
4 local sm_bind_resource = require "core.sessionmanager".bind_resource; | |
5 | |
6 local usermanager_validate_credentials = require "core.usermanager".validate_credentials; | |
7 local t_concat, t_insert = table.concat, table.insert; | |
8 local tostring = tostring; | |
9 | |
10 local log = require "util.logger".init("mod_starttls"); | |
11 | |
12 local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls'; | |
13 | |
14 local new_connhandler = require "net.connhandlers".new; | |
15 | |
16 add_handler("c2s_unauthed", "starttls", xmlns_starttls, | |
17 function (session, stanza) | |
18 if session.conn.starttls then | |
19 print("Wants to do TLS..."); | |
20 send(session, st.stanza("proceed", { xmlns = xmlns_starttls })); | |
21 session.connhandler = new_connhandler("xmpp-client", session); | |
22 session.notopen = true; | |
23 if session.conn.starttls() then | |
24 print("Done"); | |
25 else | |
26 print("Failed"); | |
27 end | |
28 | |
29 end | |
30 end); | |
31 | |
32 add_event_hook("stream-features", | |
33 function (session, features) | |
34 if session.conn.starttls then | |
35 t_insert(features, "<starttls xmlns='"..xmlns_starttls.."'/>"); | |
36 end | |
37 end); |