Extend reverse domain regexp with classes

With this modification it can be possible, to detect
custom IP classes for domains. It just need to 
modify the multipler in regexp {4} or {1}.

In the future it will works automaticly, but not now
This commit is contained in:
SIPOS, Peter 2016-11-21 16:52:54 +01:00
parent 1538cf0239
commit c53d9ace89

View File

@ -1044,8 +1044,10 @@ class Record(object):
domain_obj = Domain.query.filter(Domain.name == domain).first()
domain_auto_ptr = DomainSetting.query.filter(DomainSetting.domain == domain_obj).filter(DomainSetting.setting == 'auto_ptr').first()
domain_auto_ptr = strtobool(domain_auto_ptr.value) if domain_auto_ptr else False
system_auto_ptr = Setting.query.filter(Setting.name == 'auto_ptr').first()
system_auto_ptr = strtobool(system_auto_ptr.value)
if system_auto_ptr or domain_auto_ptr:
try:
d = Domain()
@ -1053,7 +1055,7 @@ 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)\.?)|(\.(?P<ipv4name>.+r.arpa)\.?)', dns.reversename.from_address(r_content).to_text())
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')
d.create_reverse_domain(domain, domain_reverse_name)
self.name = dns.reversename.from_address(r_content).to_text().rstrip('.')
@ -1066,7 +1068,7 @@ 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)\.?)|(\.(?P<ipv4name>.+r.arpa)\.?)', dns.reversename.from_address(r_content).to_text())
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()
self.type = 'PTR'