From 938380caccccf565f11dbb8ff326788e5a2a857b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 May 2015 21:00:41 +0200 Subject: mod_auth_internal_hashed: Use util.hex --- plugins/mod_auth_internal_hashed.lua | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_auth_internal_hashed.lua b/plugins/mod_auth_internal_hashed.lua index 954392c9..78abe50d 100644 --- a/plugins/mod_auth_internal_hashed.lua +++ b/plugins/mod_auth_internal_hashed.lua @@ -13,31 +13,14 @@ local getAuthenticationDatabaseSHA1 = require "util.sasl.scram".getAuthenticatio local usermanager = require "core.usermanager"; local generate_uuid = require "util.uuid".generate; local new_sasl = require "util.sasl".new; +local hex = require"util.hex"; +local to_hex, from_hex = hex.to, hex.from; local log = module._log; local host = module.host; local accounts = module:open_store("accounts"); -local to_hex; -do - local function replace_byte_with_hex(byte) - return ("%02x"):format(byte:byte()); - end - function to_hex(binary_string) - return binary_string:gsub(".", replace_byte_with_hex); - end -end - -local from_hex; -do - local function replace_hex_with_byte(hex) - return string.char(tonumber(hex, 16)); - end - function from_hex(hex_string) - return hex_string:gsub("..", replace_hex_with_byte); - end -end -- Default; can be set per-user -- cgit v1.2.3 From 3f9b6834573752a09e06196792bcce7774fd6f1e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 May 2015 21:43:24 +0200 Subject: mod_tls: Build as a stanza instead of with string concatenation --- plugins/mod_tls.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index f9d2cee9..85fa172a 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -21,6 +21,7 @@ end 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:hook_stanza("http://etherx.jabber.org/streams", "features", function (ses 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(""); + session.sends2s(starttls_initiate); return true; end end, 500); -- cgit v1.2.3 From 72dde1c231c9d71c5ae5fe1d2d5fafc029e32c17 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 May 2015 21:48:58 +0200 Subject: mod_tls: Treat session.ssl_ctx being false as a signal that TLS is disabled --- plugins/mod_tls.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index 85fa172a..d1138e1c 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -61,7 +61,7 @@ do end local function can_do_tls(session) - if not session.conn.starttls then + if session.ssl_ctx == false or not session.conn.starttls then return false; elseif session.ssl_ctx then return true; -- cgit v1.2.3