From 159ffe0728a6e2f3a28c8f70c61ca10553dea806 Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Fri, 22 Jul 2016 02:11:04 +0200 Subject: [PATCH] now requesting in parallel --- dist/cert.helpers.d.ts | 3 ++ dist/cert.helpers.js | 16 ++++++++++ dist/cert.paths.d.ts | 7 +++-- dist/cert.paths.js | 11 ++++--- dist/cert.plugins.d.ts | 1 + dist/cert.plugins.js | 3 +- dist/index.d.ts | 2 +- dist/index.js | 58 +++++++++++++++++++++-------------- package.json | 1 + test/test.js | 6 ++-- test/test.ts | 4 +-- ts/cert.helpers.ts | 18 +++++++++++ ts/cert.paths.ts | 10 +++--- ts/cert.plugins.ts | 1 + ts/index.ts | 69 ++++++++++++++++++++++++------------------ 15 files changed, 139 insertions(+), 71 deletions(-) create mode 100644 dist/cert.helpers.d.ts create mode 100644 dist/cert.helpers.js create mode 100644 ts/cert.helpers.ts diff --git a/dist/cert.helpers.d.ts b/dist/cert.helpers.d.ts new file mode 100644 index 0000000..3a4bbf5 --- /dev/null +++ b/dist/cert.helpers.d.ts @@ -0,0 +1,3 @@ +/// +import * as plugins from "./cert.plugins"; +export declare let accountsKeyPresent: () => plugins.q.Promise<{}>; diff --git a/dist/cert.helpers.js b/dist/cert.helpers.js new file mode 100644 index 0000000..3a3afca --- /dev/null +++ b/dist/cert.helpers.js @@ -0,0 +1,16 @@ +"use strict"; +const plugins = require("./cert.plugins"); +let firstCall = true; +exports.accountsKeyPresent = () => { + let done = plugins.q.defer(); + if (firstCall) { + done.resolve(); + firstCall = false; + } + else { + setTimeout(done.resolve, 5000); + } + ; + return done.promise; +}; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvY2VydC5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxnQkFBZ0IsQ0FBQyxDQUFBO0FBRzFDLElBQUksU0FBUyxHQUFHLElBQUksQ0FBQztBQUNWLDBCQUFrQixHQUFHO0lBQzVCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsRUFBRSxDQUFDLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQztRQUNaLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztRQUNmLFNBQVMsR0FBRyxLQUFLLENBQUM7SUFDdEIsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osVUFBVSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDbkMsQ0FBQztJQUFBLENBQUM7SUFFRixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/dist/cert.paths.d.ts b/dist/cert.paths.d.ts index 2c134a9..cf04b3b 100644 --- a/dist/cert.paths.d.ts +++ b/dist/cert.paths.d.ts @@ -1,7 +1,8 @@ +export declare let certDir: string; +export declare let defaultSslDir: string; +export declare let assetDir: string; +export declare let accountsDir: string; export declare let certHook: string; export declare let config: string; export declare let leShConfig: string; export declare let letsencryptSh: string; -export declare let certDir: string; -export declare let defaultSslDir: string; -export declare let assetDir: string; diff --git a/dist/cert.paths.js b/dist/cert.paths.js index 45ef1b3..2f457ee 100644 --- a/dist/cert.paths.js +++ b/dist/cert.paths.js @@ -1,12 +1,13 @@ "use strict"; const plugins = require("./cert.plugins"); +//dirs +exports.certDir = plugins.path.join(__dirname, "assets/certs"); +exports.defaultSslDir = plugins.path.join(__dirname, "assets/defaultSslDir"); +exports.assetDir = plugins.path.join(__dirname, "assets/"); +exports.accountsDir = plugins.path.join(__dirname, "assets/accounts/"); // files exports.certHook = plugins.path.join(__dirname, "cert.hook.js"); exports.config = plugins.path.join(__dirname, "assets/config.json"); exports.leShConfig = plugins.path.join(__dirname, "assets/leshconfig.json"); exports.letsencryptSh = plugins.path.join(__dirname, "assets/letsencrypt.sh"); -//dirs -exports.certDir = plugins.path.join(__dirname, "assets/certs"); -exports.defaultSslDir = plugins.path.join(__dirname, "assets/defaultSslDir"); -exports.assetDir = plugins.path.join(__dirname, "assets/"); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2NlcnQucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLGdCQUFnQixDQUFDLENBQUE7QUFFMUMsUUFBUTtBQUNHLGdCQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLGNBQWMsQ0FBQyxDQUFDO0FBQ3ZELGNBQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsb0JBQW9CLENBQUMsQ0FBQztBQUMzRCxrQkFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyx3QkFBd0IsQ0FBQyxDQUFDO0FBQ25FLHFCQUFhLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLHVCQUF1QixDQUFDLENBQUM7QUFFaEYsTUFBTTtBQUNLLGVBQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsY0FBYyxDQUFDLENBQUM7QUFDdEQscUJBQWEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUMsc0JBQXNCLENBQUMsQ0FBQztBQUNwRSxnQkFBUSxHQUFHLE9BQU8sQ0FBQyxJ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SSxDQUFDLFNBQVMsRUFBQyx1QkFBdUIsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/dist/cert.plugins.d.ts b/dist/cert.plugins.d.ts index 3dfdfce..4523d89 100644 --- a/dist/cert.plugins.d.ts +++ b/dist/cert.plugins.d.ts @@ -2,6 +2,7 @@ import "typings-global"; export import beautylog = require("beautylog"); export import cflare = require("cflare"); export declare let fs: any; +export import lik = require("lik"); export import path = require("path"); export import q = require("q"); export import shelljs = require("shelljs"); diff --git a/dist/cert.plugins.js b/dist/cert.plugins.js index 892f670..9462016 100644 --- a/dist/cert.plugins.js +++ b/dist/cert.plugins.js @@ -3,6 +3,7 @@ require("typings-global"); exports.beautylog = require("beautylog"); exports.cflare = require("cflare"); exports.fs = require("fs-extra"); +exports.lik = require("lik"); exports.path = require("path"); exports.q = require("q"); exports.shelljs = require("shelljs"); @@ -10,4 +11,4 @@ exports.smartcli = require("smartcli"); exports.smartfile = require("smartfile"); exports.smartgit = require("smartgit"); exports.smartstring = require("smartstring"); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvY2VydC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGNBQU0sV0FBVyxRQUFRLENBQUMsQ0FBQztBQUM5QixVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3RCLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLGdCQUFRLFdBQVcsVUFBVSxDQUFDLENBQUM7QUFDL0IsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLG1CQUFXLFdBQVcsYUFBYSxDQUFDLENBQUMifQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2VydC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvY2VydC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGNBQU0sV0FBVyxRQUFRLENBQUMsQ0FBQztBQUM5QixVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3RCLFdBQUcsV0FBVyxLQUFLLENBQUMsQ0FBQztBQUNyQixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsU0FBQyxXQUFXLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGVBQU8sV0FBVyxTQUFTLENBQUMsQ0FBQztBQUM3QixnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsZ0JBQVEsV0FBVyxVQUFVLENBQUMsQ0FBQztBQUMvQixtQkFBVyxXQUFXLGFBQWEsQ0FBQyxDQUFDIn0= \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 48b8345..0ce6043 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -13,7 +13,7 @@ export declare class Cert { private _sslDir; private _gitOriginRepo; private _testMode; - domainsCurrentlyRequesting: string[]; + domainsCurrentlyRequesting: plugins.lik.Stringmap; certificatesPresent: Certificate[]; certificatesValid: Certificate[]; /** diff --git a/dist/index.js b/dist/index.js index e935d8c..7fffaa4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,13 +1,14 @@ "use strict"; const plugins = require("./cert.plugins"); const paths = require("./cert.paths"); +const helpers = require("./cert.helpers"); ; class Cert { /** * Constructor for Cert object */ constructor(optionsArg) { - this.domainsCurrentlyRequesting = []; + this.domainsCurrentlyRequesting = new plugins.lik.Stringmap(); /** * Pulls already requested certificates from git origin */ @@ -58,7 +59,6 @@ class Cert { plugins.smartfile.memory.toFsSync(leShConfigString, paths.leShConfig); plugins.shelljs.exec("chmod 700 " + paths.letsencryptSh); plugins.shelljs.exec("chmod 700 " + paths.certHook); - plugins.shelljs.exec(`bash -c "${paths.letsencryptSh}`); } ; /** @@ -66,27 +66,39 @@ class Cert { */ getDomainCert(domainNameArg, optionsArg = { force: false }) { let done = plugins.q.defer(); - if (!checkDomainsStillValid(domainNameArg, this._sslDir) || optionsArg.force) { - plugins.smartfile.fs.ensureDir(paths.certDir); - plugins.beautylog.info(`getting cert for ${domainNameArg}`); - plugins.shelljs.exec(`bash -c "${paths.letsencryptSh} -c --no-lock -f ${paths.leShConfig} -d ${domainNameArg} -t dns-01 -k ${paths.certHook} -o ${paths.certDir}"`, { - silent: true, - async: true - }, (codeArg, stdoutArg) => { - console.log(stdoutArg); - let fetchedCertsArray = plugins.smartfile.fs.listFoldersSync(paths.certDir); - if (fetchedCertsArray.indexOf(domainNameArg) != -1) { - updateSslDirSync(this._sslDir, domainNameArg); - plugins.smartfile.fs.removeSync(plugins.path.join(paths.certDir, domainNameArg)); + // make sure no one else requires the same domain at the same time + helpers.accountsKeyPresent().then(() => { + if (!this.domainsCurrentlyRequesting.checkString(domainNameArg)) { + this.domainsCurrentlyRequesting.addString(domainNameArg); + if (!checkDomainsStillValid(domainNameArg, this._sslDir) || optionsArg.force) { + plugins.smartfile.fs.ensureDir(paths.certDir); + plugins.beautylog.info(`getting cert for ${domainNameArg}`); + plugins.shelljs.exec(`bash -c "${paths.letsencryptSh} -c --no-lock -f ${paths.leShConfig} -d ${domainNameArg} -t dns-01 -k ${paths.certHook} -o ${paths.certDir}"`, { + silent: true, + async: true + }, (codeArg, stdoutArg) => { + console.log(stdoutArg); + let fetchedCertsArray = plugins.smartfile.fs.listFoldersSync(paths.certDir); + if (fetchedCertsArray.indexOf(domainNameArg) != -1) { + updateSslDirSync(this._sslDir, domainNameArg); + plugins.smartfile.fs.removeSync(plugins.path.join(paths.certDir, domainNameArg)); + } + this.domainsCurrentlyRequesting.removeString(domainNameArg); + done.resolve(); + }); } - done.resolve(); - }); - } - else { - plugins.beautylog.info("certificate for " + domainNameArg + " is still valid! Not fetching new one!"); - done.resolve(); - } - ; + else { + plugins.beautylog.info("certificate for " + domainNameArg + " is still valid! Not fetching new one!"); + this.domainsCurrentlyRequesting.removeString(domainNameArg); + done.resolve(); + } + ; + } + else { + plugins.beautylog.warn(`${domainNameArg} is already requesting`); + } + ; + }); return done.promise; } ; @@ -138,4 +150,4 @@ let updateSslDirSync = (sslDirArg, domainNameArg) => { let updateGitOrigin = (syncDirectionArg) => { }; updateGitOrigin(0 /* toOrigin */); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0sZ0JBQWdCLENBQUMsQ0FBQTtBQUMxQyxNQUFZLEtBQUssV0FBTSxjQUFjLENBQUMsQ0FBQTtBQVFyQyxDQUFDO0FBRUY7SUFVSTs7T0FFRztJQUNILFlBQVksVUFBa0M7UUFQOUMsK0JBQTBCLEdBQWEsRUFBRSxDQUFDO1FBOEMxQzs7V0FFRztRQUNILHFCQUFnQixHQUFHO1lBQ2YsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxDQUFDLENBQUM7Z0JBQ3RCLE9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sSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsYUFBYSxFQUFFLGFBQWEsQ0FBQyxDQUM3RCxDQUFDO1FBQ0YscUJBQXFCO1FBQ3JCLElBQUksU0FBUyxHQUFHLG1CQUFtQixDQUFDO1FBQ3BDLElBQUksb0JBQW9CLEdBQVcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLGdCQUFnQixFQUFFLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ3RHLElBQUksUUFBUSxHQUFHLFFBQVEsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLG9CQUFvQixDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNqRSxJQUFJLFVBQVUsR0FBZTtZQUN6QixVQUFVLEVBQUUsYUFBYTtZQUN6QixPQUFPLEVBQUUsUUFBUTtZQUNqQixPQUFPLEVBQUUsUUFBUSxHQUFHLE9BQU87U0FDOUIsQ0FBQztRQUNGLE9BQU8sQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FDN0IsSUFBSSxDQUFDLFNBQVMsQ0FBQyxVQUFVLENBQUMsRUFDMUIsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLGFBQWEsRUFBRSxhQUFhLENBQUMsQ0FDN0QsQ0FBQztJQUNOLENBQUM7SUFBQSxDQUFDO0FBQ04sQ0FBQyxDQUFBO0FBT0QsSUFBSSxlQUFlLEdBQUcsQ0FBQyxnQkFBa0M7QUFFekQsQ0FBQyxDQUFDO0FBRUYsZUFBZSxDQUFDLGdCQUF5QixDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/package.json b/package.json index 01ff73d..31e4c30 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "beautylog": "^5.0.14", "cflare": "0.0.9", "fs-extra": "^0.30.0", + "lik": "^1.0.2", "q": "^1.4.1", "shelljs": "^0.7.0", "smartcli": "^1.0.4", diff --git a/test/test.js b/test/test.js index 41b7fbe..9901de3 100644 --- a/test/test.js +++ b/test/test.js @@ -33,12 +33,12 @@ describe("cert", function () { this.timeout(120000); let promiseArray = []; promiseArray.push(testCert.getDomainCert("testing1.bleu.de")); - //promiseArray.push(testCert.getDomainCert("testing2.bleu.de")); - //promiseArray.push(testCert.getDomainCert("testing3.bleu.de")); + promiseArray.push(testCert.getDomainCert("testing2.bleu.de")); + promiseArray.push(testCert.getDomainCert("testing3.bleu.de")); q.all(promiseArray).then(() => { done(); }); }); }); }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQix1QkFBbUIsTUFBTSxDQUFDLENBQUE7QUFDMUIsTUFBTyxJQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDOUIsTUFBTyxDQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDeEIsMEJBQTJCLGlCQUFpQixDQUFDLENBQUE7QUFDN0MsTUFBWSxJQUFJLFdBQU0sZUFBZSxDQUFDLENBQUE7QUFHdEMsSUFBSSxRQUFRLEdBQUcsSUFBSSxXQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxFQUFFLE9BQU8sQ0FBQyxHQUFHLEVBQUUsR0FBRyxTQUFTLENBQUMsQ0FBQztBQUVsRSxJQUFJLFFBQWtCLENBQUM7QUFFdkIsUUFBUSxDQUFDLE1BQU0sRUFBQztJQUNaLFFBQVEsQ0FBQyxTQUFTLEVBQUM7UUFDZixFQUFFLENBQUMsZ0NBQWdDLEVBQUMsVUFBUyxJQUFJO1lBQzdDLElBQUksQ0FBQ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SxDQUFDLGFBQWEsQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDLENBQUM7WUFDOUQsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUMsQ0FBQyxJQUFJLENBQUM7Z0JBQ3JCLElBQUksRUFBRSxDQUFDO1lBQ1gsQ0FBQyxDQUFDLENBQUM7UUFDUCxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index e8d3849..8636c3b 100644 --- a/test/test.ts +++ b/test/test.ts @@ -36,8 +36,8 @@ describe("cert",function(){ this.timeout(120000); let promiseArray = []; promiseArray.push(testCert.getDomainCert("testing1.bleu.de")); - //promiseArray.push(testCert.getDomainCert("testing2.bleu.de")); - //promiseArray.push(testCert.getDomainCert("testing3.bleu.de")); + promiseArray.push(testCert.getDomainCert("testing2.bleu.de")); + promiseArray.push(testCert.getDomainCert("testing3.bleu.de")); q.all(promiseArray).then(() => { done(); }); diff --git a/ts/cert.helpers.ts b/ts/cert.helpers.ts new file mode 100644 index 0000000..fd6c697 --- /dev/null +++ b/ts/cert.helpers.ts @@ -0,0 +1,18 @@ +import * as plugins from "./cert.plugins"; +import * as paths from "./cert.paths"; + +let firstCall = true; +let accountKeyPresent = true; +export let accountsKeyPresent = () => { + let done = plugins.q.defer(); + if (firstCall) { + done.resolve(); + firstCall = false; + setTimeout(() => {accountKeyPresent = true},5000); + } else if(accountKeyPresent){ + done.resolve() + } else { + setTimeout(done.resolve, 5000); + }; + return done.promise; +}; \ No newline at end of file diff --git a/ts/cert.paths.ts b/ts/cert.paths.ts index ff17657..ba38048 100644 --- a/ts/cert.paths.ts +++ b/ts/cert.paths.ts @@ -1,12 +1,14 @@ import * as plugins from "./cert.plugins"; +//dirs +export let certDir = plugins.path.join(__dirname,"assets/certs"); +export let defaultSslDir = plugins.path.join(__dirname,"assets/defaultSslDir"); +export let assetDir = plugins.path.join(__dirname,"assets/"); +export let accountsDir = plugins.path.join(__dirname,"assets/accounts/"); + // files export let certHook = plugins.path.join(__dirname,"cert.hook.js"); export let config = plugins.path.join(__dirname,"assets/config.json"); export let leShConfig = plugins.path.join(__dirname,"assets/leshconfig.json"); export let letsencryptSh = plugins.path.join(__dirname,"assets/letsencrypt.sh"); -//dirs -export let certDir = plugins.path.join(__dirname,"assets/certs"); -export let defaultSslDir = plugins.path.join(__dirname,"assets/defaultSslDir"); -export let assetDir = plugins.path.join(__dirname,"assets/"); \ No newline at end of file diff --git a/ts/cert.plugins.ts b/ts/cert.plugins.ts index 8b1cc52..782dd0c 100644 --- a/ts/cert.plugins.ts +++ b/ts/cert.plugins.ts @@ -2,6 +2,7 @@ import "typings-global"; export import beautylog = require("beautylog"); export import cflare = require("cflare"); export let fs = require("fs-extra"); +export import lik = require("lik"); export import path = require("path"); export import q = require("q"); export import shelljs = require("shelljs"); diff --git a/ts/index.ts b/ts/index.ts index 53133fa..cbead4d 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,5 +1,6 @@ import * as plugins from "./cert.plugins"; import * as paths from "./cert.paths"; +import * as helpers from "./cert.helpers" export interface ICertConstructorOptions { cfEmail: string, @@ -7,7 +8,7 @@ export interface ICertConstructorOptions { sslDir?: string, gitOriginRepo?: string, testMode?: boolean -}; +}; export class Cert { private _cfEmail: string; @@ -15,14 +16,14 @@ export class Cert { private _sslDir: string; private _gitOriginRepo: string; private _testMode: boolean; - domainsCurrentlyRequesting: string[] = []; + domainsCurrentlyRequesting: plugins.lik.Stringmap = new plugins.lik.Stringmap(); certificatesPresent: Certificate[]; certificatesValid: Certificate[]; - + /** * Constructor for Cert object */ - constructor(optionsArg:ICertConstructorOptions) { + constructor(optionsArg: ICertConstructorOptions) { this._cfEmail = optionsArg.cfEmail; this._cfKey = optionsArg.cfKey; this._sslDir = optionsArg.sslDir; @@ -58,7 +59,6 @@ export class Cert { ); plugins.shelljs.exec("chmod 700 " + paths.letsencryptSh); plugins.shelljs.exec("chmod 700 " + paths.certHook); - plugins.shelljs.exec(`bash -c "${paths.letsencryptSh}`); }; /** @@ -86,29 +86,40 @@ export class Cert { */ getDomainCert(domainNameArg: string, optionsArg: { force: boolean } = { force: false }) { let done = plugins.q.defer(); - if (!checkDomainsStillValid(domainNameArg, this._sslDir) || optionsArg.force) { - plugins.smartfile.fs.ensureDir(paths.certDir); - plugins.beautylog.info(`getting cert for ${domainNameArg}`); - plugins.shelljs.exec( - `bash -c "${paths.letsencryptSh} -c --no-lock -f ${paths.leShConfig} -d ${domainNameArg} -t dns-01 -k ${paths.certHook} -o ${paths.certDir}"`, - { - silent: true, - async:true - }, - (codeArg, stdoutArg) => { - console.log(stdoutArg); - let fetchedCertsArray: string[] = plugins.smartfile.fs.listFoldersSync(paths.certDir); - if (fetchedCertsArray.indexOf(domainNameArg) != -1) { - updateSslDirSync(this._sslDir, domainNameArg); - plugins.smartfile.fs.removeSync(plugins.path.join(paths.certDir,domainNameArg)); - } + // make sure no one else requires the same domain at the same time + helpers.accountsKeyPresent().then(() => { + if (!this.domainsCurrentlyRequesting.checkString(domainNameArg)) { + this.domainsCurrentlyRequesting.addString(domainNameArg); + if (!checkDomainsStillValid(domainNameArg, this._sslDir) || optionsArg.force) { + plugins.smartfile.fs.ensureDir(paths.certDir); + plugins.beautylog.info(`getting cert for ${domainNameArg}`); + plugins.shelljs.exec( + `bash -c "${paths.letsencryptSh} -c --no-lock -f ${paths.leShConfig} -d ${domainNameArg} -t dns-01 -k ${paths.certHook} -o ${paths.certDir}"`, + { + silent: true, + async: true + }, + (codeArg, stdoutArg) => { + console.log(stdoutArg); + let fetchedCertsArray: string[] = plugins.smartfile.fs.listFoldersSync(paths.certDir); + if (fetchedCertsArray.indexOf(domainNameArg) != -1) { + updateSslDirSync(this._sslDir, domainNameArg); + plugins.smartfile.fs.removeSync(plugins.path.join(paths.certDir, domainNameArg)); + } + this.domainsCurrentlyRequesting.removeString(domainNameArg); + done.resolve(); + } + ); + } else { + plugins.beautylog.info("certificate for " + domainNameArg + " is still valid! Not fetching new one!"); + this.domainsCurrentlyRequesting.removeString(domainNameArg); done.resolve(); - } - ); - } else { - plugins.beautylog.info("certificate for " + domainNameArg + " is still valid! Not fetching new one!"); - done.resolve(); - }; + }; + } else { + plugins.beautylog.warn(`${domainNameArg} is already requesting`); + }; + }); + return done.promise; }; cleanOldCertificates() { @@ -132,8 +143,8 @@ interface certConfig { } let checkDomainsStillValid = (domainNameArg: string, sslDirArg: string): boolean => { - let domainConfigPath = plugins.path.join(sslDirArg, domainNameArg,"config.json"); - if (plugins.smartfile.fs.fileExistsSync(domainConfigPath)){ + let domainConfigPath = plugins.path.join(sslDirArg, domainNameArg, "config.json"); + if (plugins.smartfile.fs.fileExistsSync(domainConfigPath)) { let domainConfig = plugins.smartfile.fs.toObjectSync( domainConfigPath, "json"