From 0d62fa9d6938e623a693160f2a0fc32dda1e816d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 18 Aug 2016 15:57:22 +0200 Subject: net.server_epoll: Improve string representation of connections --- net/server_epoll.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'net/server_epoll.lua') diff --git a/net/server_epoll.lua b/net/server_epoll.lua index d661d53a..f4ec54f6 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -114,14 +114,12 @@ local interface = {}; 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) -- cgit v1.2.3