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
#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'

View file

@ -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,27 +124,29 @@ 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
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()
#compare dynIP and DNS IP
dynIP = get_dynip(config.ifconfig, verbose)
dynIP = get_dynip(config.ifconfig[afi], 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)
subdomains = config.subdomains
if force_update:
print ('Going to update/create the DNS Records for the subdomains')
for sub in subdomains: