From 7284ab70a815cd4b2b5aa4f221686ed2c2d74504 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sun, 8 Sep 2024 00:25:23 +0500 Subject: [PATCH] tld extract bug fix --- cloudAPI/cloudManager.py | 14 ++++---------- dns/dnsManager.py | 15 ++------------- mailServer/mailserverManager.py | 16 ++++++---------- plogical/dnsUtilities.py | 19 ++++++------------- plogical/mailUtilities.py | 12 +++--------- plogical/sslv2.py | 6 ++++-- 6 files changed, 25 insertions(+), 57 deletions(-) diff --git a/cloudAPI/cloudManager.py b/cloudAPI/cloudManager.py index 43a97f86c..6c387f79c 100755 --- a/cloudAPI/cloudManager.py +++ b/cloudAPI/cloudManager.py @@ -2859,18 +2859,11 @@ def SwitchDNS(self): zones = cf.zones.get(params = {'per_page':100}) - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.8/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python*/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command, None, True) for website in Websites.objects.all(): import tldextract - extractDomain = tldextract.extract(website.domain) + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + extractDomain = no_cache_extract(website.domain) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix for zone in zones: @@ -2920,7 +2913,8 @@ def SwitchDNS(self): for website in ChildDomains.objects.all(): import tldextract - extractDomain = tldextract.extract(website.domain) + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + extractDomain = no_cache_extract(website.domain) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix for zone in zones: diff --git a/dns/dnsManager.py b/dns/dnsManager.py index 9f19b7e5d..7569804b0 100755 --- a/dns/dnsManager.py +++ b/dns/dnsManager.py @@ -171,20 +171,9 @@ def addDeleteDNSRecords(self, request = None, userID = None): finalData['domainsList'] = [] import tldextract - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.8/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python*/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command, None, True) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.8/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - + no_cache_extract = tldextract.TLDExtract(cache_dir=None) for items in tempList: - extractDomain = tldextract.extract(items) + extractDomain = no_cache_extract(items) subDomain = extractDomain.subdomain if len(subDomain) == 0: finalData['domainsList'].append(items) diff --git a/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index d12e76174..8c7c18a25 100755 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -693,18 +693,12 @@ def fetchDKIMKeys(self): try: - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.8/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python*/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command, None, True) import tldextract - extractDomain = tldextract.extract(domainName) + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + + extractDomain = no_cache_extract(domainName) domainName = extractDomain.domain + '.' + extractDomain.suffix path = "/etc/opendkim/keys/" + domainName + "/default.txt" @@ -772,7 +766,9 @@ def generateDKIMKeys(self): import tldextract - extractDomain = tldextract.extract(domainName) + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + + extractDomain = no_cache_extract(domainName) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix zone = dnsDomains.objects.get(name=topLevelDomain) diff --git a/plogical/dnsUtilities.py b/plogical/dnsUtilities.py index a4d32acc0..1816b4c47 100755 --- a/plogical/dnsUtilities.py +++ b/plogical/dnsUtilities.py @@ -115,21 +115,12 @@ def dnsTemplate(domain, admin): ipData = f.read() ipAddress = ipData.split('\n', 1)[0] - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.8/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python*/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command, None, True) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.8/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) import tldextract - extractDomain = tldextract.extract(domain) + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + + extractDomain = no_cache_extract(domain) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix subDomain = extractDomain.subdomain @@ -582,7 +573,9 @@ def createDKIMRecords(domain): import tldextract - extractDomain = tldextract.extract(domain) + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + + extractDomain = no_cache_extract(domain) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix subDomain = extractDomain.subdomain diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index bbca4dc45..87e27fd7d 100755 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -401,19 +401,13 @@ def setupDKIM(virtualHostName): try: ## Generate DKIM Keys - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.6/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python3.8/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command) - - command = 'chown cyberpanel:cyberpanel -R /usr/local/CyberCP/lib/python*/site-packages/tldextract/.suffix_cache' - ProcessUtilities.executioner(command, None, True) import tldextract + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + actualDomain = virtualHostName - extractDomain = tldextract.extract(virtualHostName) + extractDomain = no_cache_extract(virtualHostName) virtualHostName = extractDomain.domain + '.' + extractDomain.suffix if not os.path.exists("/etc/opendkim/keys/" + virtualHostName + "/default.txt"): diff --git a/plogical/sslv2.py b/plogical/sslv2.py index cda09f05b..7da67e928 100755 --- a/plogical/sslv2.py +++ b/plogical/sslv2.py @@ -339,10 +339,11 @@ def FindIfDomainInCloudflare(virtualHostName): import tldextract RetStatus, SAVED_CF_Key, SAVED_CF_Email = ACLManager.FetchCloudFlareAPIKeyFromAcme() + no_cache_extract = tldextract.TLDExtract(cache_dir=None) if RetStatus: - extractDomain = tldextract.extract(virtualHostName) + extractDomain = no_cache_extract(virtualHostName) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix logging.CyberCPLogFileWriter.writeToFile(f'top level domain in cf: {topLevelDomain}') import CloudFlare @@ -375,7 +376,8 @@ def FindIfDomainInPowerDNS(virtualHostName): from plogical.dnsUtilities import DNS from dns.models import Domains - extractDomain = tldextract.extract(virtualHostName) + no_cache_extract = tldextract.TLDExtract(cache_dir=None) + extractDomain = no_cache_extract(virtualHostName) topLevelDomain = extractDomain.domain + '.' + extractDomain.suffix zone = Domains.objects.get(name=topLevelDomain)