From f68186314bf14c868620a0554c1399752a438a90 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 12 Dec 2023 14:43:05 +1100 Subject: [PATCH] fix: Clone new TLSA and fix some typos --- varo.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/varo.py b/varo.py index 98553d4..e602627 100644 --- a/varo.py +++ b/varo.py @@ -271,15 +271,71 @@ def copy_to_alts(domain): print(alt_zone) if alt_zone == "": continue + # Delete all records from domain.alt + data = { + "action": "getRecords", + "zone": alt_zone, + "name": domain+"."+alt_domain, + "type": "", + "content": "" + } + r = requests.post(url, headers=headers, json=data) + r = r.json() + if 'data' not in r: + continue + for record in r['data']: + data = { + "action": "deleteRecord", + "zone": alt_zone, + "record": record['uuid'] + } + r = requests.post(url, headers=headers, json=data) + print(r.text) + # Add each record to each alt for record in records: data = { "action": "addRecord", "zone": alt_zone, "type": record['type'], - "name": record['name'].replace(domain,alt_domain), + "name": domain+"."+alt_domain, "content": record['content'], } print(data) r = requests.post(url, headers=headers, json=data) print(r.text) + # Add TLSA record if it doesn't exist + data = { + "action": "getRecords", + "zone": alt_zone, + "name": "_443._tcp."+domain+"."+alt_domain, + "type": "TLSA", + "content": "" + } + r = requests.post(url, headers=headers, json=data) + r = r.json() + if 'data' not in r: + # Get alt TLSA from _443._tcp.alt_domain + data = { + "action": "getRecords", + "zone": alt_zone, + "name": "_443._tcp."+alt_domain, + "type": "TLSA", + "content": "" + } + r = requests.post(url, headers=headers, json=data) + r = r.json() + if 'data' not in r: + continue + for record in r['data']: + ALT_TLSA = record['content'] + + data = { + "action": "addRecord", + "zone": alt_zone, + "type": "TLSA", + "name": "_443._tcp."+domain+"."+alt_domain, + "content": ALT_TLSA, + } + r = requests.post(url, headers=headers, json=data) + print(r.text)