aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apt-panopticon.lua
diff options
context:
space:
mode:
authoronefang2019-12-14 08:03:02 +1000
committeronefang2019-12-14 08:03:02 +1000
commitdb3ebe1722620d22fcfa33b9fcaca1d7608cb09d (patch)
tree01529fa3a2ac84c83247f89755e7e801059c10df /apt-panopticon.lua
parentDocument the ultimate goal. (diff)
downloadapt-panopticon-db3ebe1722620d22fcfa33b9fcaca1d7608cb09d.zip
apt-panopticon-db3ebe1722620d22fcfa33b9fcaca1d7608cb09d.tar.gz
apt-panopticon-db3ebe1722620d22fcfa33b9fcaca1d7608cb09d.tar.bz2
apt-panopticon-db3ebe1722620d22fcfa33b9fcaca1d7608cb09d.tar.xz
Validate the mirrors_list FQDN and BaseURL.
Also, move the relatd tests into this new function.
Diffstat (limited to '')
-rwxr-xr-xapt-panopticon.lua32
1 files changed, 22 insertions, 10 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index b87bf72..502ed6a 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -580,6 +580,26 @@ local downloads = function(host, URL, meta, release, list)
580end 580end
581 581
582 582
583local validateURL = function(m)
584 if " " == m.BaseURL:sub(-1, -1) then
585 W("space at end of BaseURL in mirror_list.txt! " .. m.BaseURL, "", "", m.FQDN)
586 m.BaseURL = m.BaseURL:sub(1, -2)
587 end
588 if "/" == m.BaseURL:sub(-1, -1) then
589 W("slash at end of BaseURL in mirror_list.txt! " .. m.BaseURL, "", "", m.FQDN)
590 m.BaseURL = m.BaseURL:sub(1, -2)
591 end
592 local p = url.parse("http://" .. m.BaseURL)
593 if nil == p.path then p.path = '' end
594 if nil ~= p.port then p.authority = authority .. ':' .. p.port end
595 if m.FQDN ~= p.authority then W("Something wrong in FDQN from mirror_list.txt! " .. m.FDQN, "", "", p.authority) end
596 if m.BaseURL ~= (p.authority .. p.path) then W("Something wrong in BaseURL from mirror_list.txt! " .. m.BaseURL, "", "", p.authority) end
597 if (nil ~= p.query) or (nil ~= p.fragment) or (nil ~= p.params) then W("Something wrong in BaseURL from mirror_list.txt, should be nothing after the path! " .. m.BaseURL, "", "", p.authority) end
598 if (nil ~= p.user) or (nil ~= p.userinfo) or (nil ~= p.password) then W("Something wrong in BaseURL from mirror_list.txt, should be no credentials! " .. m.BaseURL, "", "", p.authority) end
599 m.FQDN = p.authority
600 m.BaseURL = p.authority .. p.path
601 return m
602end
583local getMirrors = function () 603local getMirrors = function ()
584 local mirrors = {} 604 local mirrors = {}
585 local host = "" 605 local host = ""
@@ -595,7 +615,7 @@ local getMirrors = function ()
595 d = string.lower(d) 615 d = string.lower(d)
596 if "FQDN" == t then 616 if "FQDN" == t then
597 if "" ~= host then 617 if "" ~= host then
598 mirrors[host] = m 618 mirrors[host] = validateURL(m)
599 m = {} 619 m = {}
600 active = true 620 active = true
601 end 621 end
@@ -620,7 +640,7 @@ local getMirrors = function ()
620 end 640 end
621 end 641 end
622 if "" ~= host --[[and active]] then 642 if "" ~= host --[[and active]] then
623 mirrors[host] = m 643 mirrors[host] = validateURL(m)
624 end 644 end
625 end 645 end
626 if APT.testing("DNSRR") then 646 if APT.testing("DNSRR") then
@@ -869,14 +889,6 @@ else
869 checkHost(APT.options.referenceSite.value) 889 checkHost(APT.options.referenceSite.value)
870 890
871 for k, m in pairs(APT.mirrors) do 891 for k, m in pairs(APT.mirrors) do
872 if "/" == m.BaseURL:sub(-1, -1) then
873 W("slash at end of BaseURL in mirror_list.txt! " .. m.BaseURL, "", "", m.FQDN)
874 m.BaseURL = m.BaseURL:sub(1, -2)
875 end
876 if " " == m.BaseURL:sub(-1, -1) then
877 W("space at end of BaseURL in mirror_list.txt! " .. m.BaseURL, "", "", m.FQDN)
878 m.BaseURL = m.BaseURL:sub(1, -2)
879 end
880 local pu = url.parse("http://" .. m.BaseURL) 892 local pu = url.parse("http://" .. m.BaseURL)
881 if APT.options.referenceSite.value ~= pu.host then 893 if APT.options.referenceSite.value ~= pu.host then
882 checkHost(m.BaseURL) 894 checkHost(m.BaseURL)