From e14629329f64f01073383398aac311ea27fbe32f Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 29 Sep 2019 12:25:45 +1000 Subject: checkURL -> checkHEAD --- mirror-checker.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'mirror-checker.lua') diff --git a/mirror-checker.lua b/mirror-checker.lua index b2d1cc7..23c7e33 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua @@ -197,7 +197,7 @@ local nlst = function (u) return r and table.concat(t), e end -checkURL = function (host, URL, r, retry) +checkHEAD = function (host, URL, r, retry) if nil == r then r = 0 end if nil == retry then retry = 0 end local check = "Checking file" @@ -249,7 +249,7 @@ checkURL = function (host, URL, r, retry) E(" " .. c .. " " .. s .. "! " .. check .. " " .. host .. " -> " .. URL) -- So far the only errors are "timeout", "Network is unreachable", and "closed", and I suspect "closed" is due to saturating my bandwidth. -- Might be worthwhile retrying those, some number of times. - if ("closed" == c) or ("Network is unreachable" == c) or ("timeout" == c) then checkURL(host, URL, r, retry + 1) end + if ("closed" == c) or ("Network is unreachable" == c) or ("timeout" == c) then checkHEAD(host, URL, r, retry + 1) end else if ("4" == tostring(c):sub(1, 1)) or ("5" == tostring(c):sub(1, 1)) then E(" " .. c .. " " .. s .. ". " .. check .. " " .. host .. " -> " .. URL) @@ -267,9 +267,9 @@ checkURL = function (host, URL, r, retry) E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL) elseif nil == pu.host then W(" no location host! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l) - checkURL(host, PU.scheme .. "://" .. PU.host .. l, r + 1) + checkHEAD(host, PU.scheme .. "://" .. PU.host .. l, r + 1) else - checkURL(pu.host, l, r + 1) + checkHEAD(pu.host, l, r + 1) end end end @@ -279,20 +279,20 @@ local checkPaths = function (host, ip, path, file) if nil ~= file then if "redirect" == ip then ip = host end I(" Checking IP for file " .. host .. " -> " .. ip .. " " .. path .. " " .. file) - if testing("http", host) then checkURL(host, "http://" .. ip .. path .. "/" .. file) end - if testing("https", host) then checkURL(host, "https://" .. ip .. path .. "/" .. file) end + if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/" .. file) end + if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/" .. file) end else I(" Checking IP " .. host .. " -> " .. ip .. " " .. path) for i, s in pairs(referenceDevs) do - if testing("http", host) then checkURL(host, "http://" .. ip .. path .. "/" .. s) end - if testing("https", host) then checkURL(host, "https://" .. ip .. path .. "/" .. s) end + if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/" .. s) end + if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/" .. s) end end for i, s in pairs(releases) do for j, k in pairs(releaseFiles) do if repoExists(s .. k) then - if testing("http", host) then checkURL(host, "http://" .. ip .. path .. "/merged/dists/" .. s .. k) end - if testing("https", host) then checkURL(host, "https://" .. ip .. path .. "/merged/dists/" .. s .. k) end + if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/merged/dists/" .. s .. k) end + if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/merged/dists/" .. s .. k) end end end end @@ -308,9 +308,9 @@ checkRedirects = function (orig, host, path, ip, file) if nil == host then host = orig end if nil == path then path = "" end if nil == file then file = "" end - local po = url.parse("http://" .. orig) local ph = url.parse("http://" .. host) if (nil ~= ip) and ("redir" ~= ip) then + local po = url.parse("http://" .. orig) if "" ~= file then D("checking redirected file " .. po.host .. " " .. file) checkPaths(po.host, ip, path, file) -- cgit v1.1