diff options
| author | onefang | 2019-12-27 13:53:50 +1000 |
|---|---|---|
| committer | onefang | 2019-12-27 13:53:50 +1000 |
| commit | 73808f2d16a80c350ba420a5d88823e0be509b1b (patch) | |
| tree | 783e36eac4fbaf9ef2be36a68ae2b6efa64695bf /apt-panopticon-update-data.lua | |
| parent | Optimise updater a tiny bit. (diff) | |
| download | apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.zip apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.tar.gz apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.tar.bz2 apt-panopticon-73808f2d16a80c350ba420a5d88823e0be509b1b.tar.xz | |
Add timeouts tracking.
Diffstat (limited to '')
| -rwxr-xr-x | apt-panopticon-update-data.lua | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/apt-panopticon-update-data.lua b/apt-panopticon-update-data.lua index 57eddd9..ceef7f3 100755 --- a/apt-panopticon-update-data.lua +++ b/apt-panopticon-update-data.lua | |||
| @@ -11,6 +11,35 @@ local arg, sendArgs = APT.parseArgs({...}) | |||
| 11 | 11 | ||
| 12 | local oldest = 0 | 12 | local oldest = 0 |
| 13 | 13 | ||
| 14 | local fixResults = function(f) | ||
| 15 | if APT.checkFile(f) then | ||
| 16 | local results = loadfile(f)() | ||
| 17 | results = APT.padResults(results) | ||
| 18 | for i, w in pairs(APT.protocols) do | ||
| 19 | tests = results[w] | ||
| 20 | if nil ~= tests.Redirects then | ||
| 21 | tests.redirects = tests.Redirects | ||
| 22 | tests.Redirects = nil | ||
| 23 | elseif nil == tests.redirects then | ||
| 24 | tests.redirects = {} | ||
| 25 | end | ||
| 26 | results[w] = tests | ||
| 27 | end | ||
| 28 | if nil ~= results.Redirects then | ||
| 29 | for i, w in pairs(APT.protocols) do | ||
| 30 | results[w].redirects = results.Redirects | ||
| 31 | end | ||
| 32 | results.Redirects = nil | ||
| 33 | end | ||
| 34 | local rfile, e = io.open(f, "w+") | ||
| 35 | if nil == rfile then C("opening results file - " .. e) else | ||
| 36 | rfile:write(APT.dumpTable(results, "", "results") .. "\nreturn results\n") | ||
| 37 | rfile:close() | ||
| 38 | end | ||
| 39 | end | ||
| 40 | end | ||
| 41 | |||
| 42 | |||
| 14 | local lock = 'apt-panopticon.lock' | 43 | local lock = 'apt-panopticon.lock' |
| 15 | while APT.checkFile(lock) do os.execute('sleep 10') end | 44 | while APT.checkFile(lock) do os.execute('sleep 10') end |
| 16 | os.execute('touch ' .. lock) | 45 | os.execute('touch ' .. lock) |
| @@ -53,7 +82,6 @@ for l in files:lines() do | |||
| 53 | local f = l:sub(1, -8) .. "/" .. k .. ".lua" | 82 | local f = l:sub(1, -8) .. "/" .. k .. ".lua" |
| 54 | if APT.checkFile(f) then | 83 | if APT.checkFile(f) then |
| 55 | results = loadfile(f)() | 84 | results = loadfile(f)() |
| 56 | results = APT.padResults(results) | ||
| 57 | results['IPs'] = v.IPs | 85 | results['IPs'] = v.IPs |
| 58 | local rfile, e = io.open(f, "w+") | 86 | local rfile, e = io.open(f, "w+") |
| 59 | if nil == rfile then C("opening results file - " .. e) else | 87 | if nil == rfile then C("opening results file - " .. e) else |
| @@ -63,6 +91,10 @@ for l in files:lines() do | |||
| 63 | end | 91 | end |
| 64 | end | 92 | end |
| 65 | end | 93 | end |
| 94 | local fls = io.popen('ls -1 ' .. lsub .. '/*.lua 2>/dev/null') | ||
| 95 | for k in fls:lines() do | ||
| 96 | fixResults(k) | ||
| 97 | end | ||
| 66 | end | 98 | end |
| 67 | 99 | ||
| 68 | 100 | ||
