aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mirror-checker.lua
diff options
context:
space:
mode:
authoronefang2019-09-07 01:30:38 +1000
committeronefang2019-09-07 01:30:38 +1000
commit7380b7e774c58d311e87a7976a177790f5f730bb (patch)
tree02efbf14d0eca5f330fd728f952e777879ea70a3 /mirror-checker.lua
parentSwitch printTable to dumpTable. (diff)
downloadapt-panopticon-7380b7e774c58d311e87a7976a177790f5f730bb.zip
apt-panopticon-7380b7e774c58d311e87a7976a177790f5f730bb.tar.gz
apt-panopticon-7380b7e774c58d311e87a7976a177790f5f730bb.tar.bz2
apt-panopticon-7380b7e774c58d311e87a7976a177790f5f730bb.tar.xz
Save and load the mirror list between threads.
Diffstat (limited to '')
-rwxr-xr-xmirror-checker.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/mirror-checker.lua b/mirror-checker.lua
index 0e8567e..e2975fe 100755
--- a/mirror-checker.lua
+++ b/mirror-checker.lua
@@ -130,6 +130,8 @@ local E = function(s) log(0, "ERROR ", s) end
130local C = function(s) log(-1, "CRITICAL", s) end 130local C = function(s) log(-1, "CRITICAL", s) end
131 131
132local testing = function(t) 132local testing = function(t)
133local mirrors = {}
134
133 for i, v in pairs(options.tests.value) do 135 for i, v in pairs(options.tests.value) do
134 if t == v then return true end 136 if t == v then return true end
135 end 137 end
@@ -372,6 +374,11 @@ local getMirrors = function ()
372 mirrors[host] = m 374 mirrors[host] = m
373 end 375 end
374 end 376 end
377 local file, e = io.open("results/mirrors.lua", "w+")
378 if nil == file then C("opening mirrors file - " .. e) else
379 file:write(dumpTable(mirrors, "", "mirrors") .. "\nreturn mirrors\n")
380 file:close()
381 end
375 return mirrors 382 return mirrors
376end 383end
377 384
@@ -463,6 +470,8 @@ if 0 < #arg then
463 end 470 end
464 if nil == logFile then C("opening log file - " .. e); return end 471 if nil == logFile then C("opening log file - " .. e); return end
465 I("Starting tests for " ..arg[1] .. " with these tests - " .. table.concat(options.tests.value, ", ")) 472 I("Starting tests for " ..arg[1] .. " with these tests - " .. table.concat(options.tests.value, ", "))
473 mirrors = loadfile("results/mirrors.lua")()
474--print(dumpTable(mirrors, "", "mirrors"))
466 if nil ~= arg[2] then I(" Using IP " .. arg[2]) end 475 if nil ~= arg[2] then I(" Using IP " .. arg[2]) end
467 if nil ~= arg[3] then I(" Using file " .. arg[3]); end 476 if nil ~= arg[3] then I(" Using file " .. arg[3]); end
468 if testing("Integrity") or testing("Updated") then 477 if testing("Integrity") or testing("Updated") then
@@ -487,7 +496,8 @@ else
487 if nil == logFile then C("opening log file - " .. e); return end 496 if nil == logFile then C("opening log file - " .. e); return end
488 I("Starting tests " .. table.concat(options.tests.value, ", ")) 497 I("Starting tests " .. table.concat(options.tests.value, ", "))
489 execute("mkdir -p results") 498 execute("mkdir -p results")
490 local mirrors = getMirrors() 499 mirrors = getMirrors()
500--print(dumpTable(mirrors, "", "mirrors"))
491 mirrors[options.referenceSite.value] = nil 501 mirrors[options.referenceSite.value] = nil
492 checkRedirects(options.referenceSite.value) 502 checkRedirects(options.referenceSite.value)
493-- forkIP(options.referenceSite.value) 503-- forkIP(options.referenceSite.value)