Browse Source

Merge pull request #1019 from octodns/tiny-dns-trailing-dot

Correctly handle trailing . in TinyDNS source fqdns
pull/1024/head
Ross McFarland 2 years ago
committed by GitHub
parent
commit
1032abf558
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +7
    -4
      octodns/source/tinydns.py
  3. +6
    -6
      tests/zones/tinydns/example.com

+ 1
- 0
CHANGELOG.md View File

@ -5,6 +5,7 @@
ownership to be marked in the same zone for delegation NS records. ownership to be marked in the same zone for delegation NS records.
* octodns-report access --lenient flag to allow running reports with records * octodns-report access --lenient flag to allow running reports with records
sourced from providers with non-compliant record data. sourced from providers with non-compliant record data.
* Correctly handle FQDNs in TinyDNS config files that end with trailing .'s
## v1.0.0.rc0 - 2023-05-16 - First of the ones ## v1.0.0.rc0 - 2023-05-16 - First of the ones


+ 7
- 4
octodns/source/tinydns.py View File

@ -133,7 +133,7 @@ class TinyDnsBaseSource(BaseSource):
'3': 'AAAA', '3': 'AAAA',
'6': 'AAAA', '6': 'AAAA',
} }
name_re = re.compile(fr'((?P<name>.+)\.)?{zone.name[:-1]}$')
name_re = re.compile(fr'((?P<name>.+)\.)?{zone.name[:-1]}\.?$')
data = defaultdict(lambda: defaultdict(list)) data = defaultdict(lambda: defaultdict(list))
for line in self._lines(): for line in self._lines():
@ -172,7 +172,7 @@ class TinyDnsBaseSource(BaseSource):
) )
def _populate_in_addr_arpa(self, zone, lenient): def _populate_in_addr_arpa(self, zone, lenient):
name_re = re.compile(fr'(?P<name>.+)\.{zone.name[:-1]}$')
name_re = re.compile(fr'(?P<name>.+)\.{zone.name[:-1]}\.?$')
for line in self._lines(): for line in self._lines():
_type = line[0] _type = line[0]
@ -188,11 +188,11 @@ class TinyDnsBaseSource(BaseSource):
if line[0].endswith('in-addr.arpa'): if line[0].endswith('in-addr.arpa'):
# since it's already in in-addr.arpa format # since it's already in in-addr.arpa format
match = name_re.match(line[0]) match = name_re.match(line[0])
value = f'{line[1]}.'
value = line[1]
else: else:
addr = ip_address(line[1]) addr = ip_address(line[1])
match = name_re.match(addr.reverse_pointer) match = name_re.match(addr.reverse_pointer)
value = f'{line[0]}.'
value = line[0]
if match: if match:
try: try:
@ -200,6 +200,9 @@ class TinyDnsBaseSource(BaseSource):
except IndexError: except IndexError:
ttl = self.default_ttl ttl = self.default_ttl
if value[-1] != '.':
value = f'{value}.'
name = match.group('name') name = match.group('name')
record = Record.new( record = Record.new(
zone, zone,


+ 6
- 6
tests/zones/tinydns/example.com View File

@ -4,12 +4,12 @@
# Multi-value A # Multi-value A
+example.com:10.2.3.4:30 +example.com:10.2.3.4:30
+example.com:10.2.3.5:30
+example.com.:10.2.3.5:30
Ccname.other.foo:www.other.foo Ccname.other.foo:www.other.foo
# A+PTR # A+PTR
=some-host-abc123.example.com:10.2.3.7:1800
=some-host-abc123.example.com.:10.2.3.7:1800
# A+PTR with duplicate address, fine for A's, but warning on PTRs # A+PTR with duplicate address, fine for A's, but warning on PTRs
=has-dup-def123.example.com:10.2.3.8 =has-dup-def123.example.com:10.2.3.8
=has-dup-def456.example.com:10.2.3.8 =has-dup-def456.example.com:10.2.3.8
@ -26,21 +26,21 @@ Ccname.other.foo:www.other.foo
# MX # MX
@example.com::smtp-1-host.example.com:10 @example.com::smtp-1-host.example.com:10
@example.com::smtp-2-host.example.com:20
@example.com.::smtp-2-host.example.com:20
# MX with ttl # MX with ttl
@smtp.example.com::smtp-1-host.example.com:30:1800 @smtp.example.com::smtp-1-host.example.com:30:1800
@smtp.example.com::smtp-2-host.example.com:40:1800
@smtp.example.com.::smtp-2-host.example.com:40:1800
# NS # NS
.sub.example.com::ns3.ns.com:30 .sub.example.com::ns3.ns.com:30
.sub.example.com::ns4.ns.com:30
.sub.example.com.::ns4.ns.com:30
# A, under sub # A, under sub
+www.sub.example.com::1.2.3.4 +www.sub.example.com::1.2.3.4
# Top-level NS # Top-level NS
.example.com::ns1.ns.com .example.com::ns1.ns.com
.example.com::ns2.ns.com
.example.com.::ns2.ns.com
# sub special cases # sub special cases
+a1.blah-asdf.subtest.com:10.2.3.5 +a1.blah-asdf.subtest.com:10.2.3.5


Loading…
Cancel
Save