Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
11621:e48cd6503b6e | 11622:a62146353528 |
---|---|
115 if session.secure == false then | 115 if session.secure == false then |
116 session.secure = true; | 116 session.secure = true; |
117 session.encrypted = true; | 117 session.encrypted = true; |
118 | 118 |
119 local sock = session.conn:socket(); | 119 local sock = session.conn:socket(); |
120 if sock.info then | 120 local info = sock.info and sock:info(); |
121 local info = sock:info(); | 121 if type(info) == "table" then |
122 (session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher); | 122 (session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher); |
123 session.compressed = info.compression; | 123 session.compressed = info.compression; |
124 m_tls_params:with_labels(info.protocol, info.cipher):add(1) | 124 m_tls_params:with_labels(info.protocol, info.cipher):add(1) |
125 else | 125 else |
126 (session.log or log)("info", "Stream encrypted"); | 126 (session.log or log)("info", "Stream encrypted"); |
292 session.secure = true; | 292 session.secure = true; |
293 session.encrypted = true; | 293 session.encrypted = true; |
294 | 294 |
295 -- Check if TLS compression is used | 295 -- Check if TLS compression is used |
296 local sock = conn:socket(); | 296 local sock = conn:socket(); |
297 if sock.info then | 297 local info = sock.info and sock:info(); |
298 local info = sock:info(); | 298 if type(info) == "table" then |
299 (session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher); | 299 (session.log or log)("info", "Stream encrypted (%s with %s)", info.protocol, info.cipher); |
300 session.compressed = info.compression; | 300 session.compressed = info.compression; |
301 m_tls_params:with_labels(info.protocol, info.cipher):add(1) | 301 m_tls_params:with_labels(info.protocol, info.cipher):add(1) |
302 else | 302 else |
303 (session.log or log)("info", "Stream encrypted"); | 303 (session.log or log)("info", "Stream encrypted"); |