From c7ea6c46dfcb79a750a4a258db6ed60e481dafaa Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 5 Nov 2019 18:15:59 +1000 Subject: Less dumb DNS report. --- apt-panopticon-report-DNS.lua | 52 ++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/apt-panopticon-report-DNS.lua b/apt-panopticon-report-DNS.lua index b26bde5..178659b 100755 --- a/apt-panopticon-report-DNS.lua +++ b/apt-panopticon-report-DNS.lua @@ -54,33 +54,36 @@ end -- Use this to dump a table to a string. dumpTable = function (table, space, name) local r = "" - if "" == space then r = r .. space .. name .. " =\n" else r = r .. space .. "[" .. name .. "] =\n" end - r = r .. space .. "{\n" +-- if "" == space then r = r .. space .. name .. " =\n" else r = r .. space .. "[" .. name .. "] =\n" end + if "" == space then r = r .. space .. name .. " \n" else r = r .. space .. name .. "\n" end +-- r = r .. space .. "{\n" r = r .. dumpTableSub(table, space .. " ") - if "" == space then r = r .. space .. "}\n" else r = r .. space .. "},\n" end +-- if "" == space then r = r .. space .. "}\n" else r = r .. space .. "},\n" end + if "" == space then r = r .. space .. "\n" end return r end dumpTableSub = function (table, space) local r = "" -- for k, v in pairs(table) do for k, v in orderedPairs(table) do - if type(k) == "string" then k = '"' .. k .. '"' end +-- if type(k) == "string" then k = '"' .. k .. '"' end if type(v) == "table" then r = r .. dumpTable(v, space, k) - elseif type(v) == "string" then - r = r .. space .. "[" .. k .. "] = '" .. v .. "';\n" - elseif type(v) == "function" then - r = r .. space .. "[" .. k .. "] = function ();\n" - elseif type(v) == "userdata" then - r = r .. space .. "userdata " .. "[" .. k .. "];\n" - elseif type(v) == "boolean" then - if (v) then - r = r .. space .. "[" .. k .. "] = true;\n" - else - r = r .. space .. "[" .. k .. "] = false;\n" - end +-- elseif type(v) == "string" then +-- r = r .. space .. "[" .. k .. "] = '" .. v .. "';\n" +-- elseif type(v) == "function" then +-- r = r .. space .. "[" .. k .. "] = function ();\n" +-- elseif type(v) == "userdata" then +-- r = r .. space .. "userdata " .. "[" .. k .. "];\n" +-- elseif type(v) == "boolean" then +-- if (v) then +-- r = r .. space .. "[" .. k .. "] = true;\n" +-- else +-- r = r .. space .. "[" .. k .. "] = false;\n" +-- end else - r = r .. space .. "[" .. k .. "] = " .. v .. ";\n" +-- r = r .. space .. "[" .. k .. "] = " .. v .. ";\n" + r = r .. space .. k .. "\n" end end return r @@ -121,9 +124,8 @@ local W = function(s, p, t, h) log(1, "WARNING ", s, p, t, h) end local E = function(s, p, t, h) log(0, "ERROR ", s, p, t, h) end local C = function(s) log(-1, "CRITICAL", s) end -local mirrors = {} - -mirrors = loadfile("results/mirrors.lua")() +local mirrors = loadfile("results/mirrors.lua")() +local m = {} for k, v in pairs(mirrors) do mirrors[k].Protocols = nil @@ -133,12 +135,16 @@ for k, v in pairs(mirrors) do mirrors[k].BaseURL = nil mirrors[k].Country = nil mirrors[k].Bandwidth = nil + m["\n" .. k .. " DNS entries"] = mirrors[k].IPs end -local file, e = io.open("results/REPORT-DNS.txt", "w+") +local file, e = io.open("results/Report-DNS.txt", "w+") if nil == file then C("opening mirrors file - " .. e) else - file:write(dumpTable(mirrors, "", "DNS report")) + file:write("This DNS report lists each mirror, and the DNS entries for that mirror. \n" .. + "If a mirror has a CNAME, that CNAME is listed along with that CNAMEs DNS entries.\n" .. + "deb.devuan.org is the DNS round robin, which points to the mirrors that are part of the DNS-RR.\n" .. + "pkgmaster.devuan.org is the master mirror, all the others sync to it.\n") + file:write(dumpTable(m, "", "")) file:close() end - -- cgit v1.1