Browse Source

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.
master
onefang 3 years ago
parent
commit
9c9226dced
  1. 8
      apt-panopticommon.lua
  2. 8
      apt-panopticon.lua

8
apt-panopticommon.lua

@ -23,6 +23,7 @@ APT.verbosity = -1
APT.origin = false
APT.redir = false
APT.keep = false
APT.IPv46 = ''
APT.options =
{
@ -119,6 +120,10 @@ APT.parseArgs = function(args)
APT.args = args
local arg = {}
local sendArgs = ""
-- A special test to disable IPv6 tests if IPv6 isn't available.
if 1 == APT.exe('ip -6 addr | grep inet6 | grep " global"'):Do().status then
table.insert(args, '--tests=-IPv6')
end
if 0 ~= #(args) then
local option = ""
for i, a in pairs(args) do
@ -132,6 +137,9 @@ APT.parseArgs = function(args)
elseif "-q" == a then
APT.verbosity = -1
sendArgs = sendArgs .. a .. " "
elseif ("-4" == a) or ("-6" == a) then
APT.IPv46 = a
sendArgs = sendArgs .. a .. " "
elseif "-k" == a then
APT.keep = true
sendArgs = sendArgs .. a .. " "

8
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

Loading…
Cancel
Save