From c0551dd8cf8d777f3138265f9d8aee916da63ae9 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 31 Dec 2019 00:26:08 +1000 Subject: Check redirects we must do, and ones we must not, and more avoiding the rabbit hole. --- apt-panopticon.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apt-panopticon.lua b/apt-panopticon.lua index d71ab1d..ede6b6b 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -348,8 +348,11 @@ checkHEAD = function (host, URL, r, retry, sanity) end I(spcd .. spcd .. code .. " " .. cstr .. ". " .. check .. " " .. APT.lnk(URL), host) -- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. - if (1 <= APT.options.bandwidth.value) and (nil ~= location) then + if nil ~= location then pu = url.parse(location, defaultURL) + if (pu.host == APT.options.roundRobin.value) and (nil ~= PU.path:find('merged/pool/DEVUAN/')) then + E('DEVUAN packages must not be redirected to ' .. APT.options.roundRobin.value .. ' - ' .. APT.lnk(URL) .. arw .. APT.lnk(location), PU.scheme, sanity, host) + end 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. if APT.testing("Protocol") then if APT.options.roundRobin.value == host then -- Coz HTTPS shouldn't happen via the round robin. @@ -364,10 +367,16 @@ checkHEAD = function (host, URL, r, retry, sanity) E(spcd .. spcd .. "Redirect loop! " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), PU.scheme, "", host) elseif nil == pu.host then I(spcd .. spcd .. "Relative redirect. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) - checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1, retry, '' ~= sanity) + if 1 <= APT.options.bandwidth.value then checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1, retry, '' ~= sanity) end elseif (PU.host == pu.host) or (host == pu.host) then + if PU.host ~= host then + local t = pu.host + pu.host = PU.host + location = url.build(pu) + pu.host = t + end I(spcd .. spcd .. "Redirect to same host. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) - checkHEAD(pu.host, location, r + 1, retry, '' ~= sanity) + if 1 <= APT.options.bandwidth.value then checkHEAD(host, location, r + 1, retry, '' ~= sanity) end else I(spcd .. spcd .. "Redirect to different host. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) if 1 <= APT.options.bandwidth.value then @@ -389,6 +398,8 @@ checkHEAD = function (host, URL, r, retry, sanity) D(spcd .. 'logging to ' .. APT.logName(pu.host, nil, file)[2]) end end + elseif nil ~= PU.path:find('merged/pool/DEBIAN-SECURITY/') then + W('DEBIAN-SECURITY packages must be redirected to a Debian mirror - ' .. APT.lnk(URL) .. arw .. APT.lnk(location), PU.scheme, sanity, host) end end end -- cgit v1.1