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-report-email-web.lua | 42 ++++++++++++++++++++----------------- apt-panopticon.lua | 18 ++++++++++++---- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua index b8b487e..a9852c1 100755 --- a/apt-panopticon-report-email-web.lua +++ b/apt-panopticon-report-email-web.lua @@ -346,28 +346,32 @@ local makeIPlist = function(hosts) if nil ~= hosts[k].IPs then for l, w in pairs(hosts[k].IPs) do if type(w) == "table" then - n[l] = {} - for i, u in pairs(w) do - if (APT.testing("IPv6") and ("AAAA" == u)) or ("A" == u) then - local inRR = "" - local lc = logCount(k, i) - if checkRR then - -- If there where errors, warnings, or timeouts, then it'll have that wrapped in font tags. - inRR = "" - if nil ~= lc:find("" - if nil ~= RRbfile then - local f, e = RRbfile:write(i, '\n') - if f == nil then C("writing DNS-RR_bad.txt file - " .. e) end +-- TODO - don't hard code deb.roundr.devuan.org. + -- Don't output the extra DNS-RR entries that are for admin reasons. + if ((APT.options.roundRobin.value == k) and ("deb.roundr.devuan.org" == l)) or (APT.options.roundRobin.value ~= k) then + n[l] = {} + for i, u in pairs(w) do + if (APT.testing("IPv6") and ("AAAA" == u)) or ("A" == u) then + local inRR = "" + local lc = logCount(k, i) + if checkRR then + -- If there where errors, warnings, or timeouts, then it'll have that wrapped in font tags. + inRR = "" + if nil ~= lc:find("" + if nil ~= RRbfile then + local f, e = RRbfile:write(i, '\n') + if f == nil then C("writing DNS-RR_bad.txt file - " .. e) end + end + elseif nil ~= RRgfile then + local f, e = RRgfile:write(i, '\n') + if f == nil then C("writing DNS-RR_good.txt file - " .. e) end end - elseif nil ~= RRgfile then - local f, e = RRgfile:write(i, '\n') - if f == nil then C("writing DNS-RR_good.txt file - " .. e) end end + if "yes" ~= hosts[k].DNSRR then inRR = "" end + local log = '[graphs]   ' + if "" == log then n[l][i] = u else n[l][log .. inRR .. ' ' .. revDNS(hosts, k, i) .. ' ' .. lc] = u end end - if "yes" ~= hosts[k].DNSRR then inRR = "" end - local log = '[graphs]   ' - if "" == log then n[l][i] = u else n[l][log .. inRR .. ' ' .. revDNS(hosts, k, i) .. ' ' .. lc] = u end end end else 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