add wait option to template

This commit is contained in:
AJ ONeal 2019-07-31 16:33:12 -06:00
parent 560f0eddef
commit 472b89f193

View File

@ -1,9 +1,13 @@
'use strict'; 'use strict';
var request; var request;
var defaults = {}; var defaults = {
wait: 15 * 1000
};
module.exports.create = function(config) { module.exports.create = function(config) {
var wait = config.wait || defaults.wait;
return { return {
init: function(opts) { init: function(opts) {
request = opts.request; request = opts.request;
@ -14,14 +18,22 @@ module.exports.create = function(config) {
throw Error('listing zones not implemented'); throw Error('listing zones not implemented');
}, },
set: function(data) { set: function(data) {
// console.info('Add TXT', data);
var ch = data.challenge; var ch = data.challenge;
if (!ch.dnsZone) { if (!ch.dnsZone) {
// zones() is not implemented for http-01 challenges, // zones() is not implemented for http-01 challenges,
// but it is almost always implemented for dns-01 challenges // but it is almost always implemented for dns-01 challenges.
// Any plugin that implements zones() should expect ch.dnsZone here
throw new Error('No matching zone for ' + ch.dnsHost); throw new Error('No matching zone for ' + ch.dnsHost);
} }
// console.info('Add TXT', data);
throw Error('setting TXT not implemented'); throw Error('setting TXT not implemented');
// many APIs return a valid response quite a bit
// before they actually set the record, and checking
// too quickly will self-poison the response cache.
return new Promise(function(resolve) {
setTimeout(resolve, wait, null);
});
}, },
remove: function(data) { remove: function(data) {
// console.info('Remove TXT', data); // console.info('Remove TXT', data);