diff options
Diffstat (limited to '')
-rwxr-xr-x | apt-panopticon-report-web.lua | 90 |
1 files changed, 80 insertions, 10 deletions
diff --git a/apt-panopticon-report-web.lua b/apt-panopticon-report-web.lua index 163d50f..7bb48b0 100755 --- a/apt-panopticon-report-web.lua +++ b/apt-panopticon-report-web.lua | |||
@@ -51,6 +51,28 @@ function orderedPairs(t) | |||
51 | return orderedNext, t, nil | 51 | return orderedNext, t, nil |
52 | end | 52 | end |
53 | 53 | ||
54 | -- Use this to dump a table to a string, with HTML. | ||
55 | dumpTableHTML = function (table, space, name) | ||
56 | local r = name .. "\n" | ||
57 | r = r .. dumpTableHTMLSub(table, space .. " ") | ||
58 | r = r .. space .. "" | ||
59 | return r | ||
60 | end | ||
61 | dumpTableHTMLSub = function (table, space) | ||
62 | local r = "" | ||
63 | for k, v in orderedPairs(table) do | ||
64 | if type(v) == "table" then | ||
65 | if " " == space then | ||
66 | r = r .. space .. dumpTableHTML(v, space, k .. "<ul>") .. "</ul>\n" | ||
67 | else | ||
68 | r = r .. "<li>" .. space .. dumpTableHTML(v, space, k .. "<ul>") .. "</ul></li>\n" | ||
69 | end | ||
70 | else | ||
71 | r = r .. space .. "<li>" .. k .. "</li>\n" | ||
72 | end | ||
73 | end | ||
74 | return r | ||
75 | end | ||
54 | 76 | ||
55 | local results = {} | 77 | local results = {} |
56 | 78 | ||
@@ -114,9 +136,9 @@ local status = function(host, results, typ) | |||
114 | if 0 < w then | 136 | if 0 < w then |
115 | if 0 < e then result = result .. ", " end | 137 | if 0 < e then result = result .. ", " end |
116 | if 1 == w then | 138 | if 1 == w then |
117 | result = result .. w .. " <font color='blue'><b>warning</b></font>" | 139 | result = result .. w .. " <font color='yellow'><b>warning</b></font>" |
118 | else | 140 | else |
119 | result = result .. w .. " <font color='blue'><b>warnings</b></font>" | 141 | result = result .. w .. " <font color='yellow'><b>warnings</b></font>" |
120 | end | 142 | end |
121 | end | 143 | end |
122 | if "[OK]" ~= result then | 144 | if "[OK]" ~= result then |
@@ -164,15 +186,16 @@ local collate = function(host, ip, results) | |||
164 | end | 186 | end |
165 | 187 | ||
166 | local mirrors = loadfile("results/mirrors.lua")() | 188 | local mirrors = loadfile("results/mirrors.lua")() |
189 | local m = {} | ||
167 | 190 | ||
168 | local file, e = io.open("results/Report-web.html", "w+") | 191 | local file, e = io.open("results/Report-web.html", "w+") |
169 | if nil == file then C("opening mirrors file - " .. e) else | 192 | if nil == file then C("opening mirrors file - " .. e) else |
170 | file:write( "<html><head>\n" .. | 193 | file:write( "<html><head>\n" .. |
171 | '</head><body bgcolor="black" text="white" alink="red" link="blue" vlink="purple">' .. | 194 | '</head><body bgcolor="black" text="white" alink="red" link="blue" vlink="purple">' .. |
172 | "Check date: " .. os.date("!%a %b %d %T %Z %Y") .. "\n<br>\n") | 195 | "Check date: " .. os.date("!%a %b %d %T %Z %Y") .. "\n<br>\n<table>\n") |
173 | for k, v in orderedPairs(mirrors) do | 196 | for k, v in orderedPairs(mirrors) do |
174 | local results = loadfile("results/" .. k .. ".lua")() | 197 | local results = loadfile("results/" .. k .. ".lua")() |
175 | file:write(" " .. k .. ".... ") | 198 | file:write(" <tr><th>" .. k .. "</th> ") |
176 | local IPs = v.IPs | 199 | local IPs = v.IPs |
177 | for i, u in pairs(IPs) do | 200 | for i, u in pairs(IPs) do |
178 | if "table" == type(u) then | 201 | if "table" == type(u) then |
@@ -185,15 +208,62 @@ if nil == file then C("opening mirrors file - " .. e) else | |||
185 | end | 208 | end |
186 | local http = status(k, results, "http") | 209 | local http = status(k, results, "http") |
187 | local https = status(k, results, "https") | 210 | local https = status(k, results, "https") |
188 | local dns = "[<font color='yellow'><b>skip</b></font>]" | 211 | local dns = "[<font color='gray'><b>skip</b></font>]" |
189 | local protocol = status(k, results, "Protocol") | 212 | local protocol = status(k, results, "Protocol") |
190 | local sanity = "[<font color='yellow'><b>skip</b></font>]" | 213 | local sanity = "[<font color='gray'><b>skip</b></font>]" |
191 | local integrity = "[<font color='yellow'><b>skip</b></font>]" | 214 | local integrity = "[<font color='gray'><b>skip</b></font>]" |
192 | local updated = "[<font color='yellow'><b>skip</b></font>]" | 215 | local updated = "[<font color='gray'><b>skip</b></font>]" |
193 | file:write(" http: " .. http .. " https: " .. https .. " DNS-RR: " .. dns .. " Protocol: " .. protocol .. " URL-sanity: " .. sanity .. " Integrity: " .. integrity .. " Updated: " .. updated .. "\n<br>\n") | 216 | file:write("<td>http: " .. http .. "</td><td>https: " .. https .. "</td><td>DNS-RR: " .. |
217 | dns .. "</td><td>Protocol: " .. protocol .. "</td><td>URL-sanity: " .. sanity .. | ||
218 | "</td><td>Integrity: " .. integrity .. "</td><td>Updated: " .. updated .. "</td></tr>\n") | ||
194 | end | 219 | end |
195 | file:write( "==== faulty mirrors: ====<br>\n<br>\n" .. faulty) | 220 | file:write( "</table>\n==== faulty mirrors: ====<br>\n<br>\n" .. faulty) |
196 | file:write( "\n<br>\nLast Failure: NOT WRITTEN YET<br>\n<br>") | 221 | file:write( "\n<br>\nLast Failure: NOT WRITTEN YET<br>\n<br>") |
222 | |||
223 | for k, v in pairs(mirrors) do | ||
224 | local n = {} | ||
225 | mirrors[k].Protocols = nil | ||
226 | mirrors[k].FQDN = nil | ||
227 | mirrors[k].Active = nil | ||
228 | mirrors[k].Rate = nil | ||
229 | mirrors[k].BaseURL = nil | ||
230 | mirrors[k].Country = nil | ||
231 | mirrors[k].Bandwidth = nil | ||
232 | for l, w in pairs(mirrors[k].IPs) do | ||
233 | if type(w) == "table" then | ||
234 | n[l] = {} | ||
235 | for i, u in pairs(w) do | ||
236 | local nm = "LOG_" .. k .. "_" .. i .. ".html" | ||
237 | local rfile, e = io.open("results/" .. nm, "r") | ||
238 | if nil ~= rfile then | ||
239 | rfile:close() | ||
240 | n[l]["<a href='" .. nm .. "'>" .. i .. "</a>"] = u | ||
241 | else | ||
242 | n[l][i] = u | ||
243 | end | ||
244 | end | ||
245 | else | ||
246 | local nm = "LOG_" .. k .. "_" .. l .. ".html" | ||
247 | local rfile, e = io.open("results/" .. nm, "r") | ||
248 | if nil ~= rfile then | ||
249 | rfile:close() | ||
250 | n["<a href='" .. nm .. "'>" .. l .. "</a>"] = w | ||
251 | else | ||
252 | n[l] = w | ||
253 | end | ||
254 | end | ||
255 | end | ||
256 | m[k .. " DNS entries -"] = n | ||
257 | end | ||
258 | file:write("<br>\n<br>\n<br>\n" .. | ||
259 | "<p>This DNS report lists each mirror, and the DNS entries for that mirror. " .. | ||
260 | "If a mirror has a CNAME, that CNAME is listed along with that CNAMEs DNS entries. " .. | ||
261 | "deb.devuan.org is the DNS round robin, which points to the mirrors that are part of the DNS-RR. " .. | ||
262 | "pkgmaster.devuan.org is the master mirror, all the others sync to it. " .. | ||
263 | "The links point to the log files for each FDQN / IP combination that was checked. " .. | ||
264 | "</p>\n<br><br>" | ||
265 | ) | ||
266 | file:write(dumpTableHTML(m, "", "")) | ||
197 | file:write( "\n<br>\n\n</body></html>\n") | 267 | file:write( "\n<br>\n\n</body></html>\n") |
198 | file:close() | 268 | file:close() |
199 | end | 269 | end |