diff options
Diffstat (limited to 'src/main.lib/Plugins/ValidationPlugins/Dns/Manual/Manual.cs')
-rw-r--r-- | src/main.lib/Plugins/ValidationPlugins/Dns/Manual/Manual.cs | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/src/main.lib/Plugins/ValidationPlugins/Dns/Manual/Manual.cs b/src/main.lib/Plugins/ValidationPlugins/Dns/Manual/Manual.cs index 317afe9..880eb6c 100644 --- a/src/main.lib/Plugins/ValidationPlugins/Dns/Manual/Manual.cs +++ b/src/main.lib/Plugins/ValidationPlugins/Dns/Manual/Manual.cs @@ -1,4 +1,6 @@ using PKISharp.WACS.Clients.DNS; +using PKISharp.WACS.Context; +using PKISharp.WACS.Plugins.Interfaces; using PKISharp.WACS.Services; using System.Threading.Tasks; @@ -7,39 +9,42 @@ namespace PKISharp.WACS.Plugins.ValidationPlugins.Dns internal class Manual : DnsValidation<Manual> { private readonly IInputService _input; - private readonly string _identifier; + + public override ParallelOperations Parallelism => ParallelOperations.Answer; public Manual( LookupClientProvider dnsClient, ILogService log, IInputService input, - ISettingsService settings, - string identifier) - : base(dnsClient, log, settings) + ISettingsService settings) : base(dnsClient, log, settings) { // Usually it's a big no-no to rely on user input in validation plugin // because this should be able to run unattended. This plugin is for testing // only and therefor we will allow it. Future versions might be more advanced, // e.g. shoot an email to an admin and complete the order later. _input = input; - _identifier = identifier; } - public override async Task CreateRecord(string recordName, string token) + public override async Task<bool> CreateRecord(DnsValidationRecord record) { - _input.Show("Domain", _identifier, true); - _input.Show("Record", recordName); + _input.CreateSpace(); + _input.Show("Domain", record.Context.Identifier); + _input.Show("Record", record.Authority.Domain); _input.Show("Type", "TXT"); - _input.Show("Content", $"\"{token}\""); + _input.Show("Content", $"\"{record.Value}\""); _input.Show("Note", "Some DNS managers add quotes automatically. A single set is needed."); - await _input.Wait("Please press <Enter> after you've created and verified the record"); + if (!await _input.Wait("Please press <Enter> after you've created and verified the record")) + { + _log.Warning("User aborted"); + return false; + } // Pre-pre-validate, allowing the manual user to correct mistakes while (true) { - if (await PreValidate(0)) + if (await PreValidate(record)) { - break; + return true; } else { @@ -50,18 +55,19 @@ namespace PKISharp.WACS.Plugins.ValidationPlugins.Dns "try ACME validation anyway.", true); if (!retry) { - break; + return false; } } } } - public override Task DeleteRecord(string recordName, string token) + public override Task DeleteRecord(DnsValidationRecord record) { - _input.Show("Domain", _identifier, true); - _input.Show("Record", recordName); + _input.CreateSpace(); + _input.Show("Domain", record.Context.Identifier); + _input.Show("Record", record.Authority.Domain); _input.Show("Type", "TXT"); - _input.Show("Content", $"\"{token}\""); + _input.Show("Content", $"\"{record.Value}\""); _input.Wait("Please press <Enter> after you've deleted the record"); return Task.CompletedTask; } |