Skip to content

Commit 55924ff

Browse files
committed
Merge pull request #70 from Marchowes/rttd
Adding Unknown Record.
2 parents f833b39 + be7b33b commit 55924ff

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

dyn/tm/records.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
'CDNSKEYRecord', 'CERTRecord', 'CNAMERecord', 'CSYNCRecord',
1414
'DHCIDRecord', 'DNAMERecord', 'DNSKEYRecord', 'DSRecord',
1515
'KEYRecord', 'KXRecord', 'LOCRecord', 'IPSECKEYRecord', 'MXRecord',
16-
'NAPTRRecord', 'PTRRecord', 'PXRecord', 'NSAPRecord', 'RPRecord',
17-
'NSRecord', 'SOARecord', 'SPFRecord', 'SRVRecord', 'TLSARecord',
18-
'TXTRecord', 'SSHFPRecord']
16+
'NAPTRRecord', 'PTRRecord', 'PXRecord', 'NSAPRecord',
17+
'RPRecord', 'NSRecord', 'SOARecord', 'SPFRecord', 'SRVRecord',
18+
'TLSARecord', 'TXTRecord', 'SSHFPRecord', 'UNKNOWNRecord']
1919

2020

2121
class DNSRecord(object):
@@ -2160,6 +2160,7 @@ def __repr__(self):
21602160
"""print override"""
21612161
return self.__str__()
21622162

2163+
21632164
class PTRRecord(DNSRecord):
21642165
"""Pointer Records are used to reverse map an IPv4 or IPv6 IP address to a
21652166
host name
@@ -3190,4 +3191,27 @@ def __str__(self):
31903191

31913192
def __repr__(self):
31923193
"""print override"""
3193-
return self.__str__()
3194+
return self.__str__()
3195+
3196+
3197+
3198+
class UNKNOWNRecord(DNSRecord):
3199+
"""Unknown Record Holder
3200+
"""
3201+
3202+
def __init__(self, zone, fqdn, *args, **kwargs):
3203+
"""Create an :class:`~dyn.tm.records.UNKNOWNRecord` object"""
3204+
3205+
if 'create' in kwargs:
3206+
super(UNKNOWNRecord, self).__init__(zone, fqdn, kwargs['create'])
3207+
del kwargs['create']
3208+
self._build(kwargs)
3209+
self._record_type = 'UNKNOWNRecord'
3210+
3211+
def __str__(self):
3212+
"""str override"""
3213+
return '<UNKNOWNRecordRecord>'
3214+
3215+
def __repr__(self):
3216+
"""print override"""
3217+
return '<UNKNOWNRecordRecord>'

dyn/tm/zones.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'PTR': PTRRecord, 'PX': PXRecord, 'NSAP': NSAPRecord,
2525
'RP': RPRecord, 'NS': NSRecord, 'SOA': SOARecord,
2626
'SPF': SPFRecord, 'SRV': SRVRecord, 'TLSA': TLSARecord,
27-
'TXT': TXTRecord, 'SSHFP': SSHFPRecord }
27+
'TXT': TXTRecord, 'SSHFP': SSHFPRecord, 'UNKNOWN': UNKNOWNRecord}
2828

2929

3030
def get_all_zones():
@@ -452,7 +452,10 @@ def get_all_records(self):
452452
records = {}
453453
for key, record_list in record_lists.items():
454454
search = key.split('_')[0].upper()
455-
constructor = RECS[search]
455+
try:
456+
constructor = RECS[search]
457+
except KeyError:
458+
constructor = RECS['UNKNOWN']
456459
list_records = []
457460
for record in record_list:
458461
del record['zone']
@@ -522,7 +525,10 @@ def get_any_records(self):
522525
records = {}
523526
for key, record_list in record_lists.items():
524527
search = key.split('_')[0].upper()
525-
constructor = RECS[search]
528+
try:
529+
constructor = RECS[search]
530+
except KeyError:
531+
constructor = RECS['UNKNOWN']
526532
list_records = []
527533
for record in record_list:
528534
del record['zone']
@@ -933,7 +939,10 @@ def get_all_records(self):
933939
records = {}
934940
for key, record_list in record_lists.items():
935941
search = key.split('_')[0].upper()
936-
constructor = RECS[search]
942+
try:
943+
constructor = RECS[search]
944+
except KeyError:
945+
constructor = RECS['UNKNOWN']
937946
list_records = []
938947
for record in record_list:
939948
del record['zone']
@@ -999,7 +1008,10 @@ def get_any_records(self):
9991008
records = {}
10001009
for key, record_list in record_lists.items():
10011010
search = key.split('_')[0].upper()
1002-
constructor = RECS[search]
1011+
try:
1012+
constructor = RECS[search]
1013+
except KeyError:
1014+
constructor = RECS['UNKNOWN']
10031015
list_records = []
10041016
for record in record_list:
10051017
del record['zone']

0 commit comments

Comments
 (0)