diff options
| -rwxr-xr-x | apt-panopticon.lua | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 4861fa0..f258906 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua | |||
| @@ -244,8 +244,6 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
| 244 | return | 244 | return |
| 245 | end | 245 | end |
| 246 | D(PU.scheme .. " :// " .. check .. " " .. host .. " -> " .. URL) | 246 | D(PU.scheme .. " :// " .. check .. " " .. host .. " -> " .. URL) |
| 247 | if not APT.testing(PU.scheme, host) then D("Not testing " .. PU.scheme .. " " .. host .. " -> " .. URL); return end | ||
| 248 | -- TODO - Perhaps we should try it anyway, and mark it as a warning if it DOES work? | ||
| 249 | if "https" == PU.scheme and APT.options.roundRobin.value == host then D("Not testing " .. PU.scheme .. " " .. host .. " -> " .. URL .. " mirrors shouldn't have the correct cert."); return end | 247 | if "https" == PU.scheme and APT.options.roundRobin.value == host then D("Not testing " .. PU.scheme .. " " .. host .. " -> " .. URL .. " mirrors shouldn't have the correct cert."); return end |
| 250 | 248 | ||
| 251 | --[[ Using curl command line - | 249 | --[[ Using curl command line - |
| @@ -279,11 +277,6 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
| 279 | if "0" ~= status then | 277 | if "0" ~= status then |
| 280 | local msg = curlStatus[0 + status] | 278 | local msg = curlStatus[0 + status] |
| 281 | if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end | 279 | if nil == msg then msg = "UNKNOWN CURL STATUS CODE!" end |
| 282 | if sanity then | ||
| 283 | E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "URLSanity", host) | ||
| 284 | else | ||
| 285 | E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "", host) | ||
| 286 | end | ||
| 287 | if ("28" == status) or ("7" == status) then | 280 | if ("28" == status) or ("7" == status) then |
| 288 | if sanity then | 281 | if sanity then |
| 289 | T(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "URLSanity", host) | 282 | T(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "URLSanity", host) |
| @@ -291,6 +284,12 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
| 291 | T(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host) | 284 | T(" TIMEOUT " .. timeouts + 1 .. ", retry " .. retry + 1, PU.scheme, "", host) |
| 292 | end | 285 | end |
| 293 | timeouts = timeouts + 1 | 286 | timeouts = timeouts + 1 |
| 287 | else | ||
| 288 | if sanity then | ||
| 289 | E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "URLSanity", host) | ||
| 290 | else | ||
| 291 | E(" The curl command return an error code of " .. status .. " - " .. msg, PU.scheme, "", host) | ||
| 292 | end | ||
| 294 | end | 293 | end |
| 295 | checkHEAD(host, URL, r, retry + 1, sanity) | 294 | checkHEAD(host, URL, r, retry + 1, sanity) |
| 296 | return | 295 | return |
| @@ -303,7 +302,13 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
| 303 | for line in rfile:lines("*l") do | 302 | for line in rfile:lines("*l") do |
| 304 | if "#" == line:sub(1, 1) then | 303 | if "#" == line:sub(1, 1) then |
| 305 | code = line:sub(2, 4) | 304 | code = line:sub(2, 4) |
| 306 | if ("https" == PU.scheme) and ("0" ~= line:sub(6, 6)) then E(" The certificate is invalid.", PU.scheme, "https", host) end | 305 | if ("https" == PU.scheme) and ("0" ~= line:sub(6, 6)) then |
| 306 | if sanity then | ||
| 307 | E(" The certificate is invalid.", PU.scheme, "URLSanity", host) | ||
| 308 | else | ||
| 309 | E(" The certificate is invalid.", PU.scheme, "https", host) | ||
| 310 | end | ||
| 311 | end | ||
| 307 | elseif "http" == line:sub(1, 4):lower() then | 312 | elseif "http" == line:sub(1, 4):lower() then |
| 308 | -- -2 coz the headers file gets a \r at the end. | 313 | -- -2 coz the headers file gets a \r at the end. |
| 309 | cstr = line:sub(14, -2) | 314 | cstr = line:sub(14, -2) |
| @@ -320,13 +325,13 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
| 320 | E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) | 325 | E(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL, PU.scheme, "", host) |
| 321 | end | 326 | end |
| 322 | else | 327 | else |
| 328 | if not APT.testing(PU.scheme, host) then W("Not supported, but works " .. PU.scheme .. " " .. host .. " -> " .. URL, PU.scheme, "", host) end | ||
| 323 | I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL) | 329 | I(" " .. code .. " " .. cstr .. ". " .. check .. " " .. host .. " -> " .. URL) |
| 324 | -- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. | 330 | -- timeouts = timeouts - 1 -- Backoff the timeouts count if we managed to get through. |
| 325 | if nil ~= location then | 331 | if nil ~= location then |
| 326 | pu = url.parse(location, defaultURL) | 332 | pu = url.parse(location, defaultURL) |
| 327 | if ('http' == location:sub(1, 4)) and (pu.scheme ~= PU.scheme) then -- Sometimes a location sans scheme is returned, this is not a protocol change. | 333 | if ('http' == location:sub(1, 4)) and (pu.scheme ~= PU.scheme) then -- Sometimes a location sans scheme is returned, this is not a protocol change. |
| 328 | if APT.testing("Protocol") then W(" protocol changed during redirect! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. location, PU.scheme, "Protocol", host) end | 334 | if APT.testing("Protocol") then W(" protocol changed during redirect! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. location, PU.scheme, "Protocol", host) end |
| 329 | if (pu.host == host) and pu.path == PU.path then D("Not testing protocol change " .. URL .. " -> " .. location); return end | ||
| 330 | end | 335 | end |
| 331 | 336 | ||
| 332 | if location == URL then | 337 | if location == URL then |
