Changeset

7585:b64218c816de

net.server_epoll: Improve string representation of connections
author Kim Alvefur <zash@zash.se>
date Thu, 18 Aug 2016 15:57:22 +0200
parents 7584:98ee3ed105cf
children 7586:846fdbbc62ba
files net/server_epoll.lua
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/net/server_epoll.lua	Thu Aug 18 15:55:50 2016 +0200
+++ b/net/server_epoll.lua	Thu Aug 18 15:57:22 2016 +0200
@@ -114,14 +114,12 @@
 local interface_mt = { __index = interface };
 
 function interface_mt:__tostring()
-	if self.peername then
-		if self.conn then
-			return ("%d %s [%s]:%d"):format(self:getfd(), tostring(self.conn), self.peer[1], self.peer[2]);
-		else
-			return ("%d [%s]:%d"):format(self:getfd(), self.peername, self.peerport);
-		end
+	if self.sockname and self.peername then
+		return ("FD %d (%s, %d, %s, %d)"):format(self:getfd(), self.peername, self.peerport, self.sockname, self.sockport);
+	elseif self.sockname or self.peername then
+		return ("FD %d (%s, %d)"):format(self:getfd(), self.sockname or self.peername, self.sockport or self.peerport);
 	end
-	return tostring(self:getfd());
+	return ("%s FD %d"):format(tostring(self.conn), self:getfd());
 end
 
 function interface:setlistener(listeners)