Skip to content

Commit

Permalink
tld extract bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Sep 7, 2024
1 parent e78cc6f commit 7284ab7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 57 deletions.
14 changes: 4 additions & 10 deletions cloudAPI/cloudManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 2 additions & 13 deletions dns/dnsManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 6 additions & 10 deletions mailServer/mailserverManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 6 additions & 13 deletions plogical/dnsUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
12 changes: 3 additions & 9 deletions plogical/mailUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
6 changes: 4 additions & 2 deletions plogical/sslv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 7284ab7

Please sign in to comment.