From 238e8593a14e46ab0836a939926b193f6e6f122c Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 31 Dec 2019 00:19:47 +1000 Subject: Clean up if we are retrying a HEAD check. --- apt-panopticon.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 889058b..2959fc7 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -223,6 +223,17 @@ checkHEAD = function (host, URL, r, retry, sanity) local check = "HEAD testing file" local PU = url.parse(URL, defaultURL) local pu = url.parse(PU.scheme .. "://" .. host, defaultURL) + local fname = host .. "_" .. PU.host .. "_" .. PU.path:gsub("/", "_") .. ".txt" + local hdr = "" + local IP = "" + if pu.host ~= PU.host then + if "http" == PU.scheme then + hdr = '-H "Host: ' .. host .. '"' + end + IP = '--connect-to "' .. pu.host .. '::' .. PU.host .. ':"' + fname = host .. "_" .. pu.host .. '_' .. PU.host .. "_" .. PU.path:gsub("/", "_") .. ".txt" + end + os.execute('rm -f results/HEADERS_' .. fname .. ' 2>/dev/null; rm -f results/STATUS_' .. fname .. ' 2>/dev/null') if not APT.testing(PU.scheme, host) and APT.redir then I(spcd .. string.upper(PU.scheme) .. " not supported, not tested.   " .. URL, host); return end if 0 < r then check = "Redirecting to" @@ -268,15 +279,6 @@ checkHEAD = function (host, URL, r, retry, sanity) Should return with error code 28 on a timeout? -D file - write the received headers to a file. This includes the status code and string. ]] - local fname = host .. "_" .. PU.host .. "_" .. PU.path:gsub("/", "_") .. ".txt" - local hdr = "" - local IP = "" - if pu.host ~= PU.host then - if "http" == PU.scheme then - hdr = '-H "Host: ' .. host .. '"' - end - IP = '--connect-to "' .. pu.host .. '::' .. PU.host .. ':"' - end local status = APT.exe( 'curl -I --retry 0 -s --path-as-is --connect-timeout ' .. APT.options.timeout.value .. ' --max-redirs 0 ' .. IP .. ' ' .. '-o /dev/null -D results/"HEADERS_' .. fname .. '" ' .. -- cgit v1.1