Put a "." char in a safe way to the records name fields end

First of all we cut all of dot char at the end of the rstring and than we put one there.
this way we make sure that our string contains just
one dot at its end.
This commit is contained in:
SIPOS, Peter 2016-11-17 15:04:07 +01:00
parent 3dbbfc16ce
commit 7d72cf6088

View File

@ -797,7 +797,7 @@ class Record(object):
if NEW_SCHEMA: if NEW_SCHEMA:
data = {"rrsets": [ data = {"rrsets": [
{ {
"name": self.name + '.', "name": self.name.rstrip('.') + '.',
"type": self.type, "type": self.type,
"changetype": "REPLACE", "changetype": "REPLACE",
"ttl": self.ttl, "ttl": self.ttl,
@ -889,7 +889,7 @@ class Record(object):
records = [] records = []
for r in deleted_records: for r in deleted_records:
r_name = r['name'] + '.' if NEW_SCHEMA else r['name'] r_name = r['name'].rstrip('.') + '.' if NEW_SCHEMA else r['name']
r_type = r['type'] r_type = r['type']
if PRETTY_IPV6_PTR: # only if activated if PRETTY_IPV6_PTR: # only if activated
if NEW_SCHEMA: # only if new schema if NEW_SCHEMA: # only if new schema
@ -911,7 +911,7 @@ class Record(object):
records = [] records = []
for r in new_records: for r in new_records:
if NEW_SCHEMA: if NEW_SCHEMA:
r_name = r['name'] + '.' r_name = r['name'].rstrip('.') + '.'
r_type = r['type'] r_type = r['type']
if PRETTY_IPV6_PTR: # only if activated if PRETTY_IPV6_PTR: # only if activated
if r_type == 'PTR': # only ptr if r_type == 'PTR': # only ptr
@ -1034,7 +1034,7 @@ class Record(object):
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)\.?)|(\.(?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') domain_reverse_name = temp.group('ipv6name') if temp.group('ipv6name') != None else temp.group('ipv4name')
d.create_reverse_domain(domain, domain_reverse_name) d.create_reverse_domain(domain, domain_reverse_name)
self.name = dns.reversename.from_address(r_content).to_text() self.name = dns.reversename.from_address(r_content).to_text().rstrip('.')
self.type = 'PTR' self.type = 'PTR'
self.status = r['disabled'] self.status = r['disabled']
self.ttl = r['ttl'] self.ttl = r['ttl']
@ -1063,7 +1063,7 @@ class Record(object):
headers['X-API-Key'] = PDNS_API_KEY headers['X-API-Key'] = PDNS_API_KEY
data = {"rrsets": [ data = {"rrsets": [
{ {
"name": self.name, "name": self.name.rstrip('.') + '.',
"type": self.type, "type": self.type,
"changetype": "DELETE", "changetype": "DELETE",
"records": [ "records": [