Changeset

6709:b6eff3ba13de

mod_tls: Build <starttls/> as a stanza instead of with string concatenation
author Kim Alvefur <zash@zash.se>
date Mon, 18 May 2015 21:43:24 +0200
parents 6708:d2beb98ece29
children 6710:d062314446f6
files plugins/mod_tls.lua
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_tls.lua	Mon May 18 21:32:05 2015 +0200
+++ b/plugins/mod_tls.lua	Mon May 18 21:43:24 2015 +0200
@@ -21,6 +21,7 @@
 
 local xmlns_starttls = 'urn:ietf:params:xml:ns:xmpp-tls';
 local starttls_attr = { xmlns = xmlns_starttls };
+local starttls_initiate= st.stanza("starttls", starttls_attr);
 local starttls_proceed = st.stanza("proceed", starttls_attr);
 local starttls_failure = st.stanza("failure", starttls_attr);
 local c2s_feature = st.stanza("starttls", starttls_attr);
@@ -116,7 +117,7 @@
 	module:log("debug", "Received features element");
 	if can_do_tls(session) and stanza:get_child("starttls", xmlns_starttls) then
 		module:log("debug", "%s is offering TLS, taking up the offer...", session.to_host);
-		session.sends2s("<starttls xmlns='"..xmlns_starttls.."'/>");
+		session.sends2s(starttls_initiate);
 		return true;
 	end
 end, 500);