# HG changeset patch # User Florian Zeitz # Date 1319587413 -7200 # Node ID c25dee24623f9dcde61d4dac5e4ec66c82f79d5c # Parent 971a66627f7a08526064c4e577833871dbdcb502 s2smanager, net.dns: Fix handling for NXNAME and SRV target of "." diff -r 971a66627f7a -r c25dee24623f core/s2smanager.lua --- a/core/s2smanager.lua Sat Oct 22 18:29:23 2011 +0200 +++ b/core/s2smanager.lua Wed Oct 26 02:03:33 2011 +0200 @@ -246,6 +246,11 @@ 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 @@ 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 @@ 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 -r 971a66627f7a -r c25dee24623f net/dns.lua --- a/net/dns.lua Sat Oct 22 18:29:23 2011 +0200 +++ b/net/dns.lua Wed Oct 26 02:03:33 2011 +0200 @@ -358,6 +358,7 @@ 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;