From 9c9226dced67b0e18fbc67cd31ccda585f39b322 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 1 Jan 2020 19:03:15 +1000 Subject: Curl will try IPv4 as a backup if IPv6 fails, and we don't want that. Tell it not to. Also detect if IPv6 is even available. --- apt-panopticon.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apt-panopticon.lua') diff --git a/apt-panopticon.lua b/apt-panopticon.lua index aa089b1..057fc40 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -265,6 +265,7 @@ checkHEAD = function (host, URL, r, retry, sanity) -header "" - add extra headers. -L - DO follow redirects. --max-redirs n - set maximum redirects, default is 50, -1 = unlimited. + -4 or -6 - Only use IPv4 or IPv6 --retry n - maximum retries, default is 0, no retries. -o file - write to file instead of stdout. --path-as-is - https://curl.haxx.se/libcurl/c/CURLOPT_PATH_AS_IS.html might be useful for URLSanity. @@ -274,7 +275,7 @@ checkHEAD = function (host, URL, r, retry, sanity) -D file - write the received headers to a file. This includes the status code and string. ]] local status = APT.exe( - 'curl -I --retry 0 -s --path-as-is --connect-timeout ' .. APT.options.timeout.value .. ' --max-redirs 0 ' .. + 'curl -I --retry 0 -s --path-as-is --connect-timeout ' .. APT.options.timeout.value .. ' --max-redirs 0 ' .. APT.IPv46 .. ' ' .. IP .. ' ' .. '-o /dev/null -D results/"HEADERS_' .. fname .. '" ' .. hdr .. ' -w "#%{http_code} %{ssl_verify_result} %{url_effective}\\n" ' .. PU.scheme .. '://' .. host .. PU.path .. ' >>results/"STATUS_' .. fname .. '"' ):Nice():log():Do().status @@ -519,6 +520,7 @@ local download = "curl" .. " --create-dirs -f -L" .. " --fail-early" .. " --max-time " .. APT.options.maxtime.value .. + APT.IPv46 .. ' ' .. " --retry " .. APT.options.retries.value .. " -R -v -z 'results/stamp.old' --stderr results/" local downloads = function(host, URL, meta, release, list) @@ -1025,9 +1027,9 @@ if 0 < #arg then APT.allpairs(ips, function(k, v) if v == "A" then - if APT.testing("IPv4") then APT.exe("./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k .. " " .. file):Nice():log():fork() end + if APT.testing("IPv4") then APT.exe('./apt-panopticon.lua ' .. sendArgs .. ' -4 ' .. pu.host .. path .. ' ' .. k .. ' ' .. file):Nice():log():fork() end elseif v == "AAAA" then - if APT.testing("IPv6") then APT.exe("./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k .. " " .. file):Nice():log():fork() end + if APT.testing("IPv6") then APT.exe('./apt-panopticon.lua ' .. sendArgs .. ' -6 ' .. APT.IPv46 .. ' ' .. pu.host .. path .. ' ' .. k .. ' ' .. file):Nice():log():fork() end end D('logging to ' .. APT.logName(pu.host, k, file)[2]) end -- cgit v1.1