aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2019-12-31 00:22:00 +1000
committeronefang2019-12-31 00:22:00 +1000
commitf1b487e17eb1a41f7bfd47102821e8e7c2ab49e7 (patch)
treeffa769c3e7f3ba5e05263cf948a548454f4b6698
parentClean up if we are retrying a HEAD check. (diff)
downloadapt-panopticon-f1b487e17eb1a41f7bfd47102821e8e7c2ab49e7.zip
apt-panopticon-f1b487e17eb1a41f7bfd47102821e8e7c2ab49e7.tar.gz
apt-panopticon-f1b487e17eb1a41f7bfd47102821e8e7c2ab49e7.tar.bz2
apt-panopticon-f1b487e17eb1a41f7bfd47102821e8e7c2ab49e7.tar.xz
Rearrange the status and STATUS checks in HEAD tests.
Diffstat (limited to '')
-rwxr-xr-xapt-panopticon.lua32
1 files changed, 16 insertions, 16 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index 2959fc7..093d3ff 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -284,20 +284,6 @@ checkHEAD = function (host, URL, r, retry, sanity)
284 IP .. ' ' .. '-o /dev/null -D results/"HEADERS_' .. fname .. '" ' .. 284 IP .. ' ' .. '-o /dev/null -D results/"HEADERS_' .. fname .. '" ' ..
285 hdr .. ' -w "#%{http_code} %{ssl_verify_result} %{url_effective}\\n" ' .. PU.scheme .. '://' .. host .. PU.path .. ' >>results/"STATUS_' .. fname .. '"' 285 hdr .. ' -w "#%{http_code} %{ssl_verify_result} %{url_effective}\\n" ' .. PU.scheme .. '://' .. host .. PU.path .. ' >>results/"STATUS_' .. fname .. '"'
286 ):Nice():log():Do().status 286 ):Nice():log():Do().status
287 os.execute('cat results/"HEADERS_' .. fname .. '" >>results/"STATUS_' .. fname .. '" 2>/dev/null; rm -f results/"HEADERS_' .. fname .. '" 2>/dev/null')
288 if 0 ~= status then
289 local msg = curlStatus[status]
290 if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end
291 if (28 == status) or (7 == status) then
292 T(spcd .. spcd .. "TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1 .. ' ' .. APT.lnk(URL), PU.scheme, sanity, host)
293 timeouts = timeouts + 1
294 else
295 E(spcd .. spcd .. "The curl command return an error code of " .. status .. " - " .. msg .. ' for '.. APT.lnk(URL), PU.scheme, sanity, host)
296 end
297 if 60 == status then return end -- Certificate is invalid, don't bother retrying.
298 checkHEAD(host, URL, r, retry + 1, '' ~= sanity)
299 return
300 end
301 local code = "???" 287 local code = "???"
302 local cstr = "" 288 local cstr = ""
303 local location = nil 289 local location = nil
@@ -310,15 +296,31 @@ checkHEAD = function (host, URL, r, retry, sanity)
310 T(spcd .. spcd .. "TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1 .. ' ' .. APT.lnk(URL), PU.scheme, sanity, host) 296 T(spcd .. spcd .. "TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1 .. ' ' .. APT.lnk(URL), PU.scheme, sanity, host)
311 timeouts = timeouts + 1 297 timeouts = timeouts + 1
312 checkHEAD(host, URL, r, retry + 1, '' ~= sanity) 298 checkHEAD(host, URL, r, retry + 1, '' ~= sanity)
299 os.execute('cat results/"HEADERS_' .. fname .. '" >>results/"STATUS_' .. fname .. '" 2>/dev/null; rm -f results/"HEADERS_' .. fname .. '" 2>/dev/null')
313 return 300 return
314 end 301 end
315 end 302 end
303 os.execute('cat results/"HEADERS_' .. fname .. '" >>results/"STATUS_' .. fname .. '" 2>/dev/null; rm -f results/"HEADERS_' .. fname .. '" 2>/dev/null')
304 if 0 ~= status then
305 local msg = curlStatus[status]
306 if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end
307 if (28 == status) or (7 == status) then
308 T(spcd .. spcd .. "TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1 .. ' ' .. APT.lnk(URL), PU.scheme, sanity, host)
309 timeouts = timeouts + 1
310 else
311 E(spcd .. spcd .. "The curl command return an error code of " .. status .. " - " .. msg .. ' for '.. APT.lnk(URL), PU.scheme, sanity, host)
312 end
313 if 60 == status then return end -- Certificate is invalid, don't bother retrying.
314 checkHEAD(host, URL, r, retry + 1, '' ~= sanity)
315 return
316 end
316 local rfile, e = io.open("results/STATUS_" .. fname, "r") 317 local rfile, e = io.open("results/STATUS_" .. fname, "r")
317 if nil == rfile then W("opening results/STATUS_" .. fname .. " file - " .. e) else 318 if nil == rfile then W("opening results/STATUS_" .. fname .. " file - " .. e) else
318 for line in rfile:lines("*l") do 319 for line in rfile:lines("*l") do
319 if "#" == line:sub(1, 1) then 320 if "#" == line:sub(1, 1) then
320 code = line:sub(2, 4) 321 code = line:sub(2, 4)
321 if ("https" == PU.scheme) and ("0" ~= line:sub(6, 6)) then 322 if ("https" == PU.scheme) and ("0" ~= line:sub(6, 6)) then
323 os.execute('cp results/STATUS_' .. fname .. ' results/STATUS_' .. fname .. '_SAVED')
322 if '' ~= sanity then 324 if '' ~= sanity then
323 E(spcd .. spcd .. "The certificate is invalid.", PU.scheme, sanity, host) 325 E(spcd .. spcd .. "The certificate is invalid.", PU.scheme, sanity, host)
324 else 326 else
@@ -332,7 +334,6 @@ checkHEAD = function (host, URL, r, retry, sanity)
332 location = line:sub(11, -2) 334 location = line:sub(11, -2)
333 end 335 end
334 end 336 end
335 os.execute('rm -f results/STATUS_' .. fname .. ' 2>/dev/null')
336 end 337 end
337 if ("4" == tostring(code):sub(1, 1)) or ("5" == tostring(code):sub(1, 1)) then 338 if ("4" == tostring(code):sub(1, 1)) or ("5" == tostring(code):sub(1, 1)) then
338 E(spcd .. spcd .. code .. " " .. cstr .. ". " .. check .. " " .. APT.lnk(URL), PU.scheme, sanity, host) 339 E(spcd .. spcd .. code .. " " .. cstr .. ". " .. check .. " " .. APT.lnk(URL), PU.scheme, sanity, host)
@@ -1051,7 +1052,6 @@ os.execute('sleep 1') -- Wait for things to start up before checking for them.
1051 while 0 < APT.checkExes(downloadLock .. "package-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end 1052 while 0 < APT.checkExes(downloadLock .. "package-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end
1052 os.execute("sleep 5") 1053 os.execute("sleep 5")
1053 if not APT.keep then os.execute("rm -fr results/" .. pu.host .. " 2>/dev/null") end 1054 if not APT.keep then os.execute("rm -fr results/" .. pu.host .. " 2>/dev/null") end
1054 os.execute('rm results/STATUS_' .. pu.host .. '_* 2>/dev/null')
1055 end 1055 end
1056 1056
1057 APT.logPost() 1057 APT.logPost()