Software /
code /
prosody
Annotate
plugins/mod_tls.lua @ 357:17bcecb06420
Use a stanza for c2s stream features instead of an array of strings. Removes a FIXME.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 20 Nov 2008 01:33:25 +0000 |
parent | 316:13e2bd256a20 |
child | 438:193f9dd64f17 |
rev | line source |
---|---|
69
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 local st = require "util.stanza"; |
99
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
3 |
303
89e8f53b870e
Unused variables in mod_tls
Waqas Hussain <waqas20@gmail.com>
parents:
120
diff
changeset
|
4 --local sessions = sessions; |
89e8f53b870e
Unused variables in mod_tls
Waqas Hussain <waqas20@gmail.com>
parents:
120
diff
changeset
|
5 |
89e8f53b870e
Unused variables in mod_tls
Waqas Hussain <waqas20@gmail.com>
parents:
120
diff
changeset
|
6 local t_insert = table.insert; |
69
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local log = require "util.logger".init("mod_starttls"); |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 local xmlns_starttls ='urn:ietf:params:xml:ns:xmpp-tls'; |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 add_handler("c2s_unauthed", "starttls", xmlns_starttls, |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 function (session, stanza) |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 if session.conn.starttls then |
316
13e2bd256a20
Fixed mod_tls to use session.send for sending stanzas
Waqas Hussain <waqas20@gmail.com>
parents:
303
diff
changeset
|
15 session.send(st.stanza("proceed", { xmlns = xmlns_starttls })); |
99
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
16 -- FIXME: I'm commenting the below, not sure why it was necessary |
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
17 -- sessions[session.conn] = nil; |
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
18 session:reset_stream(); |
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
19 session.conn.starttls(); |
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
20 session.log("info", "TLS negotiation started..."); |
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
21 else |
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
22 -- FIXME: What reply? |
ba08b8a4eeef
Abstract connections with "connection listeners"
Matthew Wild <mwild1@gmail.com>
parents:
69
diff
changeset
|
23 session.log("warn", "Attempt to start TLS, but TLS is not available on this connection"); |
69
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 end |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 end); |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 |
357
17bcecb06420
Use a stanza for c2s stream features instead of an array of strings. Removes a FIXME.
Matthew Wild <mwild1@gmail.com>
parents:
316
diff
changeset
|
27 local starttls_attr = { xmlns = xmlns_starttls }; |
69
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 add_event_hook("stream-features", |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 function (session, features) |
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 if session.conn.starttls then |
357
17bcecb06420
Use a stanza for c2s stream features instead of an array of strings. Removes a FIXME.
Matthew Wild <mwild1@gmail.com>
parents:
316
diff
changeset
|
31 features:tag("starttls", starttls_attr):up(); |
69
5b664c8fef86
forgot to commit mod_tls, oops :)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 end |
120
ef964468f174
TLS/SASL no longer should include the connhandler module
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
33 end); |