Preventing unbound local error with TTL to allow subdomain creation

This commit is contained in:
Louis Lacoste 2022-09-15 13:58:32 +02:00
parent 5ff266689e
commit 0fc975a429

View file

@ -68,6 +68,8 @@ def retrieve_dns_ip(api_url, headers):
response = requests.get(api_url, headers=headers) response = requests.get(api_url, headers=headers)
response_json = response.json() # IPs are stored in a list as string response_json = response.json() # IPs are stored in a list as string
retrieved_dns_ip = None
retrieved_ttl = None
try: try:
retrieved_dns_ip = response_json['rrset_values'][0] retrieved_dns_ip = response_json['rrset_values'][0]
retrieved_ttl = response_json['rrset_ttl'] retrieved_ttl = response_json['rrset_ttl']
@ -91,6 +93,7 @@ def update_dns_ip(api_url, headers):
print(f"DNS IP is : {dns_ip}") print(f"DNS IP is : {dns_ip}")
else: else:
print("The subdomain doesn't exist, no DNS IP associated") print("The subdomain doesn't exist, no DNS IP associated")
if dns_ttl:
print(f"DNS TTL is {dns_ttl}") print(f"DNS TTL is {dns_ttl}")
if public_ip != dns_ip or dns_ttl != ttl: if public_ip != dns_ip or dns_ttl != ttl: