mod_admin_telnet: Avoid indexing missing socket (thanks tmolitor)
authorKim Alvefur <zash@zash.se>
Wed, 05 Feb 2020 23:29:39 +0100
changeset 10648 6c4ab1b87588
parent 10647 417eadd0f567
child 10649 067ada779ea5
mod_admin_telnet: Avoid indexing missing socket (thanks tmolitor) if `sock` was nil it would still proceed with SNI and ALPN checks
plugins/mod_admin_telnet.lua
--- 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