clean ipv6 support

This commit is contained in:
Gitouche 2022-09-26 22:52:12 +02:00
parent e0b7e598e0
commit fcb18989b9
2 changed files with 39 additions and 32 deletions

View file

@ -26,10 +26,16 @@ domain = 'mydomain.tld'
#enter all subdomains to be updated, subdomains must already exist to be updated #enter all subdomains to be updated, subdomains must already exist to be updated
#your domain and subdomains to be updated, subdomains must already exist to be updated #your domain and subdomains to be updated, subdomains must already exist to be updated
dnsentries = { dnsentries = {
"mydomain.tld": ["subdomain1", "subdomain2"], "mydomain.tld": {
"myotherdomain.tld": ["subdomain3"], "ipv4": ["subdomain1", "subdomain2"],
"ipv6": ["subdomain3v6"],
},
"myotherdomain.tld": {
"ipv4": ["subdomain4"],
},
} }
#300 seconds = 5 minutes #300 seconds = 5 minutes
ttl = '300' ttl = '300'

View file

@ -65,11 +65,10 @@ def get_dnsip(uuid, is_ipv6=False, verbose=False):
''' '''
if is_ipv6: if is_ipv6:
record_type = '/AAAA' record_type = '/AAAA'
subdomain = config.subdomains6[0]
else: else:
record_type = '/A' record_type = '/A'
subdomain = config.subdomains[0]
subdomain = config.subdomains[0]
url = config.api_endpoint+ '/zones/' + uuid + '/records/' + subdomain + record_type url = config.api_endpoint+ '/zones/' + uuid + '/records/' + subdomain + record_type
headers = {'X-Api-Key':config.api_secret} headers = {'X-Api-Key':config.api_secret}
u = requests.get(url, headers=headers) u = requests.get(url, headers=headers)
@ -125,27 +124,29 @@ def main(force_update, verbosity, repeat):
if repeat and verbose: if repeat and verbose:
print(f'repeat turned on, will repeat every {repeat} seconds') print(f'repeat turned on, will repeat every {repeat} seconds')
for key, value in config.dnsentries.items(): for domain, content in config.dnsentries.items():
config.domain = key config.domain = domain
for key, value in content.items():
afi = key
config.subdomains = value config.subdomains = value
#get zone ID from Account #get zone ID from Account
uuid = get_uuid() uuid = get_uuid()
#compare dynIP and DNS IP #compare dynIP and DNS IP
dynIP = get_dynip(config.ifconfig, verbose) dynIP = get_dynip(config.ifconfig[afi], verbose)
if check_is_ipv6(dynIP, verbose): if check_is_ipv6(dynIP, verbose):
subdomains = config.subdomains6
is_ipv6 = True is_ipv6 = True
print('Detected ipv6') print('Detected ipv6')
else: else:
print('Detected ipv4') print('Detected ipv4')
is_ipv6 = False is_ipv6 = False
subdomains = config.subdomains
dnsIP = get_dnsip(uuid, is_ipv6, verbose) dnsIP = get_dnsip(uuid, is_ipv6, verbose)
subdomains = config.subdomains
if force_update: if force_update:
print ('Going to update/create the DNS Records for the subdomains') print ('Going to update/create the DNS Records for the subdomains')
for sub in subdomains: for sub in subdomains: