From 0f43ca83d630264e42f7875bc6af1d77125b5ebe Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 25 Dec 2019 18:47:55 +1000 Subject: Track, store, and report info from the hosts that get redirected to. --- apt-panopticommon.lua | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'apt-panopticommon.lua') diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua index e73e69e..37b43e4 100644 --- a/apt-panopticommon.lua +++ b/apt-panopticommon.lua @@ -53,7 +53,7 @@ APT.options = "DNSRR", "Protocol", "URLSanity", - "Integrity", +-- "Integrity", "Updated", }, }, @@ -411,6 +411,7 @@ local E = APT.E local C = APT.C +APT.debians = {} APT.mirrors = {} APT.testing = function(t, host) @@ -498,6 +499,7 @@ APT.padResults = function(results) if nil == tests.Integrity then tests.Integrity = {errors = c; warnings = c; timeouts = c} end if nil == tests.Protocol then tests.Protocol = {errors = c; warnings = c; timeouts = c} end if nil == tests.Updated then tests.Updated = {errors = c; warnings = c; timeouts = c} end + if nil == tests.redirects then tests.redirects = {} end if nil == tests.URLSanity then tests.URLSanity = {errors = c; warnings = c; timeouts = c} end results[v] = tests end @@ -517,23 +519,25 @@ APT.collate = function(l, host, ip, results) if ("speed" == k) and (nil ~= results.speed) then if v.min < results.speed.min then results.speed.min = v.min end if v.max > results.speed.max then results.speed.max = v.max end - else + elseif 'IPs' ~= k then for i, u in pairs(v) do - if "table" == type(u) then - for h, t in pairs(u) do + if 'redirects' ~= i then + if "table" == type(u) then + for h, t in pairs(u) do + local a = results[k] + if nil == a then results[k] = {i = {}}; a = results[k] end + a = a[i] + if nil == a then results[k][i] = {h = {}}; a = results[k][i] end + a = a[h] + if nil == a then a = 0 end + results[k][i][h] = a + t + end + else local a = results[k] - if nil == a then results[k] = {i = {}}; a = results[k] end - a = a[i] - if nil == a then results[k][i] = {h = {}}; a = results[k][i] end - a = a[h] + if nil == a then a = 0; results[k] = {} else a = a[i] end if nil == a then a = 0 end - results[k][i][h] = a + t + results[k][i] = a + u end - else - local a = results[k] - if nil == a then a = 0; results[k] = {} else a = a[i] end - if nil == a then a = 0 end - results[k][i] = a + u end end end @@ -546,14 +550,14 @@ APT.collate = function(l, host, ip, results) end return results end -APT.collateAll = function(l, host, func) +APT.collateAll = function(hosts, l, host, func) results = {} local f = l .. "/" .. host .. ".lua" if APT.checkFile(f) then results = loadfile(f)() results = APT.padResults(results) if nil ~= func then func(results) end - local v = APT.mirrors[host] + local v = hosts[host] if nil ~= v then local IPs = results.IPs if nil == IPs then W('No IPs for ' .. host .. ' in ' .. l) else @@ -662,7 +666,7 @@ APT.updateRRD = function(results, host, ip) end APT.doRRD = function(l, k, v, o) - APT.collateAll(l, k, + APT.collateAll(APT.mirrors, l, k, function(results, ip) APT.createRRD(k, ip, o) APT.updateRRD(results, k, ip) -- cgit v1.1