aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--apt-panopticommon.lua31
-rwxr-xr-xapt-panopticon.lua34
2 files changed, 53 insertions, 12 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua
index d9293f6..b1f39d7 100644
--- a/apt-panopticommon.lua
+++ b/apt-panopticommon.lua
@@ -26,6 +26,19 @@ APT.keep = false
26 26
27APT.options = 27APT.options =
28{ 28{
29 bandwidth =
30 {
31 typ = "number",
32 help = ' 0 = low - HTTP tests for all IPs of all mirrors (HEAD tests), but not URL sanity tests.\n' ..
33 ' 1 = medium - Also HTTP(S) redirect tests, other protocols, download Release files over HTTP, and check them.\n' ..
34 ' 2 = high - Also download Packages.xz files that changed, unpack and check them.\n' ..
35 ' Also download and check InRelease files\n.' ..
36 ' Pick a few small packages, download them, check their SHA512.\n' ..
37 ' 3 = more - Also pick more packages, some for each arch.\n' ..
38 ' 4 = all - Do absolutely everything.\n' ..
39 ' Actually download some Contents files, and some more Packages.xz, and package files.',
40 value = 2,
41 },
29 referenceSite = 42 referenceSite =
30 { 43 {
31 typ = "string", 44 typ = "string",
@@ -127,6 +140,24 @@ APT.parseArgs = function(args)
127 elseif "-r" == a then 140 elseif "-r" == a then
128 APT.redir = true 141 APT.redir = true
129 sendArgs = sendArgs .. a .. " " 142 sendArgs = sendArgs .. a .. " "
143 elseif "--low" == a then
144 APT.options.bandwidth.value = 0
145 APT.options.timeout.value = 2
146 APT.options.timeouts.value = 1
147 APT.options.retries.value = 1
148 sendArgs = sendArgs .. a .. " "
149 elseif "--medium" == a then
150 APT.options.bandwidth.value = 1
151 sendArgs = sendArgs .. a .. " "
152 elseif "--high" == a then
153 APT.options.bandwidth.value = 2
154 sendArgs = sendArgs .. a .. " "
155 elseif "--more" == a then
156 APT.options.bandwidth.value = 3
157 sendArgs = sendArgs .. a .. " "
158 elseif "--all" == a then
159 APT.options.bandwidth.value = 4
160 sendArgs = sendArgs .. a .. " "
130 elseif "--" == a:sub(1, 2) then 161 elseif "--" == a:sub(1, 2) then
131 local s, e = a:find("=") 162 local s, e = a:find("=")
132 if nil == s then e = -1 end 163 if nil == s then e = -1 end
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index c2b44ee..b45ca45 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -350,7 +350,7 @@ checkHEAD = function (host, URL, r, retry, sanity)
350 end 350 end
351 I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL) 351 I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL)
352-- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. 352-- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through.
353 if nil ~= location then 353 if (1 <= APT.options.bandwidth.value) and (nil ~= location) then
354 pu = url.parse(location, defaultURL) 354 pu = url.parse(location, defaultURL)
355 if ('http' == location:sub(1, 4)) and (pu.scheme ~= PU.scheme) then -- Sometimes a location sans scheme is returned, this is not a protocol change. 355 if ('http' == location:sub(1, 4)) and (pu.scheme ~= PU.scheme) then -- Sometimes a location sans scheme is returned, this is not a protocol change.
356 if APT.testing("Protocol") then 356 if APT.testing("Protocol") then
@@ -397,7 +397,7 @@ end
397local checkTimeouts = function(host, scheme, URL) 397local checkTimeouts = function(host, scheme, URL)
398 totalTimeouts = totalTimeouts + timeouts; timeouts = 0 398 totalTimeouts = totalTimeouts + timeouts; timeouts = 0
399 checkHEAD(host, scheme .. "://" .. URL) 399 checkHEAD(host, scheme .. "://" .. URL)
400 if APT.testing("URLSanity") then 400 if (1 <= APT.options.bandwidth.value) and APT.testing("URLSanity") then
401 URL = URL:gsub("/", "///") 401 URL = URL:gsub("/", "///")
402 URL = URL:gsub("///", "/", 1) 402 URL = URL:gsub("///", "/", 1)
403 checkHEAD(host, scheme .. "://" .. URL, 0, 0, true) 403 checkHEAD(host, scheme .. "://" .. URL, 0, 0, true)
@@ -424,21 +424,31 @@ local checkFiles = function (host, ip, path, file)
424 if checkTimeouts(host, "https", ip .. path .. "/" .. file) then return end 424 if checkTimeouts(host, "https", ip .. path .. "/" .. file) then return end
425 else 425 else
426 I(" Checking IP " .. host .. " -> " .. ip .. " " .. path) 426 I(" Checking IP " .. host .. " -> " .. ip .. " " .. path)
427 if 1 <= APT.options.bandwidth.value then
428 -- Do these first, coz they are likely to fork off a different server.
429 for i, s in pairs(referenceDebs) do
430 if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end
431 if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end
432 end
433 end
427 for i, s in pairs(releases) do 434 for i, s in pairs(releases) do
428 for j, k in pairs(releaseFiles) do 435 for j, k in pairs(releaseFiles) do
429 if repoExists(s .. k) then 436 if repoExists(s .. k) then
430 if checkTimeouts(host, "http", ip .. path .. "/merged/dists/" .. s .. '/' .. k) then return end 437 if checkTimeouts(host, "http", ip .. path .. "/merged/dists/" .. s .. '/' .. k) then return end
431 if checkTimeouts(host, "https", ip .. path .. "/merged/dists/" .. s .. '/' .. k) then return end 438 if 1 <= APT.options.bandwidth.value then
439 if checkTimeouts(host, "https", ip .. path .. "/merged/dists/" .. s .. '/' .. k) then return end
440 else
441 break
442 end
432 end 443 end
433 end 444 end
445 if 0 == APT.options.bandwidth.value then break end
434 end 446 end
435 for i, s in pairs(referenceDebs) do 447 if 1 <= APT.options.bandwidth.value then
436 if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end 448 for i, s in pairs(referenceDevs) do
437 if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end 449 if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end
438 end 450 if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end
439 for i, s in pairs(referenceDevs) do 451 end
440 if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end
441 if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end
442 end 452 end
443 end 453 end
444end 454end
@@ -843,7 +853,7 @@ local parseRelease = function(host)
843-- TODO - like we do with debs, pick just the smallest Packages.xz that has changed. 853-- TODO - like we do with debs, pick just the smallest Packages.xz that has changed.
844-- Though we are sorting Release by name, so we can do the diff with the one from results_old, so we'll need to sort by size to. 854-- Though we are sorting Release by name, so we can do the diff with the one from results_old, so we'll need to sort by size to.
845-- pkgmaster still needs to download all the changed Packages.xz files though. 855-- pkgmaster still needs to download all the changed Packages.xz files though.
846 if updated or APT.testing("Integrity") or (APT.options.referenceSite.value == host) then 856 if (2 <= APT.options.bandwidth.value) and (updated or APT.testing("Integrity") or (APT.options.referenceSite.value == host)) then
847 local dfile, e = io.open(outFile, "r") 857 local dfile, e = io.open(outFile, "r")
848 if nil == dfile then W("opening " .. outFile .. " file - " .. e) else 858 if nil == dfile then W("opening " .. outFile .. " file - " .. e) else
849 for l in dfile:lines() do 859 for l in dfile:lines() do
@@ -1024,7 +1034,7 @@ if 0 < #arg then
1024 end 1034 end
1025 1035
1026 if not APT.redir then 1036 if not APT.redir then
1027 if APT.testing("Integrity") or APT.testing("Updated") then 1037 if (1 <= APT.options.bandwidth.value) and (APT.testing("Integrity") or APT.testing("Updated")) then
1028 if APT.origin and (APT.options.roundRobin.value ~= pu.host) then 1038 if APT.origin and (APT.options.roundRobin.value ~= pu.host) then
1029 I("Starting file downloads for " .. pu.host) 1039 I("Starting file downloads for " .. pu.host)
1030 D('*&gt;* About to create coroutine.') 1040 D('*&gt;* About to create coroutine.')