From d7ebcf2ef20dc356cbea2c070cd9eca2d9abaaf0 Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 24 Dec 2019 19:33:27 +1000 Subject: Slightly better forking and testing for redirection. --- apt-panopticon.lua | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/apt-panopticon.lua b/apt-panopticon.lua index 49f7f6d..45a591f 100755 --- a/apt-panopticon.lua +++ b/apt-panopticon.lua @@ -934,26 +934,28 @@ if 0 < #arg then if nil ~= arg[3] then I(" Using file " .. arg[3]); end APT.results = APT.padResults(APT.results) - if APT.origin or APT.redir then + if APT.origin then local file = arg[3] if nil == file then file = '' end local path = pu.path if nil == path then path = '' end - local ips = APT.results["IPs"] - for k, v in pairs(ips) do - if "table" == type(v) then - for k1, v1 in pairs(v) do - if v1 == "A" then - if APT.testing("IPv4") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k1 .. " " .. file) end - elseif v1 == "AAAA" then - if APT.testing("IPv6") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k1 .. " " .. file) end + if APT.origin then + local ips = APT.results["IPs"] + for k, v in pairs(ips) do + if "table" == type(v) then + for k1, v1 in pairs(v) do + if v1 == "A" then + if APT.testing("IPv4") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k1 .. " " .. file) end + elseif v1 == "AAAA" then + if APT.testing("IPv6") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k1 .. " " .. file) end + end + end + else + if v == "A" then + if APT.testing("IPv4") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k .. " " .. file) end + elseif v == "AAAA" then + if APT.testing("IPv6") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k .. " " .. file) end end - end - else - if v == "A" then - if APT.testing("IPv4") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k .. " " .. file) end - elseif v == "AAAA" then - if APT.testing("IPv6") then APT.fork("ionice -c3 ./apt-panopticon.lua " .. sendArgs .. " " .. pu.host .. path .. " " .. k .. " " .. file) end end end end -- cgit v1.1