aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mirror-checker.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xmirror-checker.lua47
1 files changed, 16 insertions, 31 deletions
diff --git a/mirror-checker.lua b/mirror-checker.lua
index 197e6c1..aada1e2 100755
--- a/mirror-checker.lua
+++ b/mirror-checker.lua
@@ -251,39 +251,24 @@ local execute = function (s)
251 os.execute(s) 251 os.execute(s)
252end 252end
253 253
254forkIP = function (orig, host) 254checkRedirects = function (orig, host, path, ip)
255 if nil == host then host = orig end
256 local po = url.parse("http://" .. orig, defaultURL)
257 local ph = url.parse("http://" .. host, defaultURL)
258 gatherIPs(ph.host)
259 for k, v in pairs(IP[ph.host]) do
260 D("DNS record " .. v .. " " .. k .. " for " .. ph.host)
261 if v == "A" then
262 if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. " " .. k .. " &") end
263 elseif v == "AAAA" then
264 if testing("IPv6") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. " [" .. k .. "] &") end
265 elseif v == "CNAME" then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. k .. " &")
266 forkIP(orig, k) -- Check the original as well as the CNAME, so they both get checked.
267 end
268 end
269end
270
271checkHost = function (orig, host, path, ip)
272 if nil == host then host = orig end 255 if nil == host then host = orig end
273 if nil == path then path = "" end 256 if nil == path then path = "" end
257 local po = url.parse("http://" .. orig)
258 local ph = url.parse("http://" .. host)
274 if nil ~= ip then 259 if nil ~= ip then
275 checkPaths(orig, ip, path) 260 checkPaths(po.host, ip, path)
276 else 261 else
277 D("checkHost " .. orig .. " " .. host) 262 if orig == host then D("checkRedirects " .. orig) else D("checkRedirects " .. orig .. " " .. host) end
278 gatherIPs(host) 263 gatherIPs(ph.host)
279 for k, v in pairs(IP[host]) do 264 for k, v in pairs(IP[ph.host]) do
280 D("DNS record " .. v .. " " .. k .. " for " .. host) 265 D("DNS record " .. v .. " " .. ph.host .. " -> " .. k)
281 if v == "A" then 266 if v == "A" then
282 if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " " .. k .. " &") end 267 if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " " .. k .. " &") end
283 elseif v == "AAAA" then 268 elseif v == "AAAA" then
284 if testing("IPv6") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " [" .. k .. "] &") end 269 if testing("IPv6") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " [" .. k .. "] &") end
285 elseif v == "CNAME" then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. k .. path .. " &") 270 elseif v == "CNAME" then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. k .. path .. " &")
286 checkHost(orig, k, path) -- Check the original, with the DNS records from the CNAME, as well as the CNAME, so they both get checked. 271 checkRedirects(orig, k, path) -- Check the original, with the DNS records from the CNAME, as well as the CNAME, so they both get checked.
287 end 272 end
288 end 273 end
289 end 274 end
@@ -434,7 +419,7 @@ if 0 < #arg then
434 checkExes("mirror-checker.lua " .. sendArgs) 419 checkExes("mirror-checker.lua " .. sendArgs)
435 checkExes(downloadLock) 420 checkExes(downloadLock)
436 end 421 end
437 checkHost(pu.host, pu.host, pu.path, arg[2]) 422 checkRedirects(pu.host, pu.host, pu.path, arg[2])
438 logFile:close() 423 logFile:close()
439else 424else
440 if not keep then os.execute("rm -f results/*.log") end 425 if not keep then os.execute("rm -f results/*.log") end
@@ -444,18 +429,18 @@ else
444 execute("mkdir -p results") 429 execute("mkdir -p results")
445 local mirrors = getMirrors() 430 local mirrors = getMirrors()
446 mirrors[options.referenceSite.value] = nil 431 mirrors[options.referenceSite.value] = nil
447-- checkHost(options.referenceSite.value) 432 checkRedirects(options.referenceSite.value)
448 forkIP(options.referenceSite.value) 433-- forkIP(options.referenceSite.value)
449-- checkHost("deb.devuan.org") 434 checkRedirects("deb.devuan.org")
450 forkIP("deb.devuan.org") 435-- forkIP("deb.devuan.org")
451 for k, m in pairs(mirrors) do 436 for k, m in pairs(mirrors) do
452 if "/" == m.BaseURL:sub(-1, -1) then 437 if "/" == m.BaseURL:sub(-1, -1) then
453 W("slash at end of BaseURL in mirror_list.txt! " .. m.BaseURL) 438 W("slash at end of BaseURL in mirror_list.txt! " .. m.BaseURL)
454 m.BaseURL = m.BaseURL:sub(1, -2) 439 m.BaseURL = m.BaseURL:sub(1, -2)
455 end 440 end
456 local pu = url.parse("http://" .. m.BaseURL, defaultURL) 441 local pu = url.parse("http://" .. m.BaseURL, defaultURL)
457-- checkHost(pu.host) 442 checkRedirects(m.BaseURL)
458 forkIP(m.BaseURL) 443-- forkIP(m.BaseURL)
459 checkExes("mirror-checker.lua " .. sendArgs) 444 checkExes("mirror-checker.lua " .. sendArgs)
460 if testing("Integrity") or testing("Updated") then checkExes(downloadLock) end 445 if testing("Integrity") or testing("Updated") then checkExes(downloadLock) end
461 end 446 end