This commit is contained in:
mwiegand 2021-10-09 14:37:52 +02:00
parent 0e534380e3
commit ebac40506e
3 changed files with 16 additions and 8 deletions

View file

@ -136,7 +136,8 @@ for view in views:
],
}
for zone, records in zones.items():
for zone, record_dicts in zones.items():
records = record_dicts.values()
unique_records = [
dict(record_tuple)
for record_tuple in set(

View file

@ -1,4 +1,5 @@
from ipaddress import ip_interface
from json import dumps
defaults = {
@ -74,11 +75,12 @@ def collect_records(metadata):
for type, values in records.items():
for value in values:
entry = {'name': name, 'type': type, 'value': value}
zones\
.setdefault(zone, [])\
.append(
{'name': name, 'type': type, 'value': value}
)
.setdefault(zone, {})\
.update({
str(hash(dumps(entry))): entry,
})
return {
'bind': {
@ -104,10 +106,11 @@ def ns_records(metadata):
return {
'bind': {
'zones': {
zone: [
{'name': '@', 'type': 'NS', 'value': f"{nameserver}."}
zone: {
# FIXME: bw currently cant handle lists of dicts :(
str(hash(dumps({'name': '@', 'type': 'NS', 'value': f"{nameserver}."}))): {'name': '@', 'type': 'NS', 'value': f"{nameserver}."}
for nameserver in nameservers
] for zone in metadata.get('bind/zones').keys()
} for zone in metadata.get('bind/zones').keys()
},
},
}

View file

@ -50,6 +50,10 @@
'A': ['162.55.188.157'],
'AAAA': ['2a01:4f8:1c1c:4121::2'],
},
'sublimity.de': {
'A': ['162.55.188.157'],
'AAAA': ['2a01:4f8:1c1c:4121::2'],
},
'freibrief.net': {
'A': ['162.55.188.157'],
'AAAA': ['2a01:4f8:1c1c:4121::2'],