verse.plugins.tls: Fail gracefully when LuaSec not loaded

Tue, 11 May 2010 23:06:52 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 11 May 2010 23:06:52 +0100
changeset 63
311e61176159
parent 62
d4b6f9e33c6e
child 64
a28540d4117a

verse.plugins.tls: Fail gracefully when LuaSec not loaded

plugins/tls.lua file | annotate | diff | comparison | revisions
--- a/plugins/tls.lua	Tue May 11 23:05:26 2010 +0100
+++ b/plugins/tls.lua	Tue May 11 23:06:52 2010 +0100
@@ -4,10 +4,12 @@
 function verse.plugins.tls(stream)
 	local function handle_features(features_stanza)
 		if stream.authenticated then return; end
-		if features_stanza:get_child("starttls", xmlns_tls) then
+		if features_stanza:get_child("starttls", xmlns_tls) and stream.conn.starttls then
 			stream:debug("Negotiating TLS...");
 			stream:send(st.stanza("starttls", { xmlns = xmlns_tls }));
 			return true;
+		elseif not stream.conn.starttls then
+			stream:warn("SSL libary (LuaSec) not loaded, so TLS not available");
 		else
 			stream:debug("Server doesn't offer TLS :(");
 		end

mercurial