diff options
-rwxr-xr-x | mirror-checker.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/mirror-checker.lua b/mirror-checker.lua index aada1e2..4a82309 100755 --- a/mirror-checker.lua +++ b/mirror-checker.lua | |||
@@ -193,34 +193,34 @@ checkURL = function (host, URL, r, retry) | |||
193 | return | 193 | return |
194 | end | 194 | end |
195 | local PU = url.parse(URL, defaultURL) | 195 | local PU = url.parse(URL, defaultURL) |
196 | D(" " .. PU.scheme .. " :// " .. check .. " " .. host .. " -> " .. URL) | 196 | D(PU.scheme .. " :// " .. check .. " " .. host .. " -> " .. URL) |
197 | if not testing(PU.scheme) then D("not testing " .. PU.scheme .. " " .. host .. " -> " .. URL); return end | 197 | if not testing(PU.scheme) then D("not testing " .. PU.scheme .. " " .. host .. " -> " .. URL); return end |
198 | local hd = {Host = host} | 198 | local hd = {Host = host} |
199 | local p, c, h, s = http.request{method = "HEAD", redirect = false, url = URL, headers = hd} | 199 | local p, c, h, s = http.request{method = "HEAD", redirect = false, url = URL, headers = hd} |
200 | if nil == s then s = "" end | 200 | if nil == s then s = "" end |
201 | if nil == p then | 201 | if nil == p then |
202 | E(c .. " " .. s .. "! " .. check .. " " .. host .. " -> " .. URL) | 202 | E(" " .. c .. " " .. s .. "! " .. check .. " " .. host .. " -> " .. URL) |
203 | -- So far the only errors are "timeout", "Network is unreachable", and "closed", and I suspect "closed" is due to saturating my bandwidth. | 203 | -- So far the only errors are "timeout", "Network is unreachable", and "closed", and I suspect "closed" is due to saturating my bandwidth. |
204 | -- Might be worthwhile retrying those, some number of times. | 204 | -- Might be worthwhile retrying those, some number of times. |
205 | if ("closed" == c) or ("Network is unreachable" == c) or ("timeout" == c) then checkURL(host, URL, r, retry + 1) end | 205 | if ("closed" == c) or ("Network is unreachable" == c) or ("timeout" == c) then checkURL(host, URL, r, retry + 1) end |
206 | else | 206 | else |
207 | if ("4" == tostring(c):sub(1, 1)) or ("5" == tostring(c):sub(1, 1)) then | 207 | if ("4" == tostring(c):sub(1, 1)) or ("5" == tostring(c):sub(1, 1)) then |
208 | E(c .. " " .. s .. ". " .. check .. " " .. host .. " -> " .. URL) | 208 | E(" " .. c .. " " .. s .. ". " .. check .. " " .. host .. " -> " .. URL) |
209 | else | 209 | else |
210 | I(c .. " " .. s .. ". " .. check .. " " .. host .. " -> " .. URL) | 210 | I(" " .. c .. " " .. s .. ". " .. check .. " " .. host .. " -> " .. URL) |
211 | end | 211 | end |
212 | l = h.location | 212 | l = h.location |
213 | if nil ~= l then | 213 | if nil ~= l then |
214 | local pu = url.parse(l, defaultURL) | 214 | local pu = url.parse(l, defaultURL) |
215 | if l == URL then | 215 | if l == URL then |
216 | E("redirect loop! " .. check .. " " .. host .. " -> " .. URL) | 216 | E(" redirect loop! " .. check .. " " .. host .. " -> " .. URL) |
217 | else | 217 | else |
218 | if nil == pu.host then | 218 | if nil == pu.host then |
219 | W("no location host! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l) | 219 | W(" no location host! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l) |
220 | checkURL(host, PU.scheme .. "://" .. PU.host .. l, r + 1) | 220 | checkURL(host, PU.scheme .. "://" .. PU.host .. l, r + 1) |
221 | else | 221 | else |
222 | if testing("Protocol") and pu.scheme ~= PU.scheme then | 222 | if testing("Protocol") and pu.scheme ~= PU.scheme then |
223 | W("protocol changed during redirect! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l) | 223 | W(" protocol changed during redirect! " .. check .. " " .. host .. " -> " .. URL .. " -> " .. l) |
224 | end | 224 | end |
225 | checkURL(pu.host, l, r + 1, retry) | 225 | checkURL(pu.host, l, r + 1, retry) |
226 | end | 226 | end |
@@ -247,7 +247,7 @@ local checkPaths = function (host, ip, path) | |||
247 | end | 247 | end |
248 | 248 | ||
249 | local execute = function (s) | 249 | local execute = function (s) |
250 | D("executing " .. s) | 250 | D(" executing " .. s) |
251 | os.execute(s) | 251 | os.execute(s) |
252 | end | 252 | end |
253 | 253 | ||