diff options
Diffstat (limited to 'apt-panopticon.lua')
-rwxr-xr-x | apt-panopticon.lua | 103 |
1 files changed, 100 insertions, 3 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 13adead..b2827b4 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua | |||
@@ -376,6 +376,8 @@ checkHEAD = function (host, URL, r, retry, sanity) | |||
376 | local extraArgs = sendArgs .. ' -o -r ' | 376 | local extraArgs = sendArgs .. ' -o -r ' |
377 | if 'https' == pu.scheme then extraArgs = extraArgs .. ' --tests=-http' end | 377 | if 'https' == pu.scheme then extraArgs = extraArgs .. ' --tests=-http' end |
378 | if 'http' == pu.scheme then extraArgs = extraArgs .. ' --tests=-https' end | 378 | if 'http' == pu.scheme then extraArgs = extraArgs .. ' --tests=-https' end |
379 | local pth = path:match('^(.*/pool/).*$') | ||
380 | if nil ~= pth then table.insert(APT.results[PU.scheme].redirects, pu.host .. "/" .. pth) else E('Odd redirect path ' .. path) end | ||
379 | I(" Now checking redirected host " .. u) | 381 | I(" Now checking redirected host " .. u) |
380 | APT.fork("ionice -c3 nice -n 19 " .. downloadLock .. "REDIR-" .. check .. ".log.txt" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file) | 382 | APT.fork("ionice -c3 nice -n 19 " .. downloadLock .. "REDIR-" .. check .. ".log.txt" .. " ./apt-panopticon.lua " .. extraArgs .. ' ' .. pu.host .. "/" .. path .. " " .. file) |
381 | D('logging to ' .. APT.logName(pu.host, nil, file)[2]) | 383 | D('logging to ' .. APT.logName(pu.host, nil, file)[2]) |
@@ -422,12 +424,10 @@ local checkFiles = function (host, ip, path, file) | |||
422 | end | 424 | end |
423 | end | 425 | end |
424 | end | 426 | end |
425 | |||
426 | for i, s in pairs(referenceDebs) do | 427 | for i, s in pairs(referenceDebs) do |
427 | if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end | 428 | if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end |
428 | if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end | 429 | if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end |
429 | end | 430 | end |
430 | |||
431 | for i, s in pairs(referenceDevs) do | 431 | for i, s in pairs(referenceDevs) do |
432 | if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end | 432 | if checkTimeouts(host, "http", ip .. path .. "/" .. s) then return end |
433 | if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end | 433 | if checkTimeouts(host, "https", ip .. path .. "/" .. s) then return end |
@@ -994,7 +994,7 @@ if 0 < #arg then | |||
994 | rfile:close() | 994 | rfile:close() |
995 | end | 995 | end |
996 | 996 | ||
997 | if APT.origin and APT.options.referenceSite.value ~= pu.host then | 997 | if APT.origin and (not APT.redir) and (APT.options.referenceSite.value ~= pu.host) then |
998 | os.execute('sleep 1') -- Wait for things to start up before checking for them. | 998 | os.execute('sleep 1') -- Wait for things to start up before checking for them. |
999 | while 0 < APT.checkExes(downloadLock .. "Release-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end | 999 | while 0 < APT.checkExes(downloadLock .. "Release-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end |
1000 | while 0 < APT.checkExes(downloadLock .. "Packages-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end | 1000 | while 0 < APT.checkExes(downloadLock .. "Packages-" .. pu.host .. ".log.txt") do os.execute("sleep 10") end |
@@ -1038,6 +1038,103 @@ else | |||
1038 | os.execute('sleep 1') -- Wait for things to start up before checking for them. | 1038 | os.execute('sleep 1') -- Wait for things to start up before checking for them. |
1039 | while 1 <= APT.checkExes("apt-panopticon.lua " .. sendArgs) do os.execute("sleep 10") end | 1039 | while 1 <= APT.checkExes("apt-panopticon.lua " .. sendArgs) do os.execute("sleep 10") end |
1040 | 1040 | ||
1041 | local APT_args = APT.args | ||
1042 | local APT_logFile = APT.logFile | ||
1043 | local debians = {} | ||
1044 | local srvs = io.popen('ls -1 results/*.lua') | ||
1045 | for l in srvs:lines() do | ||
1046 | local hst = l:sub(9, -5) | ||
1047 | if (l:find('_') == nil) and (nil == APT.mirrors[hst]) then | ||
1048 | local ips = loadfile(l)().IPs | ||
1049 | if nil ~= ips then | ||
1050 | debians[hst] = {Country = '', FDQN = hst, Active = 'yes', Rate = '', BaseURL = hst, Protocols = {http = true, https = true}, Bandwidth = '', IPs = ips} | ||
1051 | local baseFiles = {} | ||
1052 | local IPfiles = {} | ||
1053 | for i, a in pairs(ips) do | ||
1054 | IPfiles[i] = {} | ||
1055 | if type(a) == 'table' then | ||
1056 | for j, b in pairs(a) do | ||
1057 | IPfiles[i][j] = {} | ||
1058 | end | ||
1059 | else | ||
1060 | end | ||
1061 | end | ||
1062 | local files = io.popen('ls -1 results/LOG_' .. hst .. '_*.html') | ||
1063 | for ll in files:lines() do | ||
1064 | local dn = false | ||
1065 | for i, a in pairs(ips) do | ||
1066 | if type(a) == 'table' then | ||
1067 | for j, b in pairs(a) do | ||
1068 | if nil ~= ll:match('(results/LOG_' .. hst .. '_' .. j .. '_.*)') then | ||
1069 | table.insert(IPfiles[i][j], ll) | ||
1070 | dn = true | ||
1071 | end | ||
1072 | end | ||
1073 | else | ||
1074 | if nil ~= ll:match('(results/LOG_' .. hst .. '_' .. i .. '_.*)') then | ||
1075 | table.insert(IPfiles[i], ll) | ||
1076 | dn = true | ||
1077 | end | ||
1078 | end | ||
1079 | end | ||
1080 | if not dn then table.insert(baseFiles, ll) end | ||
1081 | end | ||
1082 | |||
1083 | APT.logOpen(hst) | ||
1084 | APT.logFile:write('<h1>Note log lines will be out of order, this is a bunch of other log files combined.</h1>\n') | ||
1085 | for i, f in pairs(baseFiles) do | ||
1086 | f = f:sub(9, -1) | ||
1087 | APT.logFile:write('<hr>\n<hr>\n<h2><a href="' .. f .. '">' .. f .. '</a></h2>\n') | ||
1088 | for l in io.lines('results/' .. f) do | ||
1089 | if l:match('^' .. os.date('%a %b %d ') .. '.*$') then APT.logFile:write(l .. '\n') end | ||
1090 | end | ||
1091 | end | ||
1092 | APT.logPost() | ||
1093 | APT.args = APT_args | ||
1094 | APT.logFile = APT_logFile | ||
1095 | |||
1096 | for ip, a in pairs(IPfiles) do | ||
1097 | if nil == a[1] then | ||
1098 | for i, f in pairs(a) do | ||
1099 | if not APT.logOpen(hst, i) then print('PROBLEM OPENING LOG FILE ' .. hst .. ' ' .. i) end | ||
1100 | APT.logFile:write('<h1>Note log lines will be out of order, this is a bunch of other log files combined.</h1>\n') | ||
1101 | for j, g in pairs(f) do | ||
1102 | g = g:sub(9, -1) | ||
1103 | APT.logFile:write('<hr>\n<hr>\n<h2><a href="' .. g .. '">' .. g .. '</a></h2>\n') | ||
1104 | for l in io.lines('results/' .. g) do | ||
1105 | if l:match('^' .. os.date('%a %b %d ') .. '.*$') then APT.logFile:write(l .. '\n') end | ||
1106 | end | ||
1107 | end | ||
1108 | APT.logPost() | ||
1109 | APT.args = APT_args | ||
1110 | APT.logFile = APT_logFile | ||
1111 | end | ||
1112 | else | ||
1113 | if not APT.logOpen(hst, ip) then print('PROBLEM OPENING LOG FILE ' .. hst .. ' ' .. ip) end | ||
1114 | APT.logFile:write('<h1>Note log lines will be out of order, this is a bunch of other log files combined.</h1>\n') | ||
1115 | for i, f in pairs(a) do | ||
1116 | f = f:sub(9, -1) | ||
1117 | APT.logFile:write('<hr>\n<hr>\n<h2><a href="' .. f .. '">' .. f .. '</a></h2>\n') | ||
1118 | for l in io.lines('results/' .. f) do | ||
1119 | if l:match('^' .. os.date('%a %b %d ') .. '.*$') then APT.logFile:write(l .. '\n') end | ||
1120 | end | ||
1121 | end | ||
1122 | APT.logPost() | ||
1123 | APT.args = APT_args | ||
1124 | APT.logFile = APT_logFile | ||
1125 | end | ||
1126 | end | ||
1127 | |||
1128 | end | ||
1129 | end | ||
1130 | end | ||
1131 | local file, e = io.open("results/debians.lua", "w+") | ||
1132 | if nil == file then C("opening debians file - " .. e) else | ||
1133 | file:write(APT.dumpTable(debians, "", "debians") .. "\nreturn debians\n") | ||
1134 | file:close() | ||
1135 | end | ||
1136 | |||
1137 | |||
1041 | for k, v in pairs(APT.mirrors) do | 1138 | for k, v in pairs(APT.mirrors) do |
1042 | local f = 'results/' .. k .. '.lua' | 1139 | local f = 'results/' .. k .. '.lua' |
1043 | if APT.checkFile(f) then | 1140 | if APT.checkFile(f) then |