clean ipv6 support
This commit is contained in:
parent
e0b7e598e0
commit
fcb18989b9
|
@ -26,10 +26,16 @@ domain = 'mydomain.tld'
|
|||
#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
|
||||
dnsentries = {
|
||||
"mydomain.tld": ["subdomain1", "subdomain2"],
|
||||
"myotherdomain.tld": ["subdomain3"],
|
||||
"mydomain.tld": {
|
||||
"ipv4": ["subdomain1", "subdomain2"],
|
||||
"ipv6": ["subdomain3v6"],
|
||||
},
|
||||
"myotherdomain.tld": {
|
||||
"ipv4": ["subdomain4"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
#300 seconds = 5 minutes
|
||||
ttl = '300'
|
||||
|
||||
|
|
|
@ -65,11 +65,10 @@ def get_dnsip(uuid, is_ipv6=False, verbose=False):
|
|||
'''
|
||||
if is_ipv6:
|
||||
record_type = '/AAAA'
|
||||
subdomain = config.subdomains6[0]
|
||||
else:
|
||||
record_type = '/A'
|
||||
subdomain = config.subdomains[0]
|
||||
|
||||
subdomain = config.subdomains[0]
|
||||
url = config.api_endpoint+ '/zones/' + uuid + '/records/' + subdomain + record_type
|
||||
headers = {'X-Api-Key':config.api_secret}
|
||||
u = requests.get(url, headers=headers)
|
||||
|
@ -125,41 +124,43 @@ def main(force_update, verbosity, repeat):
|
|||
if repeat and verbose:
|
||||
print(f'repeat turned on, will repeat every {repeat} seconds')
|
||||
|
||||
for key, value in config.dnsentries.items():
|
||||
config.domain = key
|
||||
config.subdomains = value
|
||||
for domain, content in config.dnsentries.items():
|
||||
config.domain = domain
|
||||
for key, value in content.items():
|
||||
afi = key
|
||||
config.subdomains = value
|
||||
|
||||
#get zone ID from Account
|
||||
uuid = get_uuid()
|
||||
#get zone ID from Account
|
||||
uuid = get_uuid()
|
||||
|
||||
#compare dynIP and DNS IP
|
||||
dynIP = get_dynip(config.ifconfig, verbose)
|
||||
#compare dynIP and DNS IP
|
||||
dynIP = get_dynip(config.ifconfig[afi], verbose)
|
||||
|
||||
if check_is_ipv6(dynIP, verbose):
|
||||
is_ipv6 = True
|
||||
print('Detected ipv6')
|
||||
else:
|
||||
print('Detected ipv4')
|
||||
is_ipv6 = False
|
||||
|
||||
dnsIP = get_dnsip(uuid, is_ipv6, verbose)
|
||||
|
||||
if check_is_ipv6(dynIP, verbose):
|
||||
subdomains = config.subdomains6
|
||||
is_ipv6 = True
|
||||
print('Detected ipv6')
|
||||
else:
|
||||
print('Detected ipv4')
|
||||
is_ipv6 = False
|
||||
subdomains = config.subdomains
|
||||
|
||||
dnsIP = get_dnsip(uuid, is_ipv6, verbose)
|
||||
|
||||
if force_update:
|
||||
print ('Going to update/create the DNS Records for the subdomains')
|
||||
for sub in subdomains:
|
||||
update_records(uuid, dynIP, sub, is_ipv6, verbose)
|
||||
else:
|
||||
if verbose:
|
||||
print(f'dynIP: {dynIP}')
|
||||
print(f'dnsIP: {dnsIP}')
|
||||
if dynIP == dnsIP:
|
||||
print ('IP Address Match - no further action')
|
||||
else:
|
||||
print (f'IP Address Mismatch - going to update the DNS Records for the subdomains with new IP {dynIP}')
|
||||
if force_update:
|
||||
print ('Going to update/create the DNS Records for the subdomains')
|
||||
for sub in subdomains:
|
||||
update_records(uuid, dynIP, sub, is_ipv6, verbose)
|
||||
else:
|
||||
if verbose:
|
||||
print(f'dynIP: {dynIP}')
|
||||
print(f'dnsIP: {dnsIP}')
|
||||
if dynIP == dnsIP:
|
||||
print ('IP Address Match - no further action')
|
||||
else:
|
||||
print (f'IP Address Mismatch - going to update the DNS Records for the subdomains with new IP {dynIP}')
|
||||
for sub in subdomains:
|
||||
update_records(uuid, dynIP, sub, is_ipv6, verbose)
|
||||
if repeat:
|
||||
if verbosity:
|
||||
print(f'Repeating in {repeat} seconds')
|
||||
|
|
Loading…
Reference in a new issue