diff --git a/lib/index.js b/lib/index.js index 3eb30e4..2ee4e58 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,9 +1,13 @@ 'use strict'; var request; -var defaults = {}; +var defaults = { + wait: 15 * 1000 +}; module.exports.create = function(config) { + var wait = config.wait || defaults.wait; + return { init: function(opts) { request = opts.request; @@ -14,14 +18,22 @@ module.exports.create = function(config) { throw Error('listing zones not implemented'); }, set: function(data) { + // console.info('Add TXT', data); var ch = data.challenge; if (!ch.dnsZone) { // 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); } - // console.info('Add TXT', data); + 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) { // console.info('Remove TXT', data);