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 = [ unique_records = [
dict(record_tuple) dict(record_tuple)
for record_tuple in set( for record_tuple in set(

View file

@ -1,4 +1,5 @@
from ipaddress import ip_interface from ipaddress import ip_interface
from json import dumps
defaults = { defaults = {
@ -74,11 +75,12 @@ def collect_records(metadata):
for type, values in records.items(): for type, values in records.items():
for value in values: for value in values:
entry = {'name': name, 'type': type, 'value': value}
zones\ zones\
.setdefault(zone, [])\ .setdefault(zone, {})\
.append( .update({
{'name': name, 'type': type, 'value': value} str(hash(dumps(entry))): entry,
) })
return { return {
'bind': { 'bind': {
@ -104,10 +106,11 @@ def ns_records(metadata):
return { return {
'bind': { 'bind': {
'zones': { 'zones': {
zone: [ zone: {
{'name': '@', 'type': 'NS', 'value': f"{nameserver}."} # 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 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'], 'A': ['162.55.188.157'],
'AAAA': ['2a01:4f8:1c1c:4121::2'], 'AAAA': ['2a01:4f8:1c1c:4121::2'],
}, },
'sublimity.de': {
'A': ['162.55.188.157'],
'AAAA': ['2a01:4f8:1c1c:4121::2'],
},
'freibrief.net': { 'freibrief.net': {
'A': ['162.55.188.157'], 'A': ['162.55.188.157'],
'AAAA': ['2a01:4f8:1c1c:4121::2'], 'AAAA': ['2a01:4f8:1c1c:4121::2'],