Added error handling if key is not in A or AAAA
This commit is contained in:
parent
fedae40fc4
commit
6a059e6806
1 changed files with 12 additions and 3 deletions
|
@ -31,7 +31,16 @@ def main():
|
||||||
for dnsrecord in dns_records:
|
for dnsrecord in dns_records:
|
||||||
if ipversion == 'skipping':
|
if ipversion == 'skipping':
|
||||||
print(f"DNS Name: {dnsrecord['name']} | ID: {dnsrecord['id']} | Type : {dnsrecord['type']} | IP: {dnsrecord['content']}")
|
print(f"DNS Name: {dnsrecord['name']} | ID: {dnsrecord['id']} | Type : {dnsrecord['type']} | IP: {dnsrecord['content']}")
|
||||||
|
|
||||||
|
if dnsrecord['type'] in ['A', 'AAAA']:
|
||||||
dns_names[dnsrecord['type']].append(dnsrecord["name"])
|
dns_names[dnsrecord['type']].append(dnsrecord["name"])
|
||||||
|
else:
|
||||||
|
print(f"Cannot resolve record {dnsrecord['name']} because of type {dnsrecord['type']}")
|
||||||
|
print(f"------ Full DNS record ------\n"
|
||||||
|
f"{dnsrecord}"
|
||||||
|
f"\n---------------------------"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
with open('cloudflare.json', 'r') as file:
|
with open('cloudflare.json', 'r') as file:
|
||||||
values = json.load(file)
|
values = json.load(file)
|
||||||
|
@ -55,7 +64,7 @@ def main():
|
||||||
if fullname in dns_names['A']:
|
if fullname in dns_names['A']:
|
||||||
new_dnsrecords = {"name": fullname, "type": "A", "content": ip_address_new}
|
new_dnsrecords = {"name": fullname, "type": "A", "content": ip_address_new}
|
||||||
print(f"Sending request {new_dnsrecords}")
|
print(f"Sending request {new_dnsrecords}")
|
||||||
r = cf.zones.dns_records.put(zone_id, dns_record_id, data=new_dnsrecords)
|
r = cf.zones.dns_records.patch(zone_id, dns_record_id, data=new_dnsrecords)
|
||||||
print(r)
|
print(r)
|
||||||
|
|
||||||
case '6':
|
case '6':
|
||||||
|
@ -75,7 +84,7 @@ def main():
|
||||||
if fullname in dns_names['AAAA']:
|
if fullname in dns_names['AAAA']:
|
||||||
new_dnsrecords = {"name": fullname, "type": "AAAA", "content": ip_address_new}
|
new_dnsrecords = {"name": fullname, "type": "AAAA", "content": ip_address_new}
|
||||||
print(f"Sending request {new_dnsrecords}")
|
print(f"Sending request {new_dnsrecords}")
|
||||||
r = cf.zones.dns_records.put(zone_id, dns_record_id, data=new_dnsrecords)
|
r = cf.zones.dns_records.patch(zone_id, dns_record_id, data=new_dnsrecords)
|
||||||
print(r)
|
print(r)
|
||||||
case 'skipping':
|
case 'skipping':
|
||||||
print("Done")
|
print("Done")
|
||||||
|
|
Loading…
Reference in a new issue