Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
add retry to freenom clear challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
AMEST committed Feb 19, 2022
1 parent dbc6b6d commit 35f6ece
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions DotNetCertBot.FreenomDnsProvider/FreenomDnsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,25 @@ public async Task AddChallenge(DnsChallenge challenge, string zoneName)

public async Task ClearChallenge(string zoneName, string id)
{
var zones = await Retry.Do(async () => await _client.GetZones(), RetryCount, RetryDelay);
var neededZone = zones.FirstOrDefault(z => z.Name.Equals(zoneName, StringComparison.OrdinalIgnoreCase));
if (neededZone == null)
throw new Exception($"Zone ({zoneName}) not found");
await Retry.Do(async () =>
{
var zones = await Retry.Do(async () => await _client.GetZones(), RetryCount, RetryDelay);
var neededZone = zones.FirstOrDefault(z => z.Name.Equals(zoneName, StringComparison.OrdinalIgnoreCase));
if (neededZone == null)
throw new Exception($"Zone ({zoneName}) not found");
var records = await Retry.Do(async () => await _client.GetDnsRecords(neededZone), RetryCount, RetryDelay);
var neededRecord = records.FirstOrDefault(r =>
r.Name.Equals(NormalizeDnsName(id, zoneName), StringComparison.OrdinalIgnoreCase) &&
r.Type == DnsRecordType.TXT);
var records = await Retry.Do(async () => await _client.GetDnsRecords(neededZone), RetryCount,
RetryDelay);
var neededRecord = records.FirstOrDefault(r =>
r.Name.Equals(NormalizeDnsName(id, zoneName), StringComparison.OrdinalIgnoreCase) &&
r.Type == DnsRecordType.TXT);
if (neededRecord == null)
throw new Exception($"Dns record ({id}) not found");
if (neededRecord == null)
throw new Exception($"Dns record ({id}) not found");
await Retry.Do(async () => await _client.RemoveDnsRecord(neededZone, neededRecord), RetryCount, RetryDelay);
await Retry.Do(async () => await _client.RemoveDnsRecord(neededZone, neededRecord), RetryCount,
RetryDelay);
}, RetryCount, RetryDelay);
}

public void Dispose()
Expand Down

0 comments on commit 35f6ece

Please sign in to comment.