aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-05-19 09:31:12 +0100
committerMatthew Wild <mwild1@gmail.com>2015-05-19 09:31:12 +0100
commit527e1e4bad2c8536f9c0b905e77d2679ca9ae9d5 (patch)
tree6225faf7bc524edf57e2118bc8633e07d2b28333 /plugins
parenta1eac64a926aeeec8babac775aa689dab4a598d3 (diff)
parentbb08d35ca72865e4ba3432a30a6df7e4d9e77c62 (diff)
downloadprosody-527e1e4bad2c8536f9c0b905e77d2679ca9ae9d5.tar.gz
prosody-527e1e4bad2c8536f9c0b905e77d2679ca9ae9d5.zip
Merge 0.10->trunk
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_auth_internal_hashed.lua21
-rw-r--r--plugins/mod_tls.lua5
2 files changed, 5 insertions, 21 deletions
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
diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua
index f9d2cee9..d1138e1c 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);
@@ -60,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;
@@ -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("<starttls xmlns='"..xmlns_starttls.."'/>");
+ session.sends2s(starttls_initiate);
return true;
end
end, 500);