diff options
-rw-r--r-- | apt-panopticommon.lua | 19 | ||||
-rwxr-xr-x | apt-panopticon.lua | 37 |
2 files changed, 33 insertions, 23 deletions
diff --git a/apt-panopticommon.lua b/apt-panopticommon.lua index 221c7e3..9de97b4 100644 --- a/apt-panopticommon.lua +++ b/apt-panopticommon.lua | |||
@@ -483,6 +483,17 @@ local E = APT.E | |||
483 | local C = APT.C | 483 | local C = APT.C |
484 | 484 | ||
485 | 485 | ||
486 | APT.readCmd = function(cmd) | ||
487 | local result = {} | ||
488 | local output = io.popen(cmd) | ||
489 | if nil ~= output then | ||
490 | for l in output:lines() do | ||
491 | table.insert(result, l) | ||
492 | end | ||
493 | end | ||
494 | return result | ||
495 | end | ||
496 | |||
486 | APT.debians = {} | 497 | APT.debians = {} |
487 | APT.mirrors = {} | 498 | APT.mirrors = {} |
488 | 499 | ||
@@ -559,10 +570,10 @@ APT.exe = function(c) | |||
559 | I'm getting 7168 or 0. No idea what the fuck that is. | 570 | I'm getting 7168 or 0. No idea what the fuck that is. |
560 | local ok, rslt, status = os.execute(s) | 571 | local ok, rslt, status = os.execute(s) |
561 | ]] | 572 | ]] |
562 | local f = io.popen(self.cmd .. ' ; echo "$?"', 'r') | 573 | local f = APT.readCmd(self.cmd .. ' ; echo "$?"', 'r') |
563 | -- The last line will be the command's returned status, collect everything else in result. | 574 | -- The last line will be the command's returned status, collect everything else in result. |
564 | self.status = '' -- Otherwise the result starts with 0. | 575 | self.status = '' -- Otherwise the result starts with 0. |
565 | for l in f:lines() do | 576 | for i,l in ipairs(f) do |
566 | self.result = self.result .. self.status .. "\n" | 577 | self.result = self.result .. self.status .. "\n" |
567 | self.status = l | 578 | self.status = l |
568 | end | 579 | end |
@@ -579,7 +590,9 @@ APT.exe = function(c) | |||
579 | end | 590 | end |
580 | 591 | ||
581 | APT.checkExes = function (exe) | 592 | APT.checkExes = function (exe) |
582 | local count = io.popen('ps x | grep "' .. exe .. '" | grep -v " grep " | grep -v "flock -n apt-panopticon.lock " | wc -l'):read("*l") | 593 | local count = 0 |
594 | local ps = io.popen('ps x | grep "' .. exe .. '" | grep -v " grep " | grep -v "flock -n apt-panopticon.lock " | wc -l') | ||
595 | if nil ~= ps then count = ps:read("*l") end | ||
583 | D(count .. " " .. exe .. " commands still running.") | 596 | D(count .. " " .. exe .. " commands still running.") |
584 | return tonumber(count) | 597 | return tonumber(count) |
585 | end | 598 | end |
diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 8543210..482a2ac 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua | |||
@@ -175,24 +175,21 @@ gatherIPs = function (host) | |||
175 | -- Takes about 30 seconds to look up the lot. | 175 | -- Takes about 30 seconds to look up the lot. |
176 | -- I tested using dig's -f option, it didn't seem much faster. | 176 | -- I tested using dig's -f option, it didn't seem much faster. |
177 | -- The sort -r assumes that deb.devuan.org is the first alphabetically. | 177 | -- The sort -r assumes that deb.devuan.org is the first alphabetically. |
178 | local dig = io.popen('dig +keepopen +noall +nottlid +answer ' .. host .. ' A ' .. host .. ' AAAA ' .. host .. ' CNAME ' .. host .. ' SRV | sort -r | uniq') | 178 | local dig = APT.readCmd('dig +keepopen +noall +nottlid +answer ' .. host .. ' A ' .. host .. ' AAAA ' .. host .. ' CNAME ' .. host .. ' SRV | sort -r | uniq') |
179 | repeat | 179 | for i,IPs in ipairs(dig) do |
180 | IPs = dig:read("*l") | 180 | for k, t, v in IPs:gmatch("([%w_%-%.]*)%.%s*IN%s*(%a*)%s*(.*)") do |
181 | if nil ~= IPs then | 181 | if "." == v:sub(-1, -1) then v = v:sub(1, -2) end |
182 | for k, t, v in IPs:gmatch("([%w_%-%.]*)%.%s*IN%s*(%a*)%s*(.*)") do | 182 | if nil == IP[k] then IP[k] = {} end |
183 | if "." == v:sub(-1, -1) then v = v:sub(1, -2) end | 183 | IP[k][v] = t |
184 | if nil == IP[k] then IP[k] = {} end | 184 | D(" DNS record " .. host .. " == " .. k .. " type " .. t .. " -> " .. v) |
185 | IP[k][v] = t | 185 | if t == "CNAME" then |
186 | D(" DNS record " .. host .. " == " .. k .. " type " .. t .. " -> " .. v) | 186 | gatherIPs(v) |
187 | if t == "CNAME" then | 187 | IP[k][v] = IP[v] |
188 | gatherIPs(v) | 188 | elseif v == "SRV" then |
189 | IP[k][v] = IP[v] | 189 | print("SVR record found, now what do we do?") |
190 | elseif v == "SRV" then | ||
191 | print("SVR record found, now what do we do?") | ||
192 | end | ||
193 | end | 190 | end |
194 | end | 191 | end |
195 | until nil == IPs | 192 | end |
196 | end | 193 | end |
197 | 194 | ||
198 | -- If this is the DNS-RR domain name, gather the IPs for the mirrors that mirror_list.txt says should be in it. | 195 | -- If this is the DNS-RR domain name, gather the IPs for the mirrors that mirror_list.txt says should be in it. |
@@ -1179,8 +1176,8 @@ else | |||
1179 | local APT_args = APT.args | 1176 | local APT_args = APT.args |
1180 | local APT_logFile = APT.logFile | 1177 | local APT_logFile = APT.logFile |
1181 | local debians = {} | 1178 | local debians = {} |
1182 | local srvs = io.popen('ls -1 results/*.lua') | 1179 | local srvs = APT.readCmd('ls -1 results/*.lua') |
1183 | for l in srvs:lines() do | 1180 | for ii,l in ipairs(srvs) do |
1184 | local hst = l:sub(9, -5) | 1181 | local hst = l:sub(9, -5) |
1185 | if nil ~= l:find('_R%.lua') then hst = hst:sub(1, -3) end | 1182 | if nil ~= l:find('_R%.lua') then hst = hst:sub(1, -3) end |
1186 | if (hst:find('_') == nil) and (nil == APT.mirrors[hst]) then | 1183 | if (hst:find('_') == nil) and (nil == APT.mirrors[hst]) then |
@@ -1197,8 +1194,8 @@ else | |||
1197 | end | 1194 | end |
1198 | end | 1195 | end |
1199 | end | 1196 | end |
1200 | local files = io.popen('ls -1 results/LOG_' .. hst .. '_*.html') | 1197 | local files = APT.readCmd('ls -1 results/LOG_' .. hst .. '_*.html') |
1201 | for ll in files:lines() do | 1198 | for iii,ll in ipairs(files) do |
1202 | local dn = false | 1199 | local dn = false |
1203 | for i, a in pairs(ips) do | 1200 | for i, a in pairs(ips) do |
1204 | if type(a) == 'table' then | 1201 | if type(a) == 'table' then |