diff --git a/README.md b/README.md index 06dcc78..bb400ce 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,14 @@ -[![Join the chat at https://gitter.im/Daplie/letsencrypt-express](https://badges.gitter.im/Daplie/letsencrypt-express.svg)](https://gitter.im/Daplie/letsencrypt-express?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -| [letsencrypt](https://github.com/Daplie/node-letsencrypt) (library) -| [letsencrypt-cli](https://github.com/Daplie/letsencrypt-cli) -| [letsencrypt-express](https://github.com/Daplie/letsencrypt-express) -| [letsencrypt-koa](https://github.com/Daplie/letsencrypt-koa) -| [letsencrypt-hapi](https://github.com/Daplie/letsencrypt-hapi) -| - le-challenge-dns ================ -**For production** use [`le-challenge-ddns`](https://github.com/Daplie/le-challenge-ddns) (or a similar ddns tool) +| Sponsored by [ppl](https://ppl.family) +| [greenlock.js](https://git.coolaj86.com/coolaj86/greenlock.js) (library) +| [greenlock-express.js](https://git.coolaj86.com/coolaj86/greenlock-express.js) +| [greenlock-cli.js](https://git.coolaj86.com/coolaj86/greenlock-cli.js) +| [acme-v2.js](https://git.coolaj86.com/coolaj86/acme-v2.js) +| + +**For production** use [`le-challenge-ddns`](https://git.coolaj86.com/coolaj86/le-challenge-ddns) (or a similar ddns tool) A manual (interactive CLI) dns-based strategy for node-letsencrypt for setting, retrieving, and clearing ACME DNS-01 challenges issued by the ACME server diff --git a/index.js b/index.js index d1ba9bb..19cb102 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ var dns = PromiseA.promisifyAll(require('dns')); var Challenge = module.exports; Challenge.create = function (defaults) { - return { + return { getOptions: function () { return defaults || {}; } @@ -74,3 +74,41 @@ Challenge.loopback = function (defaults, domain, challenge, done) { console.log("dig TXT +noall +answer @8.8.8.8 '" + challengeDomain + "' # " + challenge); dns.resolveTxtAsync(challengeDomain).then(function (x) { done(null, x); }, done); }; + +Challenge.test = function (args, domain, challenge, keyAuthorization, done) { + var me = this; + + args.test = args.test || '_test.'; + defaults.test = args.test; + + me.set(args, domain, challenge, keyAuthorization || challenge, function (err, k) { + if (err) { done(err); return; } + + me.loopback(defaults, domain, challenge, function (err, arr) { + if (err) { done(err); return; } + + if (!arr.some(function (a) { + return a.some(function (keyAuthDigest) { + return keyAuthDigest === k; + }); + })) { + err = new Error("txt record '" + challenge + "' doesn't match '" + k + "'"); + } + + me.remove(defaults, domain, challenge, function (_err) { + if (_err) { done(_err); return; } + + // TODO needs to use native-dns so that specific nameservers can be used + // (otherwise the cache will still have the old answer) + done(err || null); + /* + me.loopback(defaults, domain, challenge, function (err) { + if (err) { done(err); return; } + + done(); + }); + */ + }); + }); + }); +} diff --git a/package.json b/package.json index 6d9428f..354404c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "le-challenge-dns", - "version": "2.1.0", + "version": "2.2.1", "description": "A manual (interactive CLI) dns-based strategy for node-letsencrypt for setting, retrieving, and clearing ACME DNS-01 challenges issued by the ACME server", "main": "index.js", "scripts": { @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Daplie/le-challenge-dns.git" + "url": "git+https://git.coolaj86.com/coolaj86/le-challenge-dns.js.git" }, "keywords": [ "le", @@ -20,6 +20,8 @@ "interactive", "cli", "acme", + "Let's Encrypt v2", + "LetsEncrypt", "challenge", "dns", "cluster", @@ -28,9 +30,9 @@ "author": "AJ ONeal (https://coolaj86.com/)", "license": "(MIT OR Apache-2.0)", "bugs": { - "url": "https://github.com/Daplie/le-challenge-dns/issues" + "url": "https://git.coolaj86.com/coolaj86/le-challenge-dns.js/issues" }, - "homepage": "https://github.com/Daplie/le-challenge-dns#readme", + "homepage": "https://git.coolaj86.com/coolaj86/le-challenge-dns.js", "dependencies": { } }