Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns: T6422: allow multiple redundant NS records (backport #3557) #3568

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions interface-definitions/service_dns_forwarding.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
<constraint>
<regex>[-_a-zA-Z0-9.]{1,63}(?&lt;!\.)</regex>
</constraint>
<multi/>
</properties>
</leafNode>
#include <include/dns/time-to-live.xml.i>
Expand Down
10 changes: 10 additions & 0 deletions smoketest/scripts/cli/test_service_dns_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,15 @@ def test_edns_subnet_allow_list(self):
tmp = get_config_value('edns-subnet-allow-list')
self.assertEqual(tmp, ','.join(options))

def test_multiple_ns_records(self):
test_zone = 'example.com'
self.cli_set(base_path + ['authoritative-domain', test_zone, 'records', 'ns', 'test', 'target', f'ns1.{test_zone}'])
self.cli_set(base_path + ['authoritative-domain', test_zone, 'records', 'ns', 'test', 'target', f'ns2.{test_zone}'])
self.cli_commit()
zone_config = read_file(f'{PDNS_REC_RUN_DIR}/zone.{test_zone}.conf')
self.assertRegex(zone_config, fr'test\s+\d+\s+NS\s+ns1\.{test_zone}\.')
self.assertRegex(zone_config, fr'test\s+\d+\s+NS\s+ns2\.{test_zone}\.')


if __name__ == '__main__':
unittest.main(verbosity=2)
15 changes: 14 additions & 1 deletion src/conf_mode/service_dns_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_config(config=None):
'ttl': rdata['ttl'],
'value': address
})
elif rtype in ['cname', 'ptr', 'ns']:
elif rtype in ['cname', 'ptr']:
if not 'target' in rdata:
dns['authoritative_zone_errors'].append(f'{subnode}.{node}: target is required')
continue
Expand All @@ -113,6 +113,19 @@ def get_config(config=None):
'ttl': rdata['ttl'],
'value': '{}.'.format(rdata['target'])
})
elif rtype == 'ns':
if not 'target' in rdata:
dns['authoritative_zone_errors'].append(f'{subnode}.{node}: at least one target is required')
continue

for target in rdata['target']:
zone['records'].append({
'name': subnode,
'type': rtype.upper(),
'ttl': rdata['ttl'],
'value': f'{target}.'
})

elif rtype == 'mx':
if not 'server' in rdata:
dns['authoritative_zone_errors'].append(f'{subnode}.{node}: at least one server is required')
Expand Down
Loading