Software / code / verse
Comparison
plugins/tls.lua @ 197:7e98cf2c1d8d
plugins.*: Use verse.stanza() & co instead of require util.stanza
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 17 Mar 2011 18:33:52 +0100 |
| parent | 67:8154b72591d5 |
| child | 250:a5ac643a7fd6 |
comparison
equal
deleted
inserted
replaced
| 196:eb9d69d3f0b5 | 197:7e98cf2c1d8d |
|---|---|
| 1 local st = require "util.stanza"; | |
| 2 local xmlns_tls = "urn:ietf:params:xml:ns:xmpp-tls"; | 1 local xmlns_tls = "urn:ietf:params:xml:ns:xmpp-tls"; |
| 3 | 2 |
| 4 function verse.plugins.tls(stream) | 3 function verse.plugins.tls(stream) |
| 5 local function handle_features(features_stanza) | 4 local function handle_features(features_stanza) |
| 6 if stream.authenticated then return; end | 5 if stream.authenticated then return; end |
| 7 if features_stanza:get_child("starttls", xmlns_tls) and stream.conn.starttls then | 6 if features_stanza:get_child("starttls", xmlns_tls) and stream.conn.starttls then |
| 8 stream:debug("Negotiating TLS..."); | 7 stream:debug("Negotiating TLS..."); |
| 9 stream:send(st.stanza("starttls", { xmlns = xmlns_tls })); | 8 stream:send(verse.stanza("starttls", { xmlns = xmlns_tls })); |
| 10 return true; | 9 return true; |
| 11 elseif not stream.conn.starttls and not stream.secure then | 10 elseif not stream.conn.starttls and not stream.secure then |
| 12 stream:warn("SSL libary (LuaSec) not loaded, so TLS not available"); | 11 stream:warn("SSL libary (LuaSec) not loaded, so TLS not available"); |
| 13 elseif not stream.secure then | 12 elseif not stream.secure then |
| 14 stream:debug("Server doesn't offer TLS :("); | 13 stream:debug("Server doesn't offer TLS :("); |