Comparison

plugins/mod_c2s.lua @ 12480:7e9ebdc75ce4

net: isolate LuaSec-specifics For this, various accessor functions are now provided directly on the sockets, which reach down into the LuaSec implementation to obtain the information. While this may seem of little gain at first, it hides the implementation detail of the LuaSec+LuaSocket combination that the actual socket and the TLS layer are separate objects. The net gain here is that an alternative implementation does not have to emulate that specific implementation detail and "only" has to expose LuaSec-compatible data structures on the new functions.
author Jonas Schäfer <jonas@wielicki.name>
date Wed, 27 Apr 2022 17:44:14 +0200
parent 12311:bc30e1b9ad89
child 12662:07424992d7fc
comparison
equal deleted inserted replaced
12478:82270a6b1234 12480:7e9ebdc75ce4
115 -- since we now have a new stream header, session is secured 115 -- since we now have a new stream header, session is secured
116 if session.secure == false then 116 if session.secure == false then
117 session.secure = true; 117 session.secure = true;
118 session.encrypted = true; 118 session.encrypted = true;
119 119
120 local sock = session.conn:socket(); 120 local info = session.conn:ssl_info();
121 local info = sock.info and sock:info();
122 if type(info) == "table" then 121 if type(info) == "table" then
123 (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);
124 session.compressed = info.compression; 123 session.compressed = info.compression;
125 m_tls_params:with_labels(info.protocol, info.cipher):add(1) 124 m_tls_params:with_labels(info.protocol, info.cipher):add(1)
126 else 125 else
293 if conn:ssl() then 292 if conn:ssl() then
294 session.secure = true; 293 session.secure = true;
295 session.encrypted = true; 294 session.encrypted = true;
296 295
297 -- Check if TLS compression is used 296 -- Check if TLS compression is used
298 local sock = conn:socket(); 297 local info = conn:ssl_info();
299 local info = sock.info and sock:info();
300 if type(info) == "table" then 298 if type(info) == "table" then
301 (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);
302 session.compressed = info.compression; 300 session.compressed = info.compression;
303 m_tls_params:with_labels(info.protocol, info.cipher):add(1) 301 m_tls_params:with_labels(info.protocol, info.cipher):add(1)
304 else 302 else