aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2011-10-26 02:03:33 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2011-10-26 02:03:33 +0200
commit8d5ffd8d1a65a773ac7b67627b8ce116fbe522d2 (patch)
tree6b57c09d6b863c3b7444ad1bedbb2f11532ace7b
parent9c0e66e2d3b6bf83df25fa31d5e6ef9707b9d805 (diff)
downloadprosody-8d5ffd8d1a65a773ac7b67627b8ce116fbe522d2.tar.gz
prosody-8d5ffd8d1a65a773ac7b67627b8ce116fbe522d2.zip
s2smanager, net.dns: Fix handling for NXNAME and SRV target of "."
-rw-r--r--core/s2smanager.lua37
-rw-r--r--net/dns.lua1
2 files changed, 32 insertions, 6 deletions
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index c7eb9578..b930ceab 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -246,6 +246,11 @@ function attempt_connection(host_session, err)
for _, record in ipairs(answer) do
t_insert(srv_hosts, record.srv);
end
+ if #srv_hosts == 1 and srv_hosts[1].target == "." then
+ log("debug", to_host.." does not provide a XMPP service");
+ destroy_session(host_session, err); -- Nothing to see here
+ return;
+ end
t_sort(srv_hosts, compare_srv_priorities);
local srv_choice = srv_hosts[1];
@@ -347,9 +352,19 @@ function try_connect(host_session, connect_host, connect_port, err)
end
if has_other then
- rfc3484_dest(host_session.ip_hosts, sources);
- host_session.ip_choice = 0;
- try_next_ip(host_session, connect_port);
+ if #IPs > 0 then
+ rfc3484_dest(host_session.ip_hosts, sources);
+ host_session.ip_choice = 0;
+ try_next_ip(host_session, connect_port);
+ else
+ log("debug", "DNS lookup failed to get a response for %s", connect_host);
+ host_session.ip_hosts = nil;
+ if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can
+ log("debug", "No other records to try for %s - destroying", host_session.to_host);
+ err = err and (": "..err) or "";
+ destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't
+ end
+ end
else
has_other = true;
end
@@ -366,9 +381,19 @@ function try_connect(host_session, connect_host, connect_port, err)
end
if has_other then
- rfc3484_dest(host_session.ip_hosts, sources);
- host_session.ip_choice = 0;
- try_next_ip(host_session, connect_port);
+ if #IPs > 0 then
+ rfc3484_dest(host_session.ip_hosts, sources);
+ host_session.ip_choice = 0;
+ try_next_ip(host_session, connect_port);
+ else
+ log("debug", "DNS lookup failed to get a response for %s", connect_host);
+ host_session.ip_hosts = nil;
+ if not attempt_connection(host_session, "name resolution failed") then -- Retry if we can
+ log("debug", "No other records to try for %s - destroying", host_session.to_host);
+ err = err and (": "..err) or "";
+ destroy_session(host_session, "DNS resolution failed"..err); -- End of the line, we can't
+ end
+ end
else
has_other = true;
end
diff --git a/net/dns.lua b/net/dns.lua
index 8f428476..5b32a56c 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -358,6 +358,7 @@ function resolver:name() -- - - - - - - - - - - - - - - - - - - - - - name
local remember, pointers = nil, 0;
local len = self:byte();
local n = {};
+ if len == 0 then return "." end -- Root label
while len > 0 do
if len >= 0xc0 then -- name is "compressed"
pointers = pointers + 1;