aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-06-21 13:36:05 +0200
committerKim Alvefur <zash@zash.se>2021-06-21 13:36:05 +0200
commit814a3a3482fb49f620f24f02b88be55136f8733b (patch)
tree290c0b28a01b84cf2dfc2fa7d99ec18bdad5293c /plugins
parentb03eba05c8ac1682e6bde273e6e5b5ef929f6669 (diff)
downloadprosody-814a3a3482fb49f620f24f02b88be55136f8733b.tar.gz
prosody-814a3a3482fb49f620f24f02b88be55136f8733b.zip
mod_c2s: Guard against LuaSec not returning TLS info (thanks Martin)
The :info() method has been observed to return nothing ... sometimes. Unclear what causes it. Perhaps the TLS connection was shut down or hasn't fully settled? The LuaSec code has code paths that return nothing or nil, error, so it is best to guard against it.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_c2s.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index 35ec201a..722932f6 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -117,8 +117,8 @@ function stream_callbacks._streamopened(session, attr)
session.encrypted = true;
local sock = session.conn:socket();
- if sock.info then
- local info = sock:info();
+ local info = sock.info and sock:info();
+ if type(info) == "table" then
(session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher);
session.compressed = info.compression;
m_tls_params:with_labels(info.protocol, info.cipher):add(1)
@@ -294,8 +294,8 @@ function listener.onconnect(conn)
-- Check if TLS compression is used
local sock = conn:socket();
- if sock.info then
- local info = sock:info();
+ local info = sock.info and sock:info();
+ if type(info) == "table" then
(session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher);
session.compressed = info.compression;
m_tls_params:with_labels(info.protocol, info.cipher):add(1)