net.server_epoll: Prevent traceback when checking TLS after connection gone
authorKim Alvefur <zash@zash.se>
Sun, 21 Jan 2024 22:59:50 +0100
changeset 13426 3c80124452ed
parent 13425 92301fa7a673
child 13427 3c219effe707
net.server_epoll: Prevent traceback when checking TLS after connection gone Unclear why this would be done, but an error is not great.
net/server_epoll.lua
--- a/net/server_epoll.lua	Tue Feb 20 17:31:17 2024 +0000
+++ b/net/server_epoll.lua	Sun Jan 21 22:59:50 2024 +0100
@@ -630,30 +630,35 @@
 
 function interface:ssl_info()
 	local sock = self.conn;
+	if not sock then return nil, "not-connected" end
 	if not sock.info then return nil, "not-implemented"; end
 	return sock:info();
 end
 
 function interface:ssl_peercertificate()
 	local sock = self.conn;
+	if not sock then return nil, "not-connected" end
 	if not sock.getpeercertificate then return nil, "not-implemented"; end
 	return sock:getpeercertificate();
 end
 
 function interface:ssl_peerverification()
 	local sock = self.conn;
+	if not sock then return nil, "not-connected" end
 	if not sock.getpeerverification then return nil, { { "Chain verification not supported" } }; end
 	return sock:getpeerverification();
 end
 
 function interface:ssl_peerfinished()
 	local sock = self.conn;
+	if not sock then return nil, "not-connected" end
 	if not sock.getpeerfinished then return nil, "not-implemented"; end
 	return sock:getpeerfinished();
 end
 
 function interface:ssl_exportkeyingmaterial(label, len, context)
 	local sock = self.conn;
+	if not sock then return nil, "not-connected" end
 	if sock.exportkeyingmaterial then
 		return sock:exportkeyingmaterial(label, len, context);
 	end