diff options
Diffstat (limited to 'apt-panopticon.lua')
-rwxr-xr-x | apt-panopticon.lua | 142 |
1 files changed, 96 insertions, 46 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 4019fdf..bee4eac 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua | |||
@@ -14,7 +14,6 @@ APT.html = true | |||
14 | 14 | ||
15 | 15 | ||
16 | local defaultURL = {scheme = "http"} | 16 | local defaultURL = {scheme = "http"} |
17 | local releases = {"jessie", "ascii", "beowulf", "ceres"} | ||
18 | local releaseFiles = | 17 | local releaseFiles = |
19 | { | 18 | { |
20 | -- Release file. | 19 | -- Release file. |
@@ -37,16 +36,20 @@ local notExist = | |||
37 | local referenceDebs = | 36 | local referenceDebs = |
38 | { | 37 | { |
39 | -- Debian package. | 38 | -- Debian package. |
40 | "merged/pool/DEBIAN/main/d/debian-keyring/debian-keyring_2019.02.25_all.deb", | 39 | "merged/pool/DEBIAN/main/d/debian-keyring/debian-keyring_2024.03.24_all.deb", |
41 | -- Debian security package. NOTE this one should always be redirected? | 40 | -- Debian security package. NOTE this one should always be redirected? |
42 | "merged/pool/DEBIAN-SECURITY/updates/main/a/apt/apt-transport-https_1.4.10_amd64.deb", | 41 | "merged/pool/DEBIAN-SECURITY/updates/main/a/apt/apt-transport-https_1.8.2.2_all.deb", |
43 | } | 42 | } |
44 | local referenceDevs = | 43 | local referenceDevs = |
45 | { | 44 | { |
46 | -- Devuan package. NOTE this one should not get redirected, but that's more a warning than an error. | 45 | -- Devuan package. NOTE this one should not get redirected, but that's more a warning than an error. |
47 | "merged/pool/DEVUAN/main/d/devuan-keyring/devuan-keyring_2017.10.03_all.deb", | 46 | "merged/pool/DEVUAN/main/d/devuan-keyring/devuan-keyring_2023.10.07_all.deb", -- Devuan keeps changing this since the key expiry incident. |
47 | "merged/pool/DEVUAN/main/b/base-files/base-files_13.1devuan1_all.deb", | ||
48 | } | 48 | } |
49 | 49 | ||
50 | local keyring = "/usr/share/keyrings/devuan-archive-keyring.gpg" | ||
51 | --local keyring = "/etc/apt/trusted.gpg.d/devuan-keyring-2022-archive.gpg" | ||
52 | |||
50 | local curlStatus = | 53 | local curlStatus = |
51 | { | 54 | { |
52 | [1 ] = "Unsupported protocol. This build of curl has no support for this protocol.", | 55 | [1 ] = "Unsupported protocol. This build of curl has no support for this protocol.", |
@@ -170,38 +173,76 @@ local repoExists = function (r) | |||
170 | end | 173 | end |
171 | 174 | ||
172 | local IP = {} | 175 | local IP = {} |
173 | gatherIPs = function (host) | 176 | gatherIPs = function (host, again) |
177 | if nil == again then again = '' end | ||
174 | if nil == IP[host] then | 178 | if nil == IP[host] then |
175 | local IPs | 179 | local IPs |
176 | -- Takes about 30 seconds to look up the lot. | 180 | -- Takes about 30 seconds to look up the lot. |
177 | -- I tested using dig's -f option, it didn't seem much faster. | 181 | -- I tested using dig's -f option, it didn't seem much faster. |
178 | -- The sort -r assumes that deb.devuan.org is the first alphabetically. | 182 | -- The sort -r assumes that deb.devuan.org is the first alphabetically. |
179 | local dig = io.popen('dig +keepopen +noall +nottlid +answer ' .. host .. ' A ' .. host .. ' AAAA ' .. host .. ' CNAME ' .. host .. ' SRV | sort -r | uniq') | 183 | if "" == host then print("Empty host name!") end |
180 | repeat | 184 | local dig = APT.readCmd('dig ' .. again .. ' +keepopen +noall +nottlid +answer ' .. host .. ' A ' .. host .. ' AAAA ' .. host .. ' CNAME ' .. host .. ' SRV | sort -r | uniq') |
181 | IPs = dig:read("*l") | 185 | for i,IPs in ipairs(dig) do |
182 | if nil ~= IPs then | 186 | for k, t, v in IPs:gmatch("([%w_%-%.]*)%.%s*IN%s*(%a*)%s*(.*)") do |
183 | for k, t, v in IPs:gmatch("([%w_%-%.]*)%.%s*IN%s*(%a*)%s*(.*)") do | 187 | if "." == v:sub(-1, -1) then v = v:sub(1, -2) end |
184 | if "." == v:sub(-1, -1) then v = v:sub(1, -2) end | 188 | if nil == IP[k] then IP[k] = {} end |
185 | if nil == IP[k] then IP[k] = {} end | 189 | IP[k][v] = t |
186 | IP[k][v] = t | 190 | D(" DNS record " .. host .. " == " .. k .. " type " .. t .. " -> " .. v) |
187 | D(" DNS record " .. host .. " == " .. k .. " type " .. t .. " -> " .. v) | 191 | if t == "CNAME" then |
188 | if t == "CNAME" then | 192 | if "" == v then |
193 | if '' ~= again then | ||
194 | print("Empty host name! DNS record " .. host .. " == " .. k .. " type " .. t .. " -> " .. v) | ||
195 | else | ||
196 | return gatherIPs(host, '@9.9.9.11') | ||
197 | end | ||
198 | else | ||
189 | gatherIPs(v) | 199 | gatherIPs(v) |
190 | IP[k][v] = IP[v] | 200 | IP[k][v] = IP[v] |
191 | elseif v == "SRV" then | 201 | end |
192 | print("SVR record found, now what do we do?") | 202 | elseif v == "SRV" then |
203 | print("SVR record found, now what do we do?") | ||
204 | elseif "" == v then | ||
205 | if '' ~= again then | ||
206 | print("Empty host name! DNS record " .. host .. " == " .. k .. " type " .. t .. " -> " .. v) | ||
207 | else | ||
208 | return gatherIPs(host, '@9.9.9.11') | ||
193 | end | 209 | end |
194 | end | 210 | end |
195 | end | 211 | end |
196 | until nil == IPs | 212 | end |
197 | end | 213 | end |
198 | 214 | ||
199 | -- If this is the DNS-RR domain name, gather the IPs for the mirrors that mirror_list.txt says should be in it. | 215 | -- If this is the DNS-RR domain name, gather the IPs for the mirrors that mirror_list.txt says should be in it. |
200 | if host == APT.options.roundRobin.value then | 216 | if host == APT.options.roundRobin.value then |
201 | for k, m in pairs(APT.mirrors) do | 217 | for k, m in pairs(APT.mirrors) do |
202 | if "yes" == m.DNSRR then | 218 | if ("yes" == m.DNSRR) or ("maybe" == m.DNSRR) then |
219 | if "" == m.FQDN then | ||
220 | print("Empty FQDN name! " .. host) | ||
221 | end | ||
203 | gatherIPs(m.FQDN) | 222 | gatherIPs(m.FQDN) |
204 | IP[host][m.FQDN] = IP[m.FQDN] | 223 | IP[host][m.FQDN] = IP[m.FQDN] |
224 | -- Strip them out so we don't test them twice. | ||
225 | if (nil ~= IP[m.FQDN]) and (nil ~= IP[host][APT.options.roundRobinCname.value]) then | ||
226 | for l, n in pairs(IP[m.FQDN]) do | ||
227 | if type(n) == 'table' then | ||
228 | for h, p in pairs(n) do | ||
229 | for j, o in pairs(IP[host][APT.options.roundRobinCname.value]) do | ||
230 | if h == j then IP[host][m.FQDN][l][h] = nil end | ||
231 | end | ||
232 | o = 0 | ||
233 | for j in pairs(IP[host][m.FQDN][l]) do o = o + 1 end | ||
234 | if 0 == o then IP[host][m.FQDN][l] = nil end | ||
235 | end | ||
236 | else | ||
237 | for j, o in pairs(IP[host][APT.options.roundRobinCname.value]) do | ||
238 | if l == j then IP[host][m.FQDN][l] = nil end | ||
239 | end | ||
240 | end | ||
241 | o = 0 | ||
242 | for j in pairs(IP[host][m.FQDN]) do o = o + 1 end | ||
243 | if 0 == o then IP[host][m.FQDN] = nil end | ||
244 | end | ||
245 | end | ||
205 | end | 246 | end |
206 | end | 247 | end |
207 | end | 248 | end |
@@ -289,7 +330,7 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
289 | 'curl -I --retry 0 -s --path-as-is --connect-timeout ' .. APT.options.timeout.value .. ' --max-redirs 0 ' .. APT.IPv46 .. ' ' .. | 330 | 'curl -I --retry 0 -s --path-as-is --connect-timeout ' .. APT.options.timeout.value .. ' --max-redirs 0 ' .. APT.IPv46 .. ' ' .. |
290 | IP .. ' ' .. '-o /dev/null -D results/"HEADERS_' .. fname .. '" ' .. | 331 | IP .. ' ' .. '-o /dev/null -D results/"HEADERS_' .. fname .. '" ' .. |
291 | hdr .. ' -w "#%{http_code} %{ssl_verify_result} %{url_effective}\\n" ' .. PU.scheme .. '://' .. host .. PU.path .. ' >>results/"STATUS_' .. fname .. '"' | 332 | hdr .. ' -w "#%{http_code} %{ssl_verify_result} %{url_effective}\\n" ' .. PU.scheme .. '://' .. host .. PU.path .. ' >>results/"STATUS_' .. fname .. '"' |
292 | ):Nice():log():Do().status | 333 | ):timeout(APT.options.maxtime.value * 2.0):Nice():log():Do().status |
293 | if 0 < r then | 334 | if 0 < r then |
294 | APT.tested(PU.scheme, 'Redirects', host) | 335 | APT.tested(PU.scheme, 'Redirects', host) |
295 | else | 336 | else |
@@ -315,7 +356,7 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
315 | if 0 ~= status then | 356 | if 0 ~= status then |
316 | local msg = curlStatus[status] | 357 | local msg = curlStatus[status] |
317 | if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end | 358 | if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end |
318 | if (28 == status) or (7 == status) then | 359 | if (128+9 == status) or (124 == status) or (28 == status) or (7 == status) then |
319 | T(spcd .. spcd .. "TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1 .. ' ' .. APT.lnk(URL), PU.scheme, sanity, host) | 360 | T(spcd .. spcd .. "TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1 .. ' ' .. APT.lnk(URL), PU.scheme, sanity, host) |
320 | timeouts = timeouts + 1 | 361 | timeouts = timeouts + 1 |
321 | else | 362 | else |
@@ -406,7 +447,7 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
406 | local pth = path:match('^(.*/pool/).*$') | 447 | local pth = path:match('^(.*/pool/).*$') |
407 | if nil ~= pth then table.insert(APT.results[PU.scheme].redirects, pu.host .. "/" .. pth) else E(spcd .. spcd .. 'Odd redirect path ' .. path) end | 448 | if nil ~= pth then table.insert(APT.results[PU.scheme].redirects, pu.host .. "/" .. pth) else E(spcd .. spcd .. 'Odd redirect path ' .. path) end |
408 | I(spcd .. spcd .. "Now checking redirected host " .. u .. ' for ' .. APT.lnk(URL) .. arw .. APT.lnk(location), host) | 449 | I(spcd .. spcd .. "Now checking redirected host " .. u .. ' for ' .. APT.lnk(URL) .. arw .. APT.lnk(location), host) |
409 | APT.exe(downloadLock .. "REDIR-" .. check .. ".log.txt" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file):Nice():log():fork() | 450 | APT.exe(downloadLock .. "REDIR-" .. check .. ".log.txt" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file):timeout(APT.options.maxtime.value * 2.0):Nice():log():fork(pu.host) |
410 | D(spcd .. 'logging to ' .. APT.logName(pu.host, nil, file)[2]) | 451 | D(spcd .. 'logging to ' .. APT.logName(pu.host, nil, file)[2]) |
411 | APT.tested(PU.scheme, 'Redirects', host) | 452 | APT.tested(PU.scheme, 'Redirects', host) |
412 | end | 453 | end |
@@ -454,7 +495,7 @@ local checkFiles = function (host, ip, path, file) | |||
454 | if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end | 495 | if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end |
455 | end | 496 | end |
456 | end | 497 | end |
457 | for i, s in pairs(releases) do | 498 | for i, s in pairs(APT.releases) do |
458 | for j, k in pairs(releaseFiles) do | 499 | for j, k in pairs(releaseFiles) do |
459 | if repoExists(s .. k) then | 500 | if repoExists(s .. k) then |
460 | if checkTimeouts(host, "http", ip .. path .. "/merged/dists/" .. s .. '/' .. k) then return end | 501 | if checkTimeouts(host, "http", ip .. path .. "/merged/dists/" .. s .. '/' .. k) then return end |
@@ -493,7 +534,7 @@ checkHost = function (orig, host, path, ip, file) | |||
493 | else | 534 | else |
494 | if orig == host then | 535 | if orig == host then |
495 | I("Testing mirror " .. orig .. "" .. file) | 536 | I("Testing mirror " .. orig .. "" .. file) |
496 | APT.exe("./apt-panopticon.lua " .. sendArgs .. " -o " .. orig .. path .. " " .. file):Nice():log():fork() | 537 | APT.exe("./apt-panopticon.lua " .. sendArgs .. " -o " .. orig .. path .. " " .. file):timeout(APT.options.maxtime.value * 2.0):Nice():log():fork(orig) |
497 | D('logging to ' .. APT.logName(ph.host, nil, file)[2]) | 538 | D('logging to ' .. APT.logName(ph.host, nil, file)[2]) |
498 | else D("checkHost " .. orig .. arw .. host) end | 539 | else D("checkHost " .. orig .. arw .. host) end |
499 | end | 540 | end |
@@ -568,7 +609,7 @@ local downloads = function(host, URL, meta, release, list) | |||
568 | return | 609 | return |
569 | end | 610 | end |
570 | else | 611 | else |
571 | for i, s in pairs(releases) do | 612 | for i, s in pairs(APT.releases) do |
572 | for j, k in pairs(releaseFiles) do | 613 | for j, k in pairs(releaseFiles) do |
573 | if repoExists(s .. k) then | 614 | if repoExists(s .. k) then |
574 | addDownload(host, URL, f, s, k) | 615 | addDownload(host, URL, f, s, k) |
@@ -577,7 +618,7 @@ local downloads = function(host, URL, meta, release, list) | |||
577 | end | 618 | end |
578 | end | 619 | end |
579 | f:close() | 620 | f:close() |
580 | APT.exe(cm):Nice():log():fork() | 621 | APT.exe(cm):timeout(APT.options.maxtime.value * 2.0):Nice():log():fork(host) |
581 | D('logging to <a href="' .. log .. '">' .. log .. '</a>, with <a href="' .. files .. '">these files</a>') | 622 | D('logging to <a href="' .. log .. '">' .. log .. '</a>, with <a href="' .. files .. '">these files</a>') |
582 | end | 623 | end |
583 | 624 | ||
@@ -594,7 +635,7 @@ local validateURL = function(m) | |||
594 | local p = url.parse("http://" .. m.BaseURL) | 635 | local p = url.parse("http://" .. m.BaseURL) |
595 | if nil == p.path then p.path = '' end | 636 | if nil == p.path then p.path = '' end |
596 | if nil ~= p.port then p.authority = authority .. ':' .. p.port end | 637 | if nil ~= p.port then p.authority = authority .. ':' .. p.port end |
597 | if nil == m.FDQN then W("Something wrong in FDQN from mirror_list.txt! nil", "", "", p.authority) else | 638 | if nil == m.FQDN then W("Something wrong in FQDN from mirror_list.txt! nil", "", "", p.authority) else |
598 | if m.FQDN ~= p.authority then W("Something wrong in FDQN from mirror_list.txt! " .. m.FDQN, "", "", p.authority) end | 639 | if m.FQDN ~= p.authority then W("Something wrong in FDQN from mirror_list.txt! " .. m.FDQN, "", "", p.authority) end |
599 | end | 640 | end |
600 | if nil == m.BaseURL then W("Something wrong in BaseURL from mirror_list.txt! nil", "", "", p.authority) else | 641 | if nil == m.BaseURL then W("Something wrong in BaseURL from mirror_list.txt! nil", "", "", p.authority) else |
@@ -678,7 +719,7 @@ local postParse = function(host, list) | |||
678 | if APT.options.referenceSite.value == host then | 719 | if APT.options.referenceSite.value == host then |
679 | if nil ~= list then | 720 | if nil ~= list then |
680 | local sem = 'results/NEW_' .. list.out .. '_%s.txt' | 721 | local sem = 'results/NEW_' .. list.out .. '_%s.txt' |
681 | for i, n in pairs(releases) do | 722 | for i, n in pairs(APT.releases) do |
682 | local f = sem:format(n) | 723 | local f = sem:format(n) |
683 | if APT.checkFile(f .. '.tmp') then | 724 | if APT.checkFile(f .. '.tmp') then |
684 | os.execute('mv ' .. f .. '.tmp ' .. f) | 725 | os.execute('mv ' .. f .. '.tmp ' .. f) |
@@ -691,7 +732,7 @@ local postParse = function(host, list) | |||
691 | end | 732 | end |
692 | 733 | ||
693 | local parseDebs = function(host) | 734 | local parseDebs = function(host) |
694 | for i, n in pairs(releases) do | 735 | for i, n in pairs(APT.releases) do |
695 | local inFile = 'results/NEW_debs_' .. n .. '.txt' | 736 | local inFile = 'results/NEW_debs_' .. n .. '.txt' |
696 | local nfile, e = io.open(inFile, "r") | 737 | local nfile, e = io.open(inFile, "r") |
697 | if nil == nfile then W("opening " .. inFile .. " file - " .. e) else | 738 | if nil == nfile then W("opening " .. inFile .. " file - " .. e) else |
@@ -733,7 +774,7 @@ end | |||
733 | 774 | ||
734 | local parsePackages = function(host) | 775 | local parsePackages = function(host) |
735 | local list = {inf = 'Packages', parser = parseDebs, out = 'debs', files = {}, nextf = ''} | 776 | local list = {inf = 'Packages', parser = parseDebs, out = 'debs', files = {}, nextf = ''} |
736 | for i, n in pairs(releases) do | 777 | for i, n in pairs(APT.releases) do |
737 | local inFile = 'results/NEW_' .. list.inf .. '_' .. n .. '.txt' | 778 | local inFile = 'results/NEW_' .. list.inf .. '_' .. n .. '.txt' |
738 | local outFile = 'results/NEW_' .. list.out .. '_' .. n .. '.txt' | 779 | local outFile = 'results/NEW_' .. list.out .. '_' .. n .. '.txt' |
739 | if APT.options.referenceSite.value == host then | 780 | if APT.options.referenceSite.value == host then |
@@ -755,6 +796,7 @@ local parsePackages = function(host) | |||
755 | local Pp, e = io.open('results/' .. host .. '/merged/dists/'.. n .. dir .. 'Packages.parsed', "w+") | 796 | local Pp, e = io.open('results/' .. host .. '/merged/dists/'.. n .. dir .. 'Packages.parsed', "w+") |
756 | if nil == Pp then W('opening results/' .. host .. '/merged/dists/'.. n .. dir .. 'Packages.parsed' .. ' file - ' .. e) else | 797 | if nil == Pp then W('opening results/' .. host .. '/merged/dists/'.. n .. dir .. 'Packages.parsed' .. ' file - ' .. e) else |
757 | local pp = {} | 798 | local pp = {} |
799 | -- TODO - FIX - check if this file exists first. | ||
758 | for l in io.lines('results/' .. host .. '/merged/dists/'.. n .. dir .. 'Packages') do | 800 | for l in io.lines('results/' .. host .. '/merged/dists/'.. n .. dir .. 'Packages') do |
759 | if "Package: " == l:sub(1, 9) then | 801 | if "Package: " == l:sub(1, 9) then |
760 | if 0 ~= #pp then | 802 | if 0 ~= #pp then |
@@ -786,12 +828,12 @@ local parsePackages = function(host) | |||
786 | ' | grep -E "^\\+" | grep -Ev "^\\+\\+\\+|^---" >>results/NEW_' .. list.out .. '_TMP_' .. n .. '.txt') | 828 | ' | grep -E "^\\+" | grep -Ev "^\\+\\+\\+|^---" >>results/NEW_' .. list.out .. '_TMP_' .. n .. '.txt') |
787 | for i, s in pairs(referenceDebs) do | 829 | for i, s in pairs(referenceDebs) do |
788 | if 0 == APT.exe('grep -q "' .. s:sub(8, -1) .. '" results/OLD_' .. list.out .. '_' .. n .. '.txt'):log():Do().status then | 830 | if 0 == APT.exe('grep -q "' .. s:sub(8, -1) .. '" results/OLD_' .. list.out .. '_' .. n .. '.txt'):log():Do().status then |
789 | print('Reference package is out of date (' .. n .. ') - ' .. s) | 831 | print('Reference package is out of date from ' .. host .. ' (' .. n .. ') - ' .. s) |
790 | end | 832 | end |
791 | end | 833 | end |
792 | for i, s in pairs(referenceDevs) do | 834 | for i, s in pairs(referenceDevs) do |
793 | if 0 == APT.exe('grep -q "' .. s:sub(8, -1) .. '" results/OLD_' .. list.out .. '_' .. n .. '.txt'):log():Do().status then | 835 | if 0 == APT.exe('grep -q "' .. s:sub(8, -1) .. '" results/OLD_' .. list.out .. '_' .. n .. '.txt'):log():Do().status then |
794 | print('Reference package is out of date (' .. n .. ') - ' .. s) | 836 | print('Reference package is out of date from ' .. host .. ' (' .. n .. ') - ' .. s) |
795 | end | 837 | end |
796 | end | 838 | end |
797 | else | 839 | else |
@@ -839,13 +881,13 @@ local parseRelease = function(host) | |||
839 | local list = {inf = 'Release', parser = parsePackages, out = 'Packages', files = {}, nextf = 'debs'} | 881 | local list = {inf = 'Release', parser = parsePackages, out = 'Packages', files = {}, nextf = 'debs'} |
840 | local updated = false | 882 | local updated = false |
841 | local now = tonumber(os.date('%s')) | 883 | local now = tonumber(os.date('%s')) |
842 | for i, n in pairs(releases) do | 884 | for i, n in pairs(APT.releases) do |
843 | for l, o in pairs(releaseFiles) do | 885 | for l, o in pairs(releaseFiles) do |
844 | if repoExists(i .. o) then | 886 | if repoExists(i .. o) then |
845 | postDownload(host, n, o) | 887 | postDownload(host, n, o) |
846 | if (".gpg" == o:sub(-4, -1)) and (APT.checkFile('results/' .. host .. '/merged/dists/' .. n .. '/' .. o)) then | 888 | if (".gpg" == o:sub(-4, -1)) and (APT.checkFile('results/' .. host .. '/merged/dists/' .. n .. '/' .. o)) then |
847 | if APT.testing("Integrity") then | 889 | if APT.testing("Integrity") then |
848 | local status = APT.exe( "gpgv --keyring /usr/share/keyrings/devuan-keyring.gpg results/" .. host .. "/merged/dists/" .. n .. '/' .. o .. | 890 | local status = APT.exe( "gpgv --keyring " .. keyring .. " results/" .. host .. "/merged/dists/" .. n .. '/' .. o .. |
849 | " results/" .. host .. "/merged/dists/" .. n .. '/' .. o:sub(1, -5)):Nice():noErr():log():Do().status | 891 | " results/" .. host .. "/merged/dists/" .. n .. '/' .. o:sub(1, -5)):Nice():noErr():log():Do().status |
850 | if 0 ~= status then E("GPG check failed for " .. host .. "/merged/dists/" .. n .. '/' .. o, "http", "Integrity", host) end | 892 | if 0 ~= status then E("GPG check failed for " .. host .. "/merged/dists/" .. n .. '/' .. o, "http", "Integrity", host) end |
851 | -- TODO - should check the PGP sig of InRelease as well. | 893 | -- TODO - should check the PGP sig of InRelease as well. |
@@ -922,7 +964,7 @@ end | |||
922 | 964 | ||
923 | local parseStart = function(host) | 965 | local parseStart = function(host) |
924 | local list = {inf = '', parser = parseRelease, out = 'Release', files = {}, nextf = 'Packages'} | 966 | local list = {inf = '', parser = parseRelease, out = 'Release', files = {}, nextf = 'Packages'} |
925 | for i, n in pairs(releases) do | 967 | for i, n in pairs(APT.releases) do |
926 | local outFile = 'results/NEW_' .. list.out .. '_' .. n .. '.txt' | 968 | local outFile = 'results/NEW_' .. list.out .. '_' .. n .. '.txt' |
927 | for l, o in pairs(releaseFiles) do | 969 | for l, o in pairs(releaseFiles) do |
928 | if repoExists(n .. o) then | 970 | if repoExists(n .. o) then |
@@ -991,6 +1033,7 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them. | |||
991 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to devuan.bio.lmu.de (141.84.43.19) port 80 (#0) | 1033 | 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to devuan.bio.lmu.de (141.84.43.19) port 80 (#0) |
992 | curl: (22) The requested URL returned error: 404 Not Found | 1034 | curl: (22) The requested URL returned error: 404 Not Found |
993 | ]] | 1035 | ]] |
1036 | local trace = {} | ||
994 | local min, max, spd = 999999999999, 0 | 1037 | local min, max, spd = 999999999999, 0 |
995 | local num = '[%d%.]+[kM]?' | 1038 | local num = '[%d%.]+[kM]?' |
996 | if APT.checkFile(f) then | 1039 | if APT.checkFile(f) then |
@@ -1022,7 +1065,7 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them. | |||
1022 | 1065 | ||
1023 | if (APT.options.referenceSite.value ~= host) and ('' ~= list.nextf) then | 1066 | if (APT.options.referenceSite.value ~= host) and ('' ~= list.nextf) then |
1024 | local sem = 'results/NEW_' .. list.nextf .. '_%s.txt' | 1067 | local sem = 'results/NEW_' .. list.nextf .. '_%s.txt' |
1025 | for i, n in pairs(releases) do | 1068 | for i, n in pairs(APT.releases) do |
1026 | local f = sem:format(n) | 1069 | local f = sem:format(n) |
1027 | while not APT.checkFile(f) do | 1070 | while not APT.checkFile(f) do |
1028 | D('*<* About to yield coroutine while waiting on - not APT.checkFile(' .. f .. ')') | 1071 | D('*<* About to yield coroutine while waiting on - not APT.checkFile(' .. f .. ')') |
@@ -1066,7 +1109,12 @@ if 0 < #arg then | |||
1066 | I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", ")) | 1109 | I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", ")) |
1067 | APT.mirrors = loadfile("results/mirrors.lua")() | 1110 | APT.mirrors = loadfile("results/mirrors.lua")() |
1068 | APT.results = APT.padResults(APT.results) | 1111 | APT.results = APT.padResults(APT.results) |
1069 | if APT.origin or APT.redir then APT.results["IPs"] = gatherIPs(pu.host) end | 1112 | if APT.origin or APT.redir then |
1113 | if "" == pu.host then | ||
1114 | print("Empty pu.host name! " .. pu.host) | ||
1115 | end | ||
1116 | APT.results["IPs"] = gatherIPs(pu.host) | ||
1117 | end | ||
1070 | if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end | 1118 | if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end |
1071 | if nil ~= arg[3] then I(" Using file " .. arg[3]); end | 1119 | if nil ~= arg[3] then I(" Using file " .. arg[3]); end |
1072 | 1120 | ||
@@ -1081,15 +1129,17 @@ if 0 < #arg then | |||
1081 | APT.allpairs(ips, | 1129 | APT.allpairs(ips, |
1082 | function(k, v) | 1130 | function(k, v) |
1083 | if v == "A" then | 1131 | if v == "A" then |
1084 | if APT.testing("IPv4") then APT.exe('./apt-panopticon.lua ' .. sendArgs .. ' -4 ' .. pu.host .. path .. ' ' .. k .. ' ' .. file):Nice():log():fork() end | 1132 | if APT.testing("IPv4") then APT.exe('./apt-panopticon.lua ' .. sendArgs .. ' -4 ' .. pu.host .. path .. ' ' .. k .. ' ' .. file):timeout(APT.options.maxtime.value * 2.0):Nice():log():fork(pu.host) end |
1085 | elseif v == "AAAA" then | 1133 | elseif v == "AAAA" then |
1086 | if APT.testing("IPv6") then APT.exe('./apt-panopticon.lua ' .. sendArgs .. ' -6 ' .. APT.IPv46 .. ' ' .. pu.host .. path .. ' ' .. k .. ' ' .. file):Nice():log():fork() end | 1134 | if APT.testing("IPv6") then APT.exe('./apt-panopticon.lua ' .. sendArgs .. ' -6 ' .. APT.IPv46 .. ' ' .. pu.host .. path .. ' ' .. k .. ' ' .. file):timeout(APT.options.maxtime.value * 2.0):Nice():log():fork(pu.host) end |
1087 | end | 1135 | end |
1088 | D('logging to ' .. APT.logName(pu.host, k, file)[2]) | 1136 | D('logging to ' .. APT.logName(pu.host, k, file)[2]) |
1089 | end | 1137 | end |
1090 | ) | 1138 | ) |
1091 | else | 1139 | else |
1092 | E("no IPs for " .. pu.host) | 1140 | E("no IPs for " .. pu.host) |
1141 | APT.logPost() | ||
1142 | return | ||
1093 | end | 1143 | end |
1094 | end | 1144 | end |
1095 | 1145 | ||
@@ -1178,16 +1228,15 @@ else | |||
1178 | while 1 <= APT.checkExes("apt-panopticon.lua " .. sendArgs) do os.execute("sleep 5") end | 1228 | while 1 <= APT.checkExes("apt-panopticon.lua " .. sendArgs) do os.execute("sleep 5") end |
1179 | 1229 | ||
1180 | local APT_args = APT.args | 1230 | local APT_args = APT.args |
1181 | local APT_logFile = APT.logFile | ||
1182 | local debians = {} | 1231 | local debians = {} |
1183 | local srvs = io.popen('ls -1 results/*.lua') | 1232 | local srvs = APT.readCmd('ls -1 results/*.lua') |
1184 | for l in srvs:lines() do | 1233 | for ii,l in ipairs(srvs) do |
1185 | local hst = l:sub(9, -5) | 1234 | local hst = l:sub(9, -5) |
1186 | if nil ~= l:find('_R%.lua') then hst = hst:sub(1, -3) end | 1235 | if nil ~= l:find('_R%.lua') then hst = hst:sub(1, -3) end |
1187 | if (hst:find('_') == nil) and (nil == APT.mirrors[hst]) then | 1236 | if (hst:find('_') == nil) and (nil == APT.mirrors[hst]) then |
1188 | local ips = loadfile(l)().IPs | 1237 | local ips = loadfile(l)().IPs |
1189 | if nil ~= ips then | 1238 | if nil ~= ips then |
1190 | debians[hst] = {Country = '', FDQN = hst, Active = 'yes', Rate = '', BaseURL = hst, Protocols = {http = true, https = true}, Bandwidth = '', IPs = ips} | 1239 | debians[hst] = {Country = '', FQDN = hst, Active = 'yes', Rate = '', BaseURL = hst, Protocols = {http = true, https = true}, Bandwidth = '', IPs = ips} |
1191 | local baseFiles = {} | 1240 | local baseFiles = {} |
1192 | local IPfiles = {} | 1241 | local IPfiles = {} |
1193 | for i, a in pairs(ips) do | 1242 | for i, a in pairs(ips) do |
@@ -1198,8 +1247,8 @@ else | |||
1198 | end | 1247 | end |
1199 | end | 1248 | end |
1200 | end | 1249 | end |
1201 | local files = io.popen('ls -1 results/LOG_' .. hst .. '_*.html') | 1250 | local files = APT.readCmd('ls -1 results/LOG_' .. hst .. '_*.html') |
1202 | for ll in files:lines() do | 1251 | for iii,ll in ipairs(files) do |
1203 | local dn = false | 1252 | local dn = false |
1204 | for i, a in pairs(ips) do | 1253 | for i, a in pairs(ips) do |
1205 | if type(a) == 'table' then | 1254 | if type(a) == 'table' then |
@@ -1220,6 +1269,7 @@ else | |||
1220 | end | 1269 | end |
1221 | 1270 | ||
1222 | local combine = function(ip, a) | 1271 | local combine = function(ip, a) |
1272 | local APT_logFile = APT.logFile | ||
1223 | if not APT.logOpen(hst, ip) then | 1273 | if not APT.logOpen(hst, ip) then |
1224 | print('PROBLEM OPENING LOG FILE ' .. hst .. ' ' .. ip) | 1274 | print('PROBLEM OPENING LOG FILE ' .. hst .. ' ' .. ip) |
1225 | else | 1275 | else |
@@ -1231,8 +1281,8 @@ else | |||
1231 | if ln:match('^' .. os.date('!%Y%-%m%-%d ') .. '.*$') then APT.logFile:write(ln .. '\n') end -- %F isn't good enough, coz we have to escape the '-'. | 1281 | if ln:match('^' .. os.date('!%Y%-%m%-%d ') .. '.*$') then APT.logFile:write(ln .. '\n') end -- %F isn't good enough, coz we have to escape the '-'. |
1232 | end | 1282 | end |
1233 | end | 1283 | end |
1284 | APT.logPost() | ||
1234 | end | 1285 | end |
1235 | APT.logPost() | ||
1236 | APT.args = APT_args | 1286 | APT.args = APT_args |
1237 | APT.logFile = APT_logFile | 1287 | APT.logFile = APT_logFile |
1238 | end | 1288 | end |