aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mirror-checker.lua
diff options
context:
space:
mode:
Diffstat (limited to 'mirror-checker.lua')
-rwxr-xr-xmirror-checker.lua22
1 files changed, 11 insertions, 11 deletions
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)
197 return r and table.concat(t), e 197 return r and table.concat(t), e
198end 198end
199 199
200checkURL = function (host, URL, r, retry) 200checkHEAD = function (host, URL, r, retry)
201 if nil == r then r = 0 end 201 if nil == r then r = 0 end
202 if nil == retry then retry = 0 end 202 if nil == retry then retry = 0 end
203 local check = "Checking file" 203 local check = "Checking file"
@@ -249,7 +249,7 @@ checkURL = function (host, URL, r, retry)
249 E(" " .. c .. " " .. s .. "! " .. check .. " " .. host .. " -> " .. URL) 249 E(" " .. c .. " " .. s .. "! " .. check .. " " .. host .. " -> " .. URL)
250 -- So far the only errors are "timeout", "Network is unreachable", and "closed", and I suspect "closed" is due to saturating my bandwidth. 250 -- So far the only errors are "timeout", "Network is unreachable", and "closed", and I suspect "closed" is due to saturating my bandwidth.
251 -- Might be worthwhile retrying those, some number of times. 251 -- Might be worthwhile retrying those, some number of times.
252 if ("closed" == c) or ("Network is unreachable" == c) or ("timeout" == c) then checkURL(host, URL, r, retry + 1) end 252 if ("closed" == c) or ("Network is unreachable" == c) or ("timeout" == c) then checkHEAD(host, URL, r, retry + 1) end
253 else 253 else
254 if ("4" == tostring(c):sub(1, 1)) or ("5" == tostring(c):sub(1, 1)) then 254 if ("4" == tostring(c):sub(1, 1)) or ("5" == tostring(c):sub(1, 1)) then
255 E(" " .. c .. " " .. s .. ". " .. check .. " " .. host .. " -> " .. URL) 255 E(" " .. c .. " " .. s .. ". " .. check .. " " .. host .. " -> " .. URL)
@@ -267,9 +267,9 @@ checkURL = function (host, URL, r, retry)
267 E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL) 267 E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL)
268 elseif nil == pu.host then 268 elseif nil == pu.host then
269 W(" no location host! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l) 269 W(" no location host! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l)
270 checkURL(host, PU.scheme .. "://" .. PU.host .. l, r + 1) 270 checkHEAD(host, PU.scheme .. "://" .. PU.host .. l, r + 1)
271 else 271 else
272 checkURL(pu.host, l, r + 1) 272 checkHEAD(pu.host, l, r + 1)
273 end 273 end
274 end 274 end
275 end 275 end
@@ -279,20 +279,20 @@ local checkPaths = function (host, ip, path, file)
279 if nil ~= file then 279 if nil ~= file then
280 if "redirect" == ip then ip = host end 280 if "redirect" == ip then ip = host end
281 I(" Checking IP for file " .. host .. " -> " .. ip .. " " .. path .. " " .. file) 281 I(" Checking IP for file " .. host .. " -> " .. ip .. " " .. path .. " " .. file)
282 if testing("http", host) then checkURL(host, "http://" .. ip .. path .. "/" .. file) end 282 if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/" .. file) end
283 if testing("https", host) then checkURL(host, "https://" .. ip .. path .. "/" .. file) end 283 if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/" .. file) end
284 else 284 else
285 I(" Checking IP " .. host .. " -> " .. ip .. " " .. path) 285 I(" Checking IP " .. host .. " -> " .. ip .. " " .. path)
286 for i, s in pairs(referenceDevs) do 286 for i, s in pairs(referenceDevs) do
287 if testing("http", host) then checkURL(host, "http://" .. ip .. path .. "/" .. s) end 287 if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/" .. s) end
288 if testing("https", host) then checkURL(host, "https://" .. ip .. path .. "/" .. s) end 288 if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/" .. s) end
289 end 289 end
290 290
291 for i, s in pairs(releases) do 291 for i, s in pairs(releases) do
292 for j, k in pairs(releaseFiles) do 292 for j, k in pairs(releaseFiles) do
293 if repoExists(s .. k) then 293 if repoExists(s .. k) then
294 if testing("http", host) then checkURL(host, "http://" .. ip .. path .. "/merged/dists/" .. s .. k) end 294 if testing("http", host) then checkHEAD(host, "http://" .. ip .. path .. "/merged/dists/" .. s .. k) end
295 if testing("https", host) then checkURL(host, "https://" .. ip .. path .. "/merged/dists/" .. s .. k) end 295 if testing("https", host) then checkHEAD(host, "https://" .. ip .. path .. "/merged/dists/" .. s .. k) end
296 end 296 end
297 end 297 end
298 end 298 end
@@ -308,9 +308,9 @@ checkRedirects = function (orig, host, path, ip, file)
308 if nil == host then host = orig end 308 if nil == host then host = orig end
309 if nil == path then path = "" end 309 if nil == path then path = "" end
310 if nil == file then file = "" end 310 if nil == file then file = "" end
311 local po = url.parse("http://" .. orig)
312 local ph = url.parse("http://" .. host) 311 local ph = url.parse("http://" .. host)
313 if (nil ~= ip) and ("redir" ~= ip) then 312 if (nil ~= ip) and ("redir" ~= ip) then
313 local po = url.parse("http://" .. orig)
314 if "" ~= file then 314 if "" ~= file then
315 D("checking redirected file " .. po.host .. " " .. file) 315 D("checking redirected file " .. po.host .. " " .. file)
316 checkPaths(po.host, ip, path, file) 316 checkPaths(po.host, ip, path, file)