add multidomain support - broken ipv6
This commit is contained in:
parent
d504a6a177
commit
e0b7e598e0
|
@ -24,7 +24,11 @@ api_endpoint = 'https://dns.api.gandi.net/api/v5'
|
|||
domain = 'mydomain.tld'
|
||||
|
||||
#enter all subdomains to be updated, subdomains must already exist to be updated
|
||||
subdomains = ["subdomain1", "subdomain2", "subdomain3"]
|
||||
#your domain and subdomains to be updated, subdomains must already exist to be updated
|
||||
dnsentries = {
|
||||
"mydomain.tld": ["subdomain1", "subdomain2"],
|
||||
"myotherdomain.tld": ["subdomain3"],
|
||||
}
|
||||
|
||||
#300 seconds = 5 minutes
|
||||
ttl = '300'
|
||||
|
|
|
@ -125,37 +125,41 @@ def main(force_update, verbosity, repeat):
|
|||
if repeat and verbose:
|
||||
print(f'repeat turned on, will repeat every {repeat} seconds')
|
||||
|
||||
#get zone ID from Account
|
||||
uuid = get_uuid()
|
||||
for key, value in config.dnsentries.items():
|
||||
config.domain = key
|
||||
config.subdomains = value
|
||||
|
||||
#compare dynIP and DNS IP
|
||||
dynIP = get_dynip(config.ifconfig, verbose)
|
||||
#get zone ID from Account
|
||||
uuid = get_uuid()
|
||||
|
||||
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
|
||||
#compare dynIP and DNS IP
|
||||
dynIP = get_dynip(config.ifconfig, verbose)
|
||||
|
||||
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')
|
||||
if check_is_ipv6(dynIP, verbose):
|
||||
subdomains = config.subdomains6
|
||||
is_ipv6 = True
|
||||
print('Detected ipv6')
|
||||
else:
|
||||
print (f'IP Address Mismatch - going to update the DNS Records for the subdomains with new IP {dynIP}')
|
||||
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}')
|
||||
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