diff options
Diffstat (limited to 'apt-panopticon.lua')
-rwxr-xr-x | apt-panopticon.lua | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua index ade9de3..21e7599 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua | |||
@@ -43,7 +43,7 @@ options = | |||
43 | -- "rsync", | 43 | -- "rsync", |
44 | "DNSRR", | 44 | "DNSRR", |
45 | "Protocol", | 45 | "Protocol", |
46 | -- "URLSanity", | 46 | "URLSanity", |
47 | "Integrity", | 47 | "Integrity", |
48 | "Updated", | 48 | "Updated", |
49 | }, | 49 | }, |
@@ -404,9 +404,10 @@ end | |||
404 | 404 | ||
405 | local timeouts = 0; | 405 | local timeouts = 0; |
406 | local totalTimeouts = 0 | 406 | local totalTimeouts = 0 |
407 | checkHEAD = function (host, URL, r, retry) | 407 | checkHEAD = function (host, URL, r, retry, sanity) |
408 | if nil == r then r = 0 end | 408 | if nil == r then r = 0 end |
409 | if nil == retry then retry = 0 end | 409 | if nil == retry then retry = 0 end |
410 | if nil == sanity then sanity = false end | ||
410 | local check = "Checking file" | 411 | local check = "Checking file" |
411 | local PU = url.parse(URL, defaultURL) | 412 | local PU = url.parse(URL, defaultURL) |
412 | local pu = url.parse(PU.scheme .. "://" .. host, defaultURL) | 413 | local pu = url.parse(PU.scheme .. "://" .. host, defaultURL) |
@@ -469,12 +470,20 @@ checkHEAD = function (host, URL, r, retry) | |||
469 | if "0" ~= status then | 470 | if "0" ~= status then |
470 | local msg = curlStatus[0 + status] | 471 | local msg = curlStatus[0 + status] |
471 | if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end | 472 | if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end |
472 | E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "", host) | 473 | if sanity then |
474 | E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "URLSanity", host) | ||
475 | else | ||
476 | E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "", host) | ||
477 | end | ||
473 | if ("28" == status) or ("7" == status) then | 478 | if ("28" == status) or ("7" == status) then |
474 | E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host) | 479 | if sanity then |
480 | E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "URLSanity", host) | ||
481 | else | ||
482 | E(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host) | ||
483 | end | ||
475 | timeouts = timeouts + 1 | 484 | timeouts = timeouts + 1 |
476 | end | 485 | end |
477 | checkHEAD(host, URL, r, retry + 1, timeouts) | 486 | checkHEAD(host, URL, r, retry + 1, sanity) |
478 | return | 487 | return |
479 | end | 488 | end |
480 | local rfile, e = io.open("results/STATUS_" .. fname, "r") | 489 | local rfile, e = io.open("results/STATUS_" .. fname, "r") |
@@ -496,7 +505,11 @@ checkHEAD = function (host, URL, r, retry) | |||
496 | end | 505 | end |
497 | os.execute('rm results/"STATUS_' .. fname .. '" 2>/dev/null') | 506 | os.execute('rm results/"STATUS_' .. fname .. '" 2>/dev/null') |
498 | if ("4" == tostring(code):sub(1, 1)) or ("5" == tostring(code):sub(1, 1)) then | 507 | if ("4" == tostring(code):sub(1, 1)) or ("5" == tostring(code):sub(1, 1)) then |
499 | E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) | 508 | if sanity then |
509 | E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "URLSanity", host) | ||
510 | else | ||
511 | E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) | ||
512 | end | ||
500 | else | 513 | else |
501 | I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL) | 514 | I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL) |
502 | -- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. | 515 | -- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. |
@@ -511,9 +524,9 @@ checkHEAD = function (host, URL, r, retry) | |||
511 | E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) | 524 | E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) |
512 | elseif nil == pu.host then | 525 | elseif nil == pu.host then |
513 | I(" relative redirect. " .. check .. " " .. host .. " -> " .. URL .. " -> " .. location) | 526 | I(" relative redirect. " .. check .. " " .. host .. " -> " .. URL .. " -> " .. location) |
514 | checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1) | 527 | checkHEAD(host, PU.scheme .. "://" .. PU.host .. location, r + 1, retry, sanity) |
515 | elseif (PU.host == pu.host) or (host == pu.host) then | 528 | elseif (PU.host == pu.host) or (host == pu.host) then |
516 | checkHEAD(pu.host, location, r + 1) | 529 | checkHEAD(pu.host, location, r + 1, retry, sanity) |
517 | else | 530 | else |
518 | --[[ The hard part here is that we end up throwing ALL of the test files at the redirected location. | 531 | --[[ The hard part here is that we end up throwing ALL of the test files at the redirected location. |
519 | Not good for deb.debian.org, which we should only be throwing .debs at. | 532 | Not good for deb.debian.org, which we should only be throwing .debs at. |
@@ -544,6 +557,15 @@ local checkTimeouts = function(host, scheme, URL) | |||
544 | return true | 557 | return true |
545 | end | 558 | end |
546 | end | 559 | end |
560 | if testing("URLSanity") then | ||
561 | URL = URL:gsub("merged/", "merged///") | ||
562 | totalTimeouts = totalTimeouts + timeouts; timeouts = 0 | ||
563 | checkHEAD(host, scheme .. "://" .. URL, 0, 0, true) | ||
564 | if 4 <= (totalTimeouts) then | ||
565 | E("Way too many timeouts!", scheme, "URLSanity", host) | ||
566 | return true | ||
567 | end | ||
568 | end | ||
547 | return false | 569 | return false |
548 | end | 570 | end |
549 | 571 | ||