Add get_reverse_domain_name functionality

In this way the reverse it is possible to create
auto-ptr records in higher ip classes (eg. class A in IPv4).
Only works with existing higher class domain.

If is isn't find higher class domain, create a lowest class domain, and add there the reverse PTRs.

Also works with IPv6!
This commit is contained in:
SIPOS, Peter 2016-11-21 19:44:10 +01:00
parent b9f95da906
commit e6e3c39778

View File

@ -1068,8 +1068,8 @@ class Record(object):
if r['type'] in ['A', 'AAAA']:
r_name = r['name'] + '.'
r_content = r['content']
temp = re.search('^((([a-f0-9]\.){4})(?P<ipv6name>.+6.arpa)\.?)|((([0-9]+\.){1})(?P<ipv4name>.+r.arpa)\.?)', dns.reversename.from_address(r_content).to_text())
domain_reverse_name = temp.group('ipv6name') if temp.group('ipv6name') != None else temp.group('ipv4name')
reverse_host_address = dns.reversename.from_address(r_content).to_text()
domain_reverse_name = d.get_reverse_domain_name(reverse_host_address)
d.create_reverse_domain(domain, domain_reverse_name)
self.name = dns.reversename.from_address(r_content).to_text().rstrip('.')
self.type = 'PTR'
@ -1081,9 +1081,9 @@ class Record(object):
if r['type'] in ['A', 'AAAA']:
r_name = r['name'] + '.'
r_content = r['content']
temp = re.search('^((([a-f0-9]\.){4})(?P<ipv6name>.+6.arpa)\.?)|((([0-9]+\.){1})(?P<ipv4name>.+r.arpa)\.?)', dns.reversename.from_address(r_content).to_text())
domain_reverse_name = temp.group('ipv6name') if temp.group('ipv6name') != None else temp.group('ipv4name')
self.name = dns.reversename.from_address(r_content).to_text()
reverse_host_address = dns.reversename.from_address(r_content).to_text()
domain_reverse_name = d.get_reverse_domain_name(reverse_host_address)
self.name = reverse_host_address
self.type = 'PTR'
self.data = r_content
self.delete(domain_reverse_name)