From a9b6f298d7ece0539dc22a92c0631c61e4dc648e Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Fri, 31 Jan 2020 18:00:39 +0500 Subject: [PATCH] bug fix: configure default nameservers --- dns/dnsManager.py | 17 ++++++++--------- loginSystem/views.py | 0 plogical/dnsUtilities.py | 21 +++++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) mode change 100755 => 100644 loginSystem/views.py diff --git a/dns/dnsManager.py b/dns/dnsManager.py index dee0e03b2..0c9777821 100755 --- a/dns/dnsManager.py +++ b/dns/dnsManager.py @@ -15,7 +15,6 @@ from .models import Domains,Records from re import match,I,M from plogical.mailUtilities import mailUtilities from plogical.acl import ACLManager -from manageServices.models import PDNSStatus class DNSManager: defaultNameServersPath = '/home/cyberpanel/defaultNameservers' @@ -511,19 +510,19 @@ class DNSManager: if os.path.exists(DNSManager.defaultNameServersPath): nsData = open(DNSManager.defaultNameServersPath, 'r').readlines() try: - data['firstNS'] = nsData[0] + data['firstNS'] = nsData[0].rstrip('\n') except: pass try: - data['secondNS'] = nsData[1] + data['secondNS'] = nsData[1].rstrip('\n') except: pass try: - data['thirdNS'] = nsData[2] + data['thirdNS'] = nsData[2].rstrip('\n') except: pass try: - data['forthNS'] = nsData[3] + data['forthNS'] = nsData[3].rstrip('\n') except: pass @@ -545,16 +544,16 @@ class DNSManager: nsContent = '' try: - nsContent = '%s\n%s\n%s\n%s\n' % (data['firstNS'], data['secondNS'], data['thirdNS'], data['forthNS']) + nsContent = '%s\n%s\n%s\n%s\n' % (data['firstNS'].rstrip('\n'), data['secondNS'].rstrip('\n'), data['thirdNS'].rstrip('\n'), data['forthNS'].rstrip('\n')) except: try: - nsContent = '%s\n%s\n%s\n' % (data['firstNS'], data['secondNS'], data['thirdNS']) + nsContent = '%s\n%s\n%s\n' % (data['firstNS'].rstrip('\n'), data['secondNS'].rstrip('\n'), data['thirdNS'].rstrip('\n')) except: try: - nsContent = '%s\n%s\n' % (data['firstNS'], data['secondNS']) + nsContent = '%s\n%s\n' % (data['firstNS'].rstrip('\n'), data['secondNS'].rstrip('\n')) except: try: - nsContent = '%s\n' % (data['firstNS']) + nsContent = '%s\n' % (data['firstNS'].rstrip('\n')) except: pass diff --git a/loginSystem/views.py b/loginSystem/views.py old mode 100755 new mode 100644 diff --git a/plogical/dnsUtilities.py b/plogical/dnsUtilities.py index 3812f2ee5..80f3eb9f1 100755 --- a/plogical/dnsUtilities.py +++ b/plogical/dnsUtilities.py @@ -76,16 +76,17 @@ class DNS: defaultNS = open(DNS.defaultNameServersPath, 'r').readlines() for items in defaultNS: - record = Records(domainOwner=zone, - domain_id=zone.id, - name=topLevelDomain, - type="NS", - content=items, - ttl=3600, - prio=0, - disabled=0, - auth=1) - record.save() + if len(items) > 5: + record = Records(domainOwner=zone, + domain_id=zone.id, + name=topLevelDomain, + type="NS", + content=items.rstrip('\n'), + ttl=3600, + prio=0, + disabled=0, + auth=1) + record.save() else: record = Records(domainOwner=zone, domain_id=zone.id,