aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-11-19 14:44:41 +0100
committerKim Alvefur <zash@zash.se>2014-11-19 14:44:41 +0100
commit2ab66e784aec225601e5d42c49bbdea22916fcb7 (patch)
treed66ba8d282e756bff7dfdd199d113e779117b40e /plugins
parentb47d9adc40cb05bd1a0a99fa62daca3db926666c (diff)
downloadprosody-2ab66e784aec225601e5d42c49bbdea22916fcb7.tar.gz
prosody-2ab66e784aec225601e5d42c49bbdea22916fcb7.zip
mod_saslauth: Break out tls-unique channel binding callback so it is instantiated once
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_saslauth.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/plugins/mod_saslauth.lua b/plugins/mod_saslauth.lua
index 5064a21a..6cb3e3a7 100644
--- a/plugins/mod_saslauth.lua
+++ b/plugins/mod_saslauth.lua
@@ -214,6 +214,10 @@ module:hook("stanza/urn:ietf:params:xml:ns:xmpp-sasl:abort", function(event)
return true;
end);
+local function tls_unique(self)
+ return self.userdata:getpeerfinished();
+end
+
local mechanisms_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-sasl' };
local bind_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-bind' };
local xmpp_session_attr = { xmlns='urn:ietf:params:xml:ns:xmpp-session' };
@@ -228,11 +232,12 @@ module:hook("stream-features", function(event)
if origin.encrypted then
-- check wether LuaSec has the nifty binding to the function needed for tls-unique
-- FIXME: would be nice to have this check only once and not for every socket
- if origin.conn:socket().getpeerfinished and sasl_handler.add_cb_handler then
- sasl_handler:add_cb_handler("tls-unique", function(self)
- return self.userdata:getpeerfinished();
- end);
- sasl_handler["userdata"] = origin.conn:socket();
+ if sasl_handler.add_cb_handler then
+ local socket = origin.conn:socket();
+ if socket.getpeerfinished then
+ sasl_handler:add_cb_handler("tls-unique", tls_unique);
+ end
+ sasl_handler["userdata"] = socket;
end
end
local mechanisms = st.stanza("mechanisms", mechanisms_attr);