Software /
code /
prosody
Diff
plugins/mod_c2s.lua @ 11622:a62146353528
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 21 Jun 2021 13:36:05 +0200 |
parent | 11619:d629135450ec |
child | 11742:9c450185bac1 |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Sun Jun 20 18:46:52 2021 +0200 +++ b/plugins/mod_c2s.lua Mon Jun 21 13:36:05 2021 +0200 @@ -117,8 +117,8 @@ 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 @@ -- 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)