From fbd53b3ef35ced9589f77aae34313016412de195 Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 29 Sep 2019 12:29:48 +1000 Subject: checkRedirects -> checkHost --- README.md | 18 +++++++++--------- mirror-checker.lua | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index fe62f04..347049b 100644 --- a/README.md +++ b/README.md @@ -190,19 +190,19 @@ Active mirrors keyed by the FDQN, include the listed Protocols as a sub table. Write this table to results/mirrors.lua so that the forked tests can read it. -Remove the mirror site from the mirrors table, then checkRedirects() it +Remove the mirror site from the mirrors table, then checkHost() it first. -checkRedirects() deb.devuan.org, the DNS RR. +checkHost() deb.devuan.org, the DNS RR. -Loop through the mirrors table, and checkRedirects() each one. +Loop through the mirrors table, and checkHost() each one. Wait for all forked tests to finish. Delete results/*.check. -The checkRedirects() function does this - +The checkHost() function does this - If there is no second argument, then the host is set to the first argument, otherwise the host is the second argument. @@ -222,7 +222,7 @@ ionice -c3 ./mirror-checker.lua example.com/path x.x.x.x & ionice -c3 ./mirror-checker.lua example.com/path [x:x:x:x:x:x] & -For each CNAME, it checkRedirects() the host, but with the CNAME as a +For each CNAME, it checkHost() the host, but with the CNAME as a second argument. SRV reconds don't do anything yet, coz I have yet to see one from my test @@ -241,9 +241,9 @@ directory, downloads the reference files using wget. While it should actually perform the Integrity and Updated tests now, those haven't been written yet. Note that currently this downloads 4GB per mirror. -Calls checkRedirects() with the host as first and second arguments, and +Calls checkHost() with the host as first and second arguments, and includes the IP this time. The inclusion of the IP causes -checkRedirects() to call checkFiles(). +checkHost() to call checkFiles(). checkFiles() will call checkHEAD() for each of the reference files. @@ -253,7 +253,7 @@ checkHEAD() uses LuaSocket (or LuaSec for HTTPS) to send a HEAD request to the IP, with a Host header set to the original host name. Redirects will not be followed by that request. If the request returns a redirect, then checkHEAD() is called recursively. If the redirect is to some host we are -not already checking, we call checkRedirects() on it, with an IP of -"redir". This causes checkRedirects() to bypass the test that would +not already checking, we call checkHost() on it, with an IP of +"redir". This causes checkHost() to bypass the test that would otherwise call checkFiles(), instead gathering the IPs and fork as usual. diff --git a/mirror-checker.lua b/mirror-checker.lua index f443789..81b32db 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua @@ -215,7 +215,7 @@ checkHEAD = function (host, URL, r, retry) local f = io.popen(string.format('if [ ! -f results/%s.check ] ; then touch results/%s.check; echo -n "check"; fi', file:gsub("/", "_"), file:gsub("/", "_") )):read("*a") if (nil == f) or ("check" == f) then I(" Now checking redirected host " .. file) - checkRedirects(host, host, nil, "redir", pl.path) + checkHost(host, host, nil, "redir", pl.path) else D(" Already checking " .. file) end @@ -304,7 +304,7 @@ local execute = function (s) os.execute(s) end -checkRedirects = function (orig, host, path, ip, file) +checkHost = 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 @@ -318,7 +318,7 @@ checkRedirects = function (orig, host, path, ip, file) checkFiles(po.host, ip, path) end else - if orig == host then D("checkRedirects " .. orig .. "" .. file) else D("checkRedirects " .. orig .. " -> " .. host) end + if orig == host then D("checkHost " .. orig .. "" .. file) else D("checkHost " .. orig .. " -> " .. host) end -- TODO - use checkFiles() here ^^^ on the original domain name, coz that's not getting caught yet. I think. gatherIPs(ph.host) for k, v in pairs(IP[ph.host]) do @@ -328,7 +328,7 @@ checkRedirects = function (orig, host, path, ip, file) elseif v == "AAAA" then if testing("IPv6") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " [" .. k .. "] " .. file .. " &") end elseif v == "CNAME" then - checkRedirects(orig, k, path, ip, file) -- Check the original, with the DNS records from the CNAME. Do not check the CNAME, it's just a source of IPs. + checkHost(orig, k, path, ip, file) -- Check the original, with the DNS records from the CNAME. Do not check the CNAME, it's just a source of IPs. elseif v == "SRV" then print("SVR record found, now what do we do?") end @@ -510,7 +510,7 @@ if 0 < #arg then checkExes(downloadLock) end end - checkRedirects(pu.host, pu.host, pu.path, arg[2], arg[3]) + checkHost(pu.host, pu.host, pu.path, arg[2], arg[3]) logFile:close() else if not keep then os.execute("rm -f results/*.log") end @@ -523,9 +523,9 @@ else mirrors = getMirrors() --print(dumpTable(mirrors, "", "mirrors")) mirrors[options.referenceSite.value] = nil - checkRedirects(options.referenceSite.value) + checkHost(options.referenceSite.value) -- forkIP(options.referenceSite.value) - checkRedirects("deb.devuan.org") + checkHost("deb.devuan.org") -- forkIP("deb.devuan.org") for k, m in pairs(mirrors) do if "/" == m.BaseURL:sub(-1, -1) then @@ -533,7 +533,7 @@ else m.BaseURL = m.BaseURL:sub(1, -2) end local pu = url.parse("http://" .. m.BaseURL) - checkRedirects(m.BaseURL) + checkHost(m.BaseURL) -- forkIP(m.BaseURL) checkExes("mirror-checker.lua " .. sendArgs) if testing("Integrity") or testing("Updated") then checkExes(downloadLock) end -- cgit v1.1