Comparison

plugins/mod_s2s/s2sout.lib.lua @ 6631:45222bfb206f

net.dns, mod_s2s: Add chasing of CNAMEs to net.dns and remove it from mod_s2s
author Kim Alvefur <zash@zash.se>
date Fri, 24 Apr 2015 14:14:01 +0200
parent 6015:8fead005ee60
child 6632:855085439f7f
child 6680:ae34b12c4335
comparison
equal deleted inserted replaced
6601:debd9a7be528 6631:45222bfb206f
166 local have_other_result = not(has_ipv4) or not(has_ipv6) or false; 166 local have_other_result = not(has_ipv4) or not(has_ipv6) or false;
167 167
168 if has_ipv4 then 168 if has_ipv4 then
169 handle4 = adns.lookup(function (reply, err) 169 handle4 = adns.lookup(function (reply, err)
170 handle4 = nil; 170 handle4 = nil;
171
172 -- COMPAT: This is a compromise for all you CNAME-(ab)users :)
173 if not (reply and reply[#reply] and reply[#reply].a) then
174 local count = max_dns_depth;
175 reply = dns.peek(connect_host, "CNAME", "IN");
176 while count > 0 and reply and reply[#reply] and not reply[#reply].a and reply[#reply].cname do
177 log("debug", "Looking up %s (DNS depth is %d)", tostring(reply[#reply].cname), count);
178 reply = dns.peek(reply[#reply].cname, "A", "IN") or dns.peek(reply[#reply].cname, "CNAME", "IN");
179 count = count - 1;
180 end
181 end
182 -- end of CNAME resolving
183 171
184 if reply and reply[#reply] and reply[#reply].a then 172 if reply and reply[#reply] and reply[#reply].a then
185 for _, ip in ipairs(reply) do 173 for _, ip in ipairs(reply) do
186 log("debug", "DNS reply for %s gives us %s", connect_host, ip.a); 174 log("debug", "DNS reply for %s gives us %s", connect_host, ip.a);
187 IPs[#IPs+1] = new_ip(ip.a, "IPv4"); 175 IPs[#IPs+1] = new_ip(ip.a, "IPv4");