diff options
author | onefang | 2019-12-13 03:16:12 +1000 |
---|---|---|
committer | onefang | 2019-12-13 03:16:12 +1000 |
commit | 018259f210c2e8addd76dd24969803a3529a553d (patch) | |
tree | 8c8244c39e65955b3ad56e9935d05374be9dbd22 | |
parent | Comment++ (diff) | |
download | apt-panopticon-018259f210c2e8addd76dd24969803a3529a553d.zip apt-panopticon-018259f210c2e8addd76dd24969803a3529a553d.tar.gz apt-panopticon-018259f210c2e8addd76dd24969803a3529a553d.tar.bz2 apt-panopticon-018259f210c2e8addd76dd24969803a3529a553d.tar.xz |
Refactor the protocols table.
-rw-r--r-- | apt-panopticommon.lua | 12 | ||||
-rwxr-xr-x | apt-panopticon-report-email-web.lua | 3 | ||||
-rwxr-xr-x | apt-panopticon.lua | 3 |
3 files changed, 14 insertions, 4 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua index 182d90c..22354f3 100644 --- a/apt-panopticommon.lua +++ b/apt-panopticommon.lua | |||
@@ -3,6 +3,8 @@ local APT = {} | |||
3 | -- https://oss.oetiker.ch/rrdtool/prog/rrdlua.en.html | 3 | -- https://oss.oetiker.ch/rrdtool/prog/rrdlua.en.html |
4 | APT.rrd = require 'rrd' | 4 | APT.rrd = require 'rrd' |
5 | 5 | ||
6 | APT.protocols = {"ftp", "http", "https", "rsync"} | ||
7 | |||
6 | verbosity = -1 | 8 | verbosity = -1 |
7 | APT.origin = false | 9 | APT.origin = false |
8 | APT.keep = false | 10 | APT.keep = false |
@@ -247,6 +249,13 @@ dumpTableSub = function (table, space) | |||
247 | return r | 249 | return r |
248 | end | 250 | end |
249 | 251 | ||
252 | APT.search = function(t, s) | ||
253 | for i, v in pairs(t) do | ||
254 | if v == s then return true end | ||
255 | end | ||
256 | return false | ||
257 | end | ||
258 | |||
250 | APT.results = {} | 259 | APT.results = {} |
251 | APT.logFile = nil | 260 | APT.logFile = nil |
252 | APT.html = false | 261 | APT.html = false |
@@ -392,7 +401,7 @@ APT.plurals = function(e, w) | |||
392 | end | 401 | end |
393 | 402 | ||
394 | APT.padResults = function(results) | 403 | APT.padResults = function(results) |
395 | for k, v in pairs{"ftp", "http", "https", "rsync"} do | 404 | for k, v in pairs(APT.protocols) do |
396 | tests = results[v] | 405 | tests = results[v] |
397 | if nil == tests then tests = {errors = 0; warnings = 0} end | 406 | if nil == tests then tests = {errors = 0; warnings = 0} end |
398 | if nil == tests.Integrity then tests.Integrity = {errors = 0; warnings = 0} end | 407 | if nil == tests.Integrity then tests.Integrity = {errors = 0; warnings = 0} end |
@@ -477,7 +486,6 @@ APT.now = 0 | |||
477 | local status | 486 | local status |
478 | status, APT.now = APT.execute('TZ="GMT" ls -l --time-style="+%s" results/stamp | cut -d " " -f 6-6') | 487 | status, APT.now = APT.execute('TZ="GMT" ls -l --time-style="+%s" results/stamp | cut -d " " -f 6-6') |
479 | APT.now = tonumber(APT.now) | 488 | APT.now = tonumber(APT.now) |
480 | APT.protocols = {'ftp', 'http', 'https', 'rsync'} | ||
481 | APT.tests = {'raw', 'Integrity', 'Protocol', 'Updated', 'URLSanity', 'Speed'} | 489 | APT.tests = {'raw', 'Integrity', 'Protocol', 'Updated', 'URLSanity', 'Speed'} |
482 | local start = 'now-2week' | 490 | local start = 'now-2week' |
483 | local step = '10min' | 491 | local step = '10min' |
diff --git a/apt-panopticon-report-email-web.lua b/apt-panopticon-report-email-web.lua index 382b14d..94f0417 100755 --- a/apt-panopticon-report-email-web.lua +++ b/apt-panopticon-report-email-web.lua | |||
@@ -49,7 +49,8 @@ local status = function(host, results, typ) | |||
49 | local w = 0 | 49 | local w = 0 |
50 | local s = nil ~= APT.mirrors[host].Protocols[typ] | 50 | local s = nil ~= APT.mirrors[host].Protocols[typ] |
51 | local to = results.timeout | 51 | local to = results.timeout |
52 | if ('http' ~= typ) and ('https' ~= typ) and ('ftp' ~= typ) and ('rsync' ~= typ) then s = true end | 52 | -- if ('http' ~= typ) and ('https' ~= typ) and ('ftp' ~= typ) and ('rsync' ~= typ) then s = true end |
53 | if not APT.search(APT.protocols, typ) then s = true end | ||
53 | if nil ~= results[typ] then | 54 | if nil ~= results[typ] then |
54 | e = results[typ].errors | 55 | e = results[typ].errors |
55 | w = results[typ].warnings | 56 | w = results[typ].warnings |
diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 62acbf25..8b02626 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua | |||
@@ -606,7 +606,8 @@ local getMirrors = function () | |||
606 | elseif "Protocols" == t then | 606 | elseif "Protocols" == t then |
607 | local prot = {} | 607 | local prot = {} |
608 | for w in d:gmatch("(%w+)") do | 608 | for w in d:gmatch("(%w+)") do |
609 | prot[w] = true; | 609 | -- prot[w] = true; |
610 | if APT.search(APT.protocols, w:lower()) then prot[w] = true end | ||
610 | end | 611 | end |
611 | m[t] = prot | 612 | m[t] = prot |
612 | elseif "Active" == t and nil == d:sub(1, 3):find("yes", 1, true) then | 613 | elseif "Active" == t and nil == d:sub(1, 3):find("yes", 1, true) then |