diff options
| author | onefang | 2019-12-31 00:26:08 +1000 |
|---|---|---|
| committer | onefang | 2019-12-31 00:26:08 +1000 |
| commit | c0551dd8cf8d777f3138265f9d8aee916da63ae9 (patch) | |
| tree | e49170542612ceaf56b099e9d0863a9a6715a88f | |
| parent | Don't follow the rabbit down the rabbit hole if we are just doing low bandwid... (diff) | |
| download | apt-panopticon-c0551dd8cf8d777f3138265f9d8aee916da63ae9.zip apt-panopticon-c0551dd8cf8d777f3138265f9d8aee916da63ae9.tar.gz apt-panopticon-c0551dd8cf8d777f3138265f9d8aee916da63ae9.tar.bz2 apt-panopticon-c0551dd8cf8d777f3138265f9d8aee916da63ae9.tar.xz | |
Check redirects we must do, and ones we must not, and more avoiding the rabbit hole.
| -rwxr-xr-x | apt-panopticon.lua | 17 |
1 files 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) | |||
| 348 | end | 348 | end |
| 349 | I(spcd .. spcd .. code .. " " .. cstr .. ". " .. check .. " " .. APT.lnk(URL), host) | 349 | I(spcd .. spcd .. code .. " " .. cstr .. ". " .. check .. " " .. APT.lnk(URL), host) |
| 350 | -- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. | 350 | -- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. |
| 351 | if (1 <= APT.options.bandwidth.value) and (nil ~= location) then | 351 | if nil ~= location then |
| 352 | pu = url.parse(location, defaultURL) | 352 | pu = url.parse(location, defaultURL) |
| 353 | if (pu.host == APT.options.roundRobin.value) and (nil ~= PU.path:find('merged/pool/DEVUAN/')) then | ||
| 354 | E('DEVUAN packages must not be redirected to ' .. APT.options.roundRobin.value .. ' - ' .. APT.lnk(URL) .. arw .. APT.lnk(location), PU.scheme, sanity, host) | ||
| 355 | end | ||
| 353 | 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 ('http' == location:sub(1, 4)) and (pu.scheme ~= PU.scheme) then -- Sometimes a location sans scheme is returned, this is not a protocol change. |
| 354 | if APT.testing("Protocol") then | 357 | if APT.testing("Protocol") then |
| 355 | if APT.options.roundRobin.value == host then -- Coz HTTPS shouldn't happen via the round robin. | 358 | 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) | |||
| 364 | E(spcd .. spcd .. "Redirect loop! " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), PU.scheme, "", host) | 367 | E(spcd .. spcd .. "Redirect loop! " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), PU.scheme, "", host) |
| 365 | elseif nil == pu.host then | 368 | elseif nil == pu.host then |
| 366 | I(spcd .. spcd .. "Relative redirect. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) | 369 | I(spcd .. spcd .. "Relative redirect. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) |
| 367 | checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1, retry, '' ~= sanity) | 370 | if 1 <= APT.options.bandwidth.value then checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1, retry, '' ~= sanity) end |
| 368 | elseif (PU.host == pu.host) or (host == pu.host) then | 371 | elseif (PU.host == pu.host) or (host == pu.host) then |
| 372 | if PU.host ~= host then | ||
| 373 | local t = pu.host | ||
| 374 | pu.host = PU.host | ||
| 375 | location = url.build(pu) | ||
| 376 | pu.host = t | ||
| 377 | end | ||
| 369 | I(spcd .. spcd .. "Redirect to same host. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) | 378 | I(spcd .. spcd .. "Redirect to same host. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) |
| 370 | checkHEAD(pu.host, location, r + 1, retry, '' ~= sanity) | 379 | if 1 <= APT.options.bandwidth.value then checkHEAD(host, location, r + 1, retry, '' ~= sanity) end |
| 371 | else | 380 | else |
| 372 | I(spcd .. spcd .. "Redirect to different host. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) | 381 | I(spcd .. spcd .. "Redirect to different host. " .. check .. " " .. APT.lnk(URL) .. arw .. APT.lnk(location), host) |
| 373 | if 1 <= APT.options.bandwidth.value then | 382 | if 1 <= APT.options.bandwidth.value then |
| @@ -389,6 +398,8 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
| 389 | D(spcd .. 'logging to ' .. APT.logName(pu.host, nil, file)[2]) | 398 | D(spcd .. 'logging to ' .. APT.logName(pu.host, nil, file)[2]) |
| 390 | end | 399 | end |
| 391 | end | 400 | end |
| 401 | elseif nil ~= PU.path:find('merged/pool/DEBIAN-SECURITY/') then | ||
| 402 | W('DEBIAN-SECURITY packages must be redirected to a Debian mirror - ' .. APT.lnk(URL) .. arw .. APT.lnk(location), PU.scheme, sanity, host) | ||
| 392 | end | 403 | end |
| 393 | end | 404 | end |
| 394 | end | 405 | end |
