# HG changeset patch # User Kim Alvefur # Date 1624275365 -7200 # Node ID a62146353528594dd94ae8bfffe48a33e4a2d290 # Parent e48cd6503b6ef960468b24a0952cfaf57d6abb24 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. diff -r e48cd6503b6e -r a62146353528 plugins/mod_c2s.lua --- 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)