From bf5ee4b51368d8ea4746958236a1d2449b3ae57d Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 17 Jul 2020 05:30:44 +1000 Subject: Use the new DNSRR field from mirror_list.txt to do the correct thing. --- apt-panopticon.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'apt-panopticon.lua') diff --git a/apt-panopticon.lua b/apt-panopticon.lua index f154086..b91d47c 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -195,6 +195,16 @@ gatherIPs = function (host) end until nil == IPs end + + -- If this is the DNS-RR domain name, gather the IPs for the mirrors that mirror_list.txt says should be in it. + if host == APT.options.roundRobin.value then + for k, m in pairs(APT.mirrors) do + if "yes" == m.DNSRR then + gatherIPs(m.FQDN) + IP[host][m.FQDN] = IP[m.FQDN] + end + end + end return IP[host] end @@ -620,7 +630,7 @@ local getMirrors = function () W("Mirror " .. host .. " is not active - " .. d, "", "", host) active = false m[t] = d --- TODO - Should do some input validation on BaseURL, and everything else. +-- TODO - Should do some more input validation on everything. elseif "Rate" == t then local time, unit = d:match('(%d+) *(%a+)') time = tonumber(time) @@ -643,7 +653,7 @@ local getMirrors = function () end end if APT.testing("DNSRR") then - mirrors[APT.options.roundRobin.value] = { ["Protocols"] = { ["http"] = true; }; ['Updated'] = 300; + mirrors[APT.options.roundRobin.value] = { ["Protocols"] = { ["http"] = true; }; ['Updated'] = 300; ['DNSRR'] = false; ["FQDN"] = APT.options.roundRobin.value; ["Active"] = 'yes'; ["BaseURL"] = APT.options.roundRobin.value; } end local file, e = io.open("results/mirrors.lua", "w+") @@ -1042,11 +1052,11 @@ if 0 < #arg then if not APT.logOpen(pu.host, arg[2], arg[3]) then return end I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", ")) + APT.mirrors = loadfile("results/mirrors.lua")() + APT.results = APT.padResults(APT.results) if APT.origin or APT.redir then APT.results["IPs"] = gatherIPs(pu.host) end if nil ~= arg[2] then I("   Using IP " .. arg[2]); ip = arg[2] end if nil ~= arg[3] then I("   Using file " .. arg[3]); end - APT.mirrors = loadfile("results/mirrors.lua")() - APT.results = APT.padResults(APT.results) if APT.origin then local file = arg[3] -- cgit v1.1