diff options
author | onefang | 2019-11-05 00:07:43 +1000 |
---|---|---|
committer | onefang | 2019-11-05 00:07:43 +1000 |
commit | 4a1763099ece00cf0d462a3caca4421cf0a14bc4 (patch) | |
tree | 6bff6cbf3b0a71bbe4ccfd25d968774211880b84 | |
parent | Oops, missed a line in the --roundRobin commit. (diff) | |
download | apt-panopticon-4a1763099ece00cf0d462a3caca4421cf0a14bc4.zip apt-panopticon-4a1763099ece00cf0d462a3caca4421cf0a14bc4.tar.gz apt-panopticon-4a1763099ece00cf0d462a3caca4421cf0a14bc4.tar.bz2 apt-panopticon-4a1763099ece00cf0d462a3caca4421cf0a14bc4.tar.xz |
Gather the IPs and stuff them into mirrors.lua before forking.
Diffstat (limited to '')
-rw-r--r-- | README.md | 5 | ||||
-rwxr-xr-x | mirror-checker.lua | 39 |
2 files changed, 30 insertions, 14 deletions
@@ -191,8 +191,9 @@ Open results/mirror-checker-lua.log for message logging. | |||
191 | 191 | ||
192 | Download mirror_list.txt from the reference site. Build a table of | 192 | Download mirror_list.txt from the reference site. Build a table of |
193 | Active mirrors keyed by the FDQN, include the listed Protocols as a sub | 193 | Active mirrors keyed by the FDQN, include the listed Protocols as a sub |
194 | table. Write this table to results/mirrors.lua so that the forked tests | 194 | table. Add the round robin domain name. Resolve all the IPs and add |
195 | can read it. | 195 | them to this table. Write this table to results/mirrors.lua so that the |
196 | forked tests can read it. | ||
196 | 197 | ||
197 | Remove the mirror site from the mirrors table, then checkHost() it | 198 | Remove the mirror site from the mirrors table, then checkHost() it |
198 | first. | 199 | first. |
diff --git a/mirror-checker.lua b/mirror-checker.lua index f4b5142..6580190 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua | |||
@@ -182,7 +182,7 @@ local repoExists = function (r) | |||
182 | end | 182 | end |
183 | 183 | ||
184 | local IP = {} | 184 | local IP = {} |
185 | local gatherIPs = function (host) | 185 | gatherIPs = function (host) |
186 | if nil == IP[host] then | 186 | if nil == IP[host] then |
187 | local IPs | 187 | local IPs |
188 | local dig = io.popen('dig +keepopen +noall +nottlid +answer ' .. host .. ' A ' .. host .. ' AAAA ' .. host .. ' CNAME ' .. host .. ' SRV | sort -r | uniq') | 188 | local dig = io.popen('dig +keepopen +noall +nottlid +answer ' .. host .. ' A ' .. host .. ' AAAA ' .. host .. ' CNAME ' .. host .. ' SRV | sort -r | uniq') |
@@ -193,6 +193,13 @@ local gatherIPs = function (host) | |||
193 | if "." == v:sub(-1, -1) then v = v:sub(1, -2) end | 193 | if "." == v:sub(-1, -1) then v = v:sub(1, -2) end |
194 | if nil == IP[k] then IP[k] = {} end | 194 | if nil == IP[k] then IP[k] = {} end |
195 | IP[k][v] = t | 195 | IP[k][v] = t |
196 | D(" DNS record " .. host .. " == " .. k .. " type " .. t .. " -> " .. v) | ||
197 | if t == "CNAME" then | ||
198 | gatherIPs(v) | ||
199 | IP[k][v] = IP[v] | ||
200 | elseif v == "SRV" then | ||
201 | print("SVR record found, now what do we do?") | ||
202 | end | ||
196 | end | 203 | end |
197 | end | 204 | end |
198 | until nil == IPs | 205 | until nil == IPs |
@@ -349,17 +356,23 @@ checkHost = function (orig, host, path, ip, file) | |||
349 | D("checkHost " .. orig .. "" .. file) | 356 | D("checkHost " .. orig .. "" .. file) |
350 | if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " -o " .. orig .. path .. " " .. file .." &") end | 357 | if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " -o " .. orig .. path .. " " .. file .." &") end |
351 | else D("checkHost " .. orig .. " -> " .. host) end | 358 | else D("checkHost " .. orig .. " -> " .. host) end |
352 | gatherIPs(ph.host) | 359 | local h = mirrors[ph.host] |
353 | for k, v in pairs(IP[ph.host]) do | 360 | if nil == h then return end |
354 | D(" DNS record " .. v .. " " .. ph.host .. " -> " .. k) | 361 | for k, v in pairs(h.IPs) do |
355 | if v == "A" then | 362 | if "table" == type(v) then |
356 | if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " " .. k .. " " .. file .." &") end | 363 | for k1, v1 in pairs(v) do |
357 | elseif v == "AAAA" then | 364 | if v1 == "A" then |
358 | if testing("IPv6") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " [" .. k .. "] " .. file .. " &") end | 365 | if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " " .. k1 .. " " .. file .." &") end |
359 | elseif v == "CNAME" then | 366 | elseif v1 == "AAAA" then |
360 | 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. | 367 | if testing("IPv6") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " [" .. k1 .. "] " .. file .. " &") end |
361 | elseif v == "SRV" then | 368 | end |
362 | print("SVR record found, now what do we do?") | 369 | end |
370 | else | ||
371 | if v == "A" then | ||
372 | if testing("IPv4") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " " .. k .. " " .. file .." &") end | ||
373 | elseif v == "AAAA" then | ||
374 | if testing("IPv6") then execute("ionice -c3 ./mirror-checker.lua " .. sendArgs .. " " .. orig .. path .. " [" .. k .. "] " .. file .. " &") end | ||
375 | end | ||
363 | end | 376 | end |
364 | end | 377 | end |
365 | end | 378 | end |
@@ -410,6 +423,8 @@ local getMirrors = function () | |||
410 | end | 423 | end |
411 | host = d | 424 | host = d |
412 | m[t] = d | 425 | m[t] = d |
426 | gatherIPs(host) | ||
427 | m["IPs"] = IP[host] | ||
413 | elseif "Protocols" == t then | 428 | elseif "Protocols" == t then |
414 | local prot = {} | 429 | local prot = {} |
415 | for w in d:gmatch("(%w+)") do | 430 | for w in d:gmatch("(%w+)") do |