diff options
author | onefang | 2019-12-23 13:01:05 +1000 |
---|---|---|
committer | onefang | 2019-12-23 13:01:05 +1000 |
commit | 5e8b0adf2a39debac8354fd98ca7d5b729580ff7 (patch) | |
tree | 73b9c3666a89bbf52adb714c712209a09d48deb0 /apt-panopticon-report-email-web.lua | |
parent | Move the declaration of the APT.tests table to where APT.protocols is. (diff) | |
download | apt-panopticon-5e8b0adf2a39debac8354fd98ca7d5b729580ff7.zip apt-panopticon-5e8b0adf2a39debac8354fd98ca7d5b729580ff7.tar.gz apt-panopticon-5e8b0adf2a39debac8354fd98ca7d5b729580ff7.tar.bz2 apt-panopticon-5e8b0adf2a39debac8354fd98ca7d5b729580ff7.tar.xz |
Major refactor, especially of the downloading and processing code.
Make the code more readable, less scattered.
Use a coroutine to multitask better.
Plugable functions for parsing the download results, and figuring out
what to download next.
Track timeouts at a finer level.
Dig for IPs in the forked apt-panopticons, not all at once at the
beginning.
Various cleanups and tweaks.
Diffstat (limited to 'apt-panopticon-report-email-web.lua')
-rwxr-xr-x | apt-panopticon-report-email-web.lua | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua index 8a5404a..c52b6c0 100755 --- a/apt-panopticon-report-email-web.lua +++ b/apt-panopticon-report-email-web.lua | |||
@@ -3,6 +3,7 @@ | |||
3 | local APT = require 'apt-panopticommon' | 3 | local APT = require 'apt-panopticommon' |
4 | local D = APT.D | 4 | local D = APT.D |
5 | local I = APT.I | 5 | local I = APT.I |
6 | local T = APT.T | ||
6 | local W = APT.W | 7 | local W = APT.W |
7 | local E = APT.E | 8 | local E = APT.E |
8 | local C = APT.C | 9 | local C = APT.C |
@@ -47,16 +48,19 @@ local status = function(host, results, typ) | |||
47 | local result = "" | 48 | local result = "" |
48 | local e = 0 | 49 | local e = 0 |
49 | local w = 0 | 50 | local w = 0 |
51 | local t = 0 | ||
50 | local s = nil ~= APT.mirrors[host].Protocols[typ] | 52 | local s = nil ~= APT.mirrors[host].Protocols[typ] |
51 | local to = results.timeout | 53 | local to = results.timeout |
52 | if not APT.search(APT.protocols, typ) then s = true end | 54 | if not APT.search(APT.protocols, typ) then s = true end |
53 | if nil ~= results[typ] then | 55 | if nil ~= results[typ] then |
54 | e = results[typ].errors | 56 | e = results[typ].errors |
55 | w = results[typ].warnings | 57 | w = results[typ].warnings |
58 | t = results[typ].timeouts | ||
56 | for k, v in pairs(results[typ]) do | 59 | for k, v in pairs(results[typ]) do |
57 | if "table" == type(v) then | 60 | if "table" == type(v) then |
58 | if 0 <= v.errors then e = e + v.errors else to = true end | 61 | if 0 <= v.errors then e = e + v.errors else to = true end |
59 | if 0 <= v.warnings then w = w + v.warnings else to = true end | 62 | if 0 <= v.warnings then w = w + v.warnings else to = true end |
63 | if 0 <= v.timeouts then t = t + v.timeouts else to = true end | ||
60 | end | 64 | end |
61 | end | 65 | end |
62 | else | 66 | else |
@@ -67,6 +71,7 @@ local status = function(host, results, typ) | |||
67 | if typ == i then | 71 | if typ == i then |
68 | if 0 <= u.errors then e = e + u.errors end | 72 | if 0 <= u.errors then e = e + u.errors end |
69 | if 0 <= u.warnings then w = w + u.warnings end | 73 | if 0 <= u.warnings then w = w + u.warnings end |
74 | if 0 <= u.timeouts then t = t + u.timeouts end | ||
70 | end | 75 | end |
71 | end | 76 | end |
72 | end | 77 | end |
@@ -99,6 +104,21 @@ local status = function(host, results, typ) | |||
99 | else | 104 | else |
100 | faulty = faulty .. host .. " (" .. typ .. ")\n" | 105 | faulty = faulty .. host .. " (" .. typ .. ")\n" |
101 | end | 106 | end |
107 | elseif 0 < t then | ||
108 | result = "[timeout" | ||
109 | if not s then result = result .. "*" end | ||
110 | if APT.html then | ||
111 | if s then | ||
112 | result = "[<font color='blue'><b>timeout</b></font>" | ||
113 | else | ||
114 | result = "[<font color='darkblue'><b>timeout*</b></font>" | ||
115 | end | ||
116 | end | ||
117 | if APT.html then | ||
118 | faulty = faulty .. host .. " (" .. typ .. ")<br>\n" | ||
119 | else | ||
120 | faulty = faulty .. host .. " (" .. typ .. ")\n" | ||
121 | end | ||
102 | else | 122 | else |
103 | result = "[OK" | 123 | result = "[OK" |
104 | if not s then result = result .. "*" end | 124 | if not s then result = result .. "*" end |
@@ -110,7 +130,7 @@ local status = function(host, results, typ) | |||
110 | end | 130 | end |
111 | end | 131 | end |
112 | end | 132 | end |
113 | return result .. APT.plurals(e, w) .. "]" | 133 | return result .. APT.plurals(e, w, t) .. "]" |
114 | end | 134 | end |
115 | 135 | ||
116 | local m = {} | 136 | local m = {} |
@@ -125,9 +145,11 @@ local logCount = function(domain, ip) | |||
125 | if nil ~= rfile then | 145 | if nil ~= rfile then |
126 | local errors = 0 | 146 | local errors = 0 |
127 | local warnings = 0 | 147 | local warnings = 0 |
148 | local timeouts = 0 | ||
128 | for l in rfile:lines() do | 149 | for l in rfile:lines() do |
129 | if nil ~= l:match("><b>ERROR ") then errors = errors + 1 end | 150 | if nil ~= l:match("><b>ERROR ") then errors = errors + 1 end |
130 | if nil ~= l:match("><b>WARNING ") then warnings = warnings + 1 end | 151 | if nil ~= l:match("><b>WARNING ") then warnings = warnings + 1 end |
152 | if nil ~= l:match("><b>TIMEOUT ") then timeouts = timeouts + 1 end | ||
131 | end | 153 | end |
132 | rfile:close() | 154 | rfile:close() |
133 | if APT.html then | 155 | if APT.html then |
@@ -137,7 +159,7 @@ local logCount = function(domain, ip) | |||
137 | log = "<a href='" .. nm .. "'>" .. ip .. "</a>" | 159 | log = "<a href='" .. nm .. "'>" .. ip .. "</a>" |
138 | end | 160 | end |
139 | end | 161 | end |
140 | log = log .. APT.plurals(errors, warnings) | 162 | log = log .. APT.plurals(errors, warnings, timeouts) |
141 | end | 163 | end |
142 | return log | 164 | return log |
143 | end | 165 | end |
@@ -303,8 +325,11 @@ if nil == web then C("opening mirrors file - " .. e) else | |||
303 | " means the tested thing is supported for that mirror.</p>\n" .. | 325 | " means the tested thing is supported for that mirror.</p>\n" .. |
304 | "<p>[<font color='darkred'><b>FAILED*</b></font>] or [<font color='darkgreen'><b>OK*</b></font>]" .. | 326 | "<p>[<font color='darkred'><b>FAILED*</b></font>] or [<font color='darkgreen'><b>OK*</b></font>]" .. |
305 | " means the tested thing is unsupported for that mirror, but might have been tested anyway.</p>\n" .. | 327 | " means the tested thing is unsupported for that mirror, but might have been tested anyway.</p>\n" .. |
328 | "<p>[<font color='blue'><b>timeout</b></font>] or [<font color='darkblue'><b>timeout</b></font>]" .. | ||
329 | " means the mirror had some timeouts, and tests where not yet aborted. The darker colour means unsupported by the mirror, but tested anyway.</p>" .. | ||
306 | "<p>[<font color='blue'><b>TIMEOUT</b></font>] or [<font color='darkblue'><b>TIMEOUT</b></font>]" .. | 330 | "<p>[<font color='blue'><b>TIMEOUT</b></font>] or [<font color='darkblue'><b>TIMEOUT</b></font>]" .. |
307 | " means the server had too many timeouts, and tests where aborted, so there is no result for this test.</p>" .. | 331 | " means the mirror had too many timeouts, and tests where aborted, so there is no result for this test.</p>" .. |
332 | "<p>NOTE: timeouts may be due to a problem on the testing computer.</p>" .. | ||
308 | "<p>The DNS round robin (DNS-RR) column shows the IPs for that mirror, or [<font color='grey'><b>no</b></font>] if it isn't part of the DNS-RR. " .. | 333 | "<p>The DNS round robin (DNS-RR) column shows the IPs for that mirror, or [<font color='grey'><b>no</b></font>] if it isn't part of the DNS-RR. " .. |
309 | "The IPs link to the testing log for that IP accessed via the DNS-RR. " .. | 334 | "The IPs link to the testing log for that IP accessed via the DNS-RR. " .. |
310 | "deb.devuan.org is the DNS-RR itself, so it doesn't get tested directly.</p>\n" .. | 335 | "deb.devuan.org is the DNS-RR itself, so it doesn't get tested directly.</p>\n" .. |