aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apt-panopticommon.lua
diff options
context:
space:
mode:
authoronefang2019-12-25 18:47:55 +1000
committeronefang2019-12-25 18:47:55 +1000
commit0f43ca83d630264e42f7875bc6af1d77125b5ebe (patch)
treeb09908a42b1508b220181f99aeda865c7371b238 /apt-panopticommon.lua
parentMissed a return false from logOpen() (diff)
downloadapt-panopticon-0f43ca83d630264e42f7875bc6af1d77125b5ebe.zip
apt-panopticon-0f43ca83d630264e42f7875bc6af1d77125b5ebe.tar.gz
apt-panopticon-0f43ca83d630264e42f7875bc6af1d77125b5ebe.tar.bz2
apt-panopticon-0f43ca83d630264e42f7875bc6af1d77125b5ebe.tar.xz
Track, store, and report info from the hosts that get redirected to.
Diffstat (limited to 'apt-panopticommon.lua')
-rw-r--r--apt-panopticommon.lua38
1 files changed, 21 insertions, 17 deletions
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 =
53 "DNSRR", 53 "DNSRR",
54 "Protocol", 54 "Protocol",
55 "URLSanity", 55 "URLSanity",
56 "Integrity", 56-- "Integrity",
57 "Updated", 57 "Updated",
58 }, 58 },
59 }, 59 },
@@ -411,6 +411,7 @@ local E = APT.E
411local C = APT.C 411local C = APT.C
412 412
413 413
414APT.debians = {}
414APT.mirrors = {} 415APT.mirrors = {}
415 416
416APT.testing = function(t, host) 417APT.testing = function(t, host)
@@ -498,6 +499,7 @@ APT.padResults = function(results)
498 if nil == tests.Integrity then tests.Integrity = {errors = c; warnings = c; timeouts = c} end 499 if nil == tests.Integrity then tests.Integrity = {errors = c; warnings = c; timeouts = c} end
499 if nil == tests.Protocol then tests.Protocol = {errors = c; warnings = c; timeouts = c} end 500 if nil == tests.Protocol then tests.Protocol = {errors = c; warnings = c; timeouts = c} end
500 if nil == tests.Updated then tests.Updated = {errors = c; warnings = c; timeouts = c} end 501 if nil == tests.Updated then tests.Updated = {errors = c; warnings = c; timeouts = c} end
502 if nil == tests.redirects then tests.redirects = {} end
501 if nil == tests.URLSanity then tests.URLSanity = {errors = c; warnings = c; timeouts = c} end 503 if nil == tests.URLSanity then tests.URLSanity = {errors = c; warnings = c; timeouts = c} end
502 results[v] = tests 504 results[v] = tests
503 end 505 end
@@ -517,23 +519,25 @@ APT.collate = function(l, host, ip, results)
517 if ("speed" == k) and (nil ~= results.speed) then 519 if ("speed" == k) and (nil ~= results.speed) then
518 if v.min < results.speed.min then results.speed.min = v.min end 520 if v.min < results.speed.min then results.speed.min = v.min end
519 if v.max > results.speed.max then results.speed.max = v.max end 521 if v.max > results.speed.max then results.speed.max = v.max end
520 else 522 elseif 'IPs' ~= k then
521 for i, u in pairs(v) do 523 for i, u in pairs(v) do
522 if "table" == type(u) then 524 if 'redirects' ~= i then
523 for h, t in pairs(u) do 525 if "table" == type(u) then
526 for h, t in pairs(u) do
527 local a = results[k]
528 if nil == a then results[k] = {i = {}}; a = results[k] end
529 a = a[i]
530 if nil == a then results[k][i] = {h = {}}; a = results[k][i] end
531 a = a[h]
532 if nil == a then a = 0 end
533 results[k][i][h] = a + t
534 end
535 else
524 local a = results[k] 536 local a = results[k]
525 if nil == a then results[k] = {i = {}}; a = results[k] end 537 if nil == a then a = 0; results[k] = {} else a = a[i] end
526 a = a[i]
527 if nil == a then results[k][i] = {h = {}}; a = results[k][i] end
528 a = a[h]
529 if nil == a then a = 0 end 538 if nil == a then a = 0 end
530 results[k][i][h] = a + t 539 results[k][i] = a + u
531 end 540 end
532 else
533 local a = results[k]
534 if nil == a then a = 0; results[k] = {} else a = a[i] end
535 if nil == a then a = 0 end
536 results[k][i] = a + u
537 end 541 end
538 end 542 end
539 end 543 end
@@ -546,14 +550,14 @@ APT.collate = function(l, host, ip, results)
546 end 550 end
547 return results 551 return results
548end 552end
549APT.collateAll = function(l, host, func) 553APT.collateAll = function(hosts, l, host, func)
550 results = {} 554 results = {}
551 local f = l .. "/" .. host .. ".lua" 555 local f = l .. "/" .. host .. ".lua"
552 if APT.checkFile(f) then 556 if APT.checkFile(f) then
553 results = loadfile(f)() 557 results = loadfile(f)()
554 results = APT.padResults(results) 558 results = APT.padResults(results)
555 if nil ~= func then func(results) end 559 if nil ~= func then func(results) end
556 local v = APT.mirrors[host] 560 local v = hosts[host]
557 if nil ~= v then 561 if nil ~= v then
558 local IPs = results.IPs 562 local IPs = results.IPs
559 if nil == IPs then W('No IPs for ' .. host .. ' in ' .. l) else 563 if nil == IPs then W('No IPs for ' .. host .. ' in ' .. l) else
@@ -662,7 +666,7 @@ APT.updateRRD = function(results, host, ip)
662end 666end
663 667
664APT.doRRD = function(l, k, v, o) 668APT.doRRD = function(l, k, v, o)
665 APT.collateAll(l, k, 669 APT.collateAll(APT.mirrors, l, k,
666 function(results, ip) 670 function(results, ip)
667 APT.createRRD(k, ip, o) 671 APT.createRRD(k, ip, o)
668 APT.updateRRD(results, k, ip) 672 APT.updateRRD(results, k, ip)