mirror of
https://github.com/f-droid/fdroidserver.git
synced 2026-03-28 20:02:09 -04:00
Merge branch 'fix-mirrors-dns-entries' into 'master'
index: make sure DNS records are in the "mirrors" list See merge request fdroid/fdroidserver!1797
This commit is contained in:
@@ -112,15 +112,6 @@ def make(apps, apks, repodir, archive):
|
||||
'archive_url', common.config['repo_url'][:-4] + 'archive'
|
||||
)
|
||||
repodict['address'] = archive_url
|
||||
|
||||
# do dns lookup and store results for later use
|
||||
ip4_array = get_dnsa_results(archive_url)
|
||||
if len(ip4_array) > 0:
|
||||
repodict['dnsA'] = ip4_array
|
||||
ip6_array = get_dnsaaaa_results(archive_url)
|
||||
if len(ip6_array) > 0:
|
||||
repodict['dnsAAAA'] = ip6_array
|
||||
|
||||
if 'archive_web_base_url' in common.config:
|
||||
repodict["webBaseUrl"] = common.config['archive_web_base_url']
|
||||
repo_section = os.path.basename(urllib.parse.urlparse(archive_url).path)
|
||||
@@ -128,15 +119,6 @@ def make(apps, apks, repodir, archive):
|
||||
repodict['name'] = common.config['repo_name']
|
||||
repodict['icon'] = repo_icon
|
||||
repodict['address'] = common.config['repo_url']
|
||||
|
||||
# do dns lookup and store results for later use
|
||||
ip4_array = get_dnsa_results(common.config['repo_url'])
|
||||
if len(ip4_array) > 0:
|
||||
repodict['dnsA'] = ip4_array
|
||||
ip6_array = get_dnsaaaa_results(common.config['repo_url'])
|
||||
if len(ip6_array) > 0:
|
||||
repodict['dnsAAAA'] = ip6_array
|
||||
|
||||
if 'repo_web_base_url' in common.config:
|
||||
repodict["webBaseUrl"] = common.config['repo_web_base_url']
|
||||
repodict['description'] = common.config['repo_description']
|
||||
@@ -758,7 +740,7 @@ def v2_repo(repodict, repodir, archive):
|
||||
repo["icon"] = localized_config["icon"]
|
||||
|
||||
repo["address"] = repodict["address"]
|
||||
for key in 'dnsA', 'dnsAAAA', 'mirrors', 'webBaseUrl':
|
||||
for key in 'mirrors', 'webBaseUrl':
|
||||
if key in repodict:
|
||||
repo[key] = repodict[key]
|
||||
|
||||
@@ -1730,15 +1712,6 @@ def add_mirrors_to_repodict(repo_section, repodict):
|
||||
found_primary = False
|
||||
errors = 0
|
||||
for mirror in mirrors:
|
||||
|
||||
# do dns lookup to store results for later use
|
||||
ip4_array = get_dnsa_results(mirror['url'])
|
||||
if len(ip4_array) > 0:
|
||||
repodict['dnsA'] = ip4_array
|
||||
ip6_array = get_dnsaaaa_results(mirror['url'])
|
||||
if len(ip6_array) > 0:
|
||||
repodict['dnsAAAA'] = ip6_array
|
||||
|
||||
if canonical_url == mirror['url']:
|
||||
found_primary = True
|
||||
mirror['isPrimary'] = True
|
||||
@@ -1761,12 +1734,17 @@ def add_mirrors_to_repodict(repo_section, repodict):
|
||||
|
||||
if repodict['mirrors'] and not found_primary:
|
||||
primary = {'isPrimary': True, 'url': repodict['address']}
|
||||
if 'dnsA' in repodict:
|
||||
primary['dnsA'] = repodict['dnsA']
|
||||
if 'dnsAAAA' in repodict:
|
||||
primary['dnsAAAA'] = repodict['dnsAAAA']
|
||||
repodict['mirrors'].insert(0, primary)
|
||||
|
||||
for mirror in repodict['mirrors']:
|
||||
# do dns lookup to store results for later use
|
||||
ip4_array = get_dnsa_results(mirror['url'])
|
||||
if len(ip4_array) > 0:
|
||||
mirror['dnsA'] = ip4_array
|
||||
ip6_array = get_dnsaaaa_results(mirror['url'])
|
||||
if len(ip6_array) > 0:
|
||||
mirror['dnsAAAA'] = ip6_array
|
||||
|
||||
|
||||
def get_mirror_service_urls(mirror):
|
||||
"""Get direct URLs from git service for use by fdroidclient.
|
||||
|
||||
@@ -1718,13 +1718,12 @@ class IntegrationTest(unittest.TestCase):
|
||||
self.fdroid_init_with_prebuilt_keystore()
|
||||
self.update_yaml(
|
||||
common.CONFIG_FILE,
|
||||
{"include_dns_lookups": True, "mirrors": ["https://f-droid.org/fdroid"]},
|
||||
{"include_dns_lookups": True, "mirrors": ["https://ftp.fau.de/fdroid"]},
|
||||
)
|
||||
self.assert_run(self.fdroid_cmd + ["update", "--pretty", "--nosign"])
|
||||
with open('repo/index-v2.json') as fp:
|
||||
data = json.load(fp)
|
||||
self.assertIsNotNone(data['repo'].get('dnsA'))
|
||||
self.assertIsNotNone(data['repo']['mirrors'][0].get('dnsA'))
|
||||
if supports_ipv6():
|
||||
self.assertIsNotNone(data['repo'].get('dnsAAAA'))
|
||||
self.assertIsNotNone(data['repo']['mirrors'][0].get('dnsAAAA'))
|
||||
for mirror in data['repo']['mirrors']:
|
||||
self.assertIsNotNone(mirror['dnsA'])
|
||||
if supports_ipv6():
|
||||
self.assertIsNotNone(mirror['dnsAAAA'])
|
||||
|
||||
Reference in New Issue
Block a user