From 76c23edfab6f5840aac600b5c136116887edfb92 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Tue, 15 Feb 2022 11:23:20 +0100 Subject: [PATCH] Don't flush all TLSA, only erase the ones that are with this subdomain specifically Signed-off-by: Louis Vallat --- src/records.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/records.rs b/src/records.rs index 33819b2..43eb529 100644 --- a/src/records.rs +++ b/src/records.rs @@ -120,7 +120,11 @@ pub async fn update_tlsa_for_subdomain(ovh_client: &OVHClient, client: &Client>, zone: &str, subdomain: &str, hash: &str, issuer_hash: &str, port: u32, protocol: &str) { - flush_tlsa_record_for_subdomain(ovh_client, client, zone, subdomain).await; + let tlsa_subdomain = get_tlsa_subdomain(subdomain, port, protocol); + let records = get_records_from_zone(ovh_client, client, zone, "TLSA", &tlsa_subdomain).await; + for record in records { + delete_record_from_zone(ovh_client, client, zone, record.id).await; + } add_record_to_zone(ovh_client, client, zone, &Record { sub_domain: get_tlsa_subdomain(subdomain, port, protocol), target: format!("3 1 1 {}", hash).to_string(),