aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2019-11-26 01:39:37 +1000
committeronefang2019-11-26 01:39:37 +1000
commite59373c8af941fdca9e2c26a7ab366439002bb7a (patch)
tree5dcd90c7f7991f2f5c86c54bce348ab469d7393f
parentEnable the Integrity tests by default. (diff)
downloadapt-panopticon-e59373c8af941fdca9e2c26a7ab366439002bb7a.zip
apt-panopticon-e59373c8af941fdca9e2c26a7ab366439002bb7a.tar.gz
apt-panopticon-e59373c8af941fdca9e2c26a7ab366439002bb7a.tar.bz2
apt-panopticon-e59373c8af941fdca9e2c26a7ab366439002bb7a.tar.xz
Update the email report to match the web report.
I should merge these two, or factor out common stuff into a library that might be useful for other reports.
-rwxr-xr-xapt-panopticon-report-email.lua84
1 files changed, 81 insertions, 3 deletions
diff --git a/apt-panopticon-report-email.lua b/apt-panopticon-report-email.lua
index d36aab0..5cf2d05 100755
--- a/apt-panopticon-report-email.lua
+++ b/apt-panopticon-report-email.lua
@@ -52,6 +52,25 @@ function orderedPairs(t)
52end 52end
53 53
54 54
55local plurals = function(e, w)
56 local result = ""
57 if 1 == e then
58 result = e .. " error"
59 elseif e ~= 0 then
60 result = e .. " errors"
61 end
62 if 0 < w then
63 if 0 < e then result = result .. ", " end
64 if 1 == w then
65 result = result .. w .. " warning"
66 else
67 result = result .. w .. " warnings"
68 end
69 end
70 if "" ~= result then result = " (" .. result .. ")" end
71 return result
72end
73
55local results = {} 74local results = {}
56 75
57local log = function(v, t, s, prot, test, host) 76local log = function(v, t, s, prot, test, host)
@@ -165,6 +184,31 @@ end
165 184
166local mirrors = loadfile("results/mirrors.lua")() 185local mirrors = loadfile("results/mirrors.lua")()
167 186
187local logCount = function(domain, ip)
188 local nm = "LOG_" .. domain
189 local log = ""
190 local extra = ""
191 if nil ~= ip then nm = nm .. "_" .. ip end
192 nm = nm .. ".html"
193 local rfile, e = io.open("results/" .. nm, "r")
194 if nil ~= rfile then
195 local errors = 0
196 local warnings = 0
197 for l in rfile:lines() do
198 if nil ~= l:match("><b>ERROR ") then errors = errors + 1 end
199 if nil ~= l:match("><b>WARNING ") then warnings = warnings + 1 end
200 end
201 rfile:close()
202-- if nil == ip then
203-- log = "<a href='" .. nm .. "'>" .. domain .. "</a>"
204-- else
205-- log = "<a href='" .. nm .. "'>" .. ip .. "</a>"
206-- end
207 log = log .. plurals(errors, warnings)
208 end
209 return log
210end
211
168local file, e = io.open("results/Report-email.txt", "w+") 212local file, e = io.open("results/Report-email.txt", "w+")
169if nil == file then C("opening mirrors file - " .. e) else 213if nil == file then C("opening mirrors file - " .. e) else
170 file:write( "Dear Mirror Admins,\n\n" .. 214 file:write( "Dear Mirror Admins,\n\n" ..
@@ -192,13 +236,47 @@ if nil == file then C("opening mirrors file - " .. e) else
192 end 236 end
193 local http = status(k, results, "http") 237 local http = status(k, results, "http")
194 local https = status(k, results, "https") 238 local https = status(k, results, "https")
195 local dns = "[skip]" 239 local dns = ""
196 local protocol = status(k, results, "Protocol") 240 local protocol = status(k, results, "Protocol")
197 local sanity = "[skip]" 241 local sanity = "[skip]"
198 local integrity = status(k, results, "Integrity") 242 local integrity = status(k, results, "Integrity")
199 local updated = "[skip]" 243 local updated = "[skip]"
200 file:write( " http: " .. http .. " https: " .. https .. " DNS-RR: " .. dns .. " Protocol: " .. protocol .. "\n" .. 244
201 " URL-sanity: " .. sanity .. " Integrity: " .. integrity .. " Updated: " .. updated .. "\n") 245 -- DNS-RR test.
246 if ("deb.devuan.org" ~= k) and (nil ~= mirrors["deb.devuan.org"]) then
247 for l, w in pairs(mirrors[k].IPs) do
248 if type(w) == "table" then
249 for i, u in pairs(w) do
250 if nil ~= mirrors["deb.devuan.org"].IPs["deb.roundr.devuan.org"][i] then
251 local log = logCount("deb.devuan.org", i)
252 if "" ~= log then
253 if "" == dns then dns = " " else dns = dns .. " " end
254 dns = dns .. logCount("deb.devuan.org", i)
255 else
256 if "" == dns then dns = " " else dns = dns .. " " end
257 dns = dns .. i
258 end
259 end
260 end
261 else
262 if nil ~= mirrors["deb.devuan.org"].IPs["deb.roundr.devuan.org"][l] then
263 local log = logCount("deb.devuan.org", l)
264 if "" ~= log then
265 if "" == dns then dns = " " else dns = dns .. " " end
266 dns = dns .. log
267 else
268 if "" == dns then dns = " " else dns = dns .. " " end
269 dns = dns .. l
270 end
271 end
272 end
273 end
274 if "" == dns then dns = "[no]" end
275 dns = " DNS-RR: " .. dns
276 end
277
278 file:write( " http: " .. http .. " https: " .. https .. dns .. "\n" ..
279 " Protocol: " .. protocol .. " URL-sanity: " .. sanity .. " Integrity: " .. integrity .. " Updated: " .. updated .. "\n")
202 end 280 end
203 file:write( "\n==== faulty mirrors: ====\n" .. faulty) 281 file:write( "\n==== faulty mirrors: ====\n" .. faulty)
204 file:write( "\n---- END MIRROR-STATUS ----\n\n" .. 282 file:write( "\n---- END MIRROR-STATUS ----\n\n" ..