Comparison

net/adns.lua @ 6507:84ca02c6a47e

net.adns: Log peername recorded from wrapped setpeername instead of calling sock:getpeername, it exists and throws an error on unconnected sockets (thanks wirehack7)
author Kim Alvefur <zash@zash.se>
date Thu, 30 Oct 2014 12:08:05 +0100
parent 6506:f869eec511c8
child 6510:8273236a995f
comparison
equal deleted inserted replaced
6506:f869eec511c8 6507:84ca02c6a47e
78 handler.setsockname = function (_, ...) return sock:setsockname(...); end 78 handler.setsockname = function (_, ...) return sock:setsockname(...); end
79 handler.setpeername = function (_, ...) peername = (...); local ret, err = sock:setpeername(...); _:set_send(dummy_send); return ret, err; end 79 handler.setpeername = function (_, ...) peername = (...); local ret, err = sock:setpeername(...); _:set_send(dummy_send); return ret, err; end
80 handler.connect = function (_, ...) return sock:connect(...) end 80 handler.connect = function (_, ...) return sock:connect(...) end
81 --handler.send = function (_, data) _:write(data); return _.sendbuffer and _.sendbuffer(); end 81 --handler.send = function (_, data) _:write(data); return _.sendbuffer and _.sendbuffer(); end
82 handler.send = function (_, data) 82 handler.send = function (_, data)
83 local getpeername = sock.getpeername; 83 log("debug", "Sending DNS query to %s", peername);
84 log("debug", "Sending DNS query to %s", (getpeername and getpeername(sock)) or "<unconnected>");
85 return sock:send(data); 84 return sock:send(data);
86 end 85 end
87 return handler; 86 return handler;
88 end 87 end
89 88