mod_admin_telnet: Avoid indexing missing socket (thanks tmolitor)
if `sock` was nil it would still proceed with SNI and ALPN checks
--- a/plugins/mod_admin_telnet.lua Wed Feb 05 17:56:44 2020 +0000
+++ b/plugins/mod_admin_telnet.lua Wed Feb 05 23:29:39 2020 +0100
@@ -580,21 +580,21 @@
if sock and sock.info then
local info = sock:info();
line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher);
+ if sock.getsniname then
+ local name = sock:getsniname();
+ if name then
+ line[#line+1] = ("(SNI:%q)"):format(name);
+ end
+ end
+ if sock.getalpn then
+ local proto = sock:getalpn();
+ if proto then
+ line[#line+1] = ("(ALPN:%q)"):format(proto);
+ end
+ end
else
line[#line+1] = "(cipher info unavailable)";
end
- if sock.getsniname then
- local name = sock:getsniname();
- if name then
- line[#line+1] = ("(SNI:%q)"):format(name);
- end
- end
- if sock.getalpn then
- local proto = sock:getalpn();
- if proto then
- line[#line+1] = ("(ALPN:%q)"):format(proto);
- end
- end
else
line[#line+1] = "(insecure)";
end