From cd9157a9a9b2b4e99d2ea1e69110e361a4c70f42 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 31 Dec 2019 00:24:47 +1000 Subject: Don't follow the rabbit down the rabbit hole if we are just doing low bandwidth tests. --- apt-panopticon.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/apt-panopticon.lua b/apt-panopticon.lua index d4bba5e..d71ab1d 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -370,22 +370,24 @@ checkHEAD = function (host, URL, r, retry, sanity) checkHEAD(pu.host, location, r + 1, retry, '' ~= sanity) else I(spcd .. spcd .. "Redirect to different host. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) - --[[ The hard part here is that we end up throwing ALL of the test files at the redirected location. - Not good for deb.debian.org, which we should only be throwing .debs at. - What we do is loop through the DNS entries, and only test the specific protocol & file being tested here. - ]] - local u = pu.host .. "/" .. pu.path - local file = pu.path:match(".*/([%w%.%+%-_]*)$") -- Get the filename. - local path = pu.path:sub(2, -1 -(#file)) - local check = u:gsub("/", "_") - local extraArgs = sendArgs .. ' -o -r ' - if 'https' == pu.scheme then extraArgs = extraArgs .. ' --tests=-http' end - if 'http' == pu.scheme then extraArgs = extraArgs .. ' --tests=-https' end - local pth = path:match('^(.*/pool/).*$') - if nil ~= pth then table.insert(APT.results[PU.scheme].redirects, pu.host .. "/" .. pth) else E(spcd .. spcd .. 'Odd redirect path ' .. path) end - I(spcd .. spcd .. "Now checking redirected host " .. u .. '   for   ' .. APT.lnk(URL) .. arw .. APT.lnk(location), host) - APT.exe(downloadLock .. "REDIR-" .. check .. ".log.txt" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file):Nice():log():fork() - D(spcd .. 'logging to ' .. APT.logName(pu.host, nil, file)[2]) + if 1 <= APT.options.bandwidth.value then + --[[ The hard part here is that we end up throwing ALL of the test files at the redirected location. + Not good for deb.debian.org, which we should only be throwing .debs at. + What we do is loop through the DNS entries, and only test the specific protocol & file being tested here. + ]] + local u = pu.host .. "/" .. pu.path + local file = pu.path:match(".*/([%w%.%+%-_]*)$") -- Get the filename. + local path = pu.path:sub(2, -1 -(#file)) + local check = u:gsub("/", "_") + local extraArgs = sendArgs .. ' -o -r ' + if 'https' == pu.scheme then extraArgs = extraArgs .. ' --tests=-http' end + if 'http' == pu.scheme then extraArgs = extraArgs .. ' --tests=-https' end + local pth = path:match('^(.*/pool/).*$') + if nil ~= pth then table.insert(APT.results[PU.scheme].redirects, pu.host .. "/" .. pth) else E(spcd .. spcd .. 'Odd redirect path ' .. path) end + I(spcd .. spcd .. "Now checking redirected host " .. u .. '   for   ' .. APT.lnk(URL) .. arw .. APT.lnk(location), host) + APT.exe(downloadLock .. "REDIR-" .. check .. ".log.txt" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file):Nice():log():fork() + D(spcd .. 'logging to ' .. APT.logName(pu.host, nil, file)[2]) + end end end end -- cgit v1.1