From 58ef114f7f762d6c67ba66f54e513c93be71359f Mon Sep 17 00:00:00 2001 From: "SIPOS, Peter" Date: Thu, 17 Nov 2016 11:35:09 +0100 Subject: [PATCH] Move auto-ptr functionality into a new function --- app/models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 753085d..fdcc9c1 100644 --- a/app/models.py +++ b/app/models.py @@ -1016,7 +1016,16 @@ class Record(object): logging.debug(jdata2['error']) return {'status': 'error', 'msg': jdata2['error']} else: + self.auto_ptr(domain, new_records, deleted_records) logging.info('Record was applied successfully.') + return {'status': 'ok', 'msg': 'Record was applied successfully'} + except Exception, e: + logging.error("Cannot apply record changes to domain %s. DETAIL: %s" % (str(e), domain)) + return {'status': 'error', 'msg': 'There was something wrong, please contact administrator'} + + def auto_ptr(self, domain, new_records, deleted_records): + if app.config['AUTOMATIC_REVERSE_PTR']: + try: d = Domain() for r in new_records: if r['type'] in ['A', 'AAAA']: @@ -1025,7 +1034,7 @@ class Record(object): temp = re.search('^(([a-f0-9]\.){4}(?P.+6.arpa)\.?)|(\.(?P.+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('.') + self.name = dns.reversename.from_address(r_content).to_text() self.type = 'PTR' self.status = r['disabled'] self.ttl = r['ttl']