diff options
author | Tobias Markmann <tm@ayena.de> | 2009-11-29 21:33:37 +0100 |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2009-11-29 21:33:37 +0100 |
commit | f91009f78a46ad74aa62ff487fa297c06a1ae6a3 (patch) | |
tree | 8ef6302fc66fdc48b4f34f58c3bea877d7ee6bee /net/adns.lua | |
parent | 8db68f17623ad29b25c6b5d757a2fb0b3d3005c6 (diff) | |
parent | 8fcbba4b0fccb299121083d97cab065e51fba9d1 (diff) | |
download | prosody-f91009f78a46ad74aa62ff487fa297c06a1ae6a3.tar.gz prosody-f91009f78a46ad74aa62ff487fa297c06a1ae6a3.zip |
Merge with tip.
Diffstat (limited to 'net/adns.lua')
-rw-r--r-- | net/adns.lua | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/net/adns.lua b/net/adns.lua index b0c9a625..d6beffbb 100644 --- a/net/adns.lua +++ b/net/adns.lua @@ -43,33 +43,32 @@ function cancel(handle, call_handler) end function new_async_socket(sock, resolver) - local newconn, peername = {}, "<unknown>"; + local peername = "<unknown>"; local listener = {}; - function listener.incoming(conn, data) - dns.feed(sock, data); + local handler = {}; + function listener.onincoming(conn, data) + dns.feed(handler, data); end - function listener.disconnect(conn, err) + function listener.ondisconnect(conn, err) log("warn", "DNS socket for %s disconnected: %s", peername, err); local servers = resolver.server; - if resolver.socketset[newconn.handler] == resolver.best_server and resolver.best_server == #servers then + if resolver.socketset[conn] == resolver.best_server and resolver.best_server == #servers then log("error", "Exhausted all %d configured DNS servers, next lookup will try %s again", #servers, servers[1]); end resolver:servfail(conn); -- Let the magic commence end - newconn.handler, newconn._socket = server.wrapclient(sock, "dns", 53, listener); - if not newconn.handler then + handler = server.wrapclient(sock, "dns", 53, listener); + if not handler then log("warn", "handler is nil"); end - if not newconn._socket then - log("warn", "socket is nil"); - end - newconn.handler.settimeout = function () end - newconn.handler.setsockname = function (_, ...) return sock:setsockname(...); end - newconn.handler.setpeername = function (_, ...) peername = (...); local ret = sock:setpeername(...); _.setsend(sock.send); return ret; end - newconn.handler.connect = function (_, ...) return sock:connect(...) end - newconn.handler.send = function (_, data) _.write(data); return _.sendbuffer(); end - return newconn.handler; + + handler.settimeout = function () end + handler.setsockname = function (_, ...) return sock:setsockname(...); end + handler.setpeername = function (_, ...) peername = (...); local ret = sock:setpeername(...); _:set_send(sock.send); return ret; end + handler.connect = function (_, ...) return sock:connect(...) end + handler.send = function (_, data) _:write(data); return _.sendbuffer and _.sendbuffer(); end + return handler; end dns:socket_wrapper_set(new_async_socket); |