aboutsummaryrefslogtreecommitdiffstats
path: root/net/adns.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-09-18 02:48:52 +0100
committerMatthew Wild <mwild1@gmail.com>2009-09-18 02:48:52 +0100
commit13c1162f2fbba04baa1bb01712fdab305ec5f1aa (patch)
tree3335bba4f98bba077b5bfabee088476ef17086e6 /net/adns.lua
parent0040bc6b93bffd49c98789ca1fd8c4d90b4b8051 (diff)
parent97c697c83e00be46bb38e8b5e972f36aa900582e (diff)
downloadprosody-13c1162f2fbba04baa1bb01712fdab305ec5f1aa.tar.gz
prosody-13c1162f2fbba04baa1bb01712fdab305ec5f1aa.zip
Merge with 0.5
Diffstat (limited to 'net/adns.lua')
-rw-r--r--net/adns.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/net/adns.lua b/net/adns.lua
index 7ee54da3..9438bf45 100644
--- a/net/adns.lua
+++ b/net/adns.lua
@@ -11,6 +11,7 @@ local dns = require "net.dns";
local log = require "util.logger".init("adns");
+local t_insert, t_remove = table.insert, table.remove;
local coroutine, tostring, pcall = coroutine, tostring, pcall;
module "adns"
@@ -41,13 +42,20 @@ function cancel(handle, call_handler)
end
end
-function new_async_socket(sock)
- local newconn = {};
+function new_async_socket(sock, resolver)
+ local newconn, peername = {}, "<unknown>";
local listener = {};
function listener.incoming(conn, data)
dns.feed(sock, data);
end
- function listener.disconnect()
+ function listener.disconnect(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
+ 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
@@ -58,7 +66,7 @@ function new_async_socket(sock)
end
newconn.handler.settimeout = function () end
newconn.handler.setsockname = function (_, ...) return sock:setsockname(...); end
- newconn.handler.setpeername = function (_, ...) local ret = sock:setpeername(...); _.setsend(sock.send); return ret; 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;