Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix letsencrypt error handling. Update deps. Bump version.
  • Loading branch information
Rush committed Jan 29, 2017
1 parent e5e6db3 commit 2851248
Show file tree
Hide file tree
Showing 4 changed files with 2,049 additions and 19 deletions.
8 changes: 5 additions & 3 deletions modules/letsencrypt.js
Expand Up @@ -65,9 +65,10 @@ module.exports = function LetsEncrypt(commService, master, worker, moduleConfig,
return;
}

let LEX = require('greenlock');//.testing();
var leChallenge = require('le-challenge-standalone').create({ debug: false });
let LEX = require('greenlock');
var leChallenge = require('le-challenge-standalone').create({ debug: true });
let lex = LEX.create({
debug: !!process.env.LETSENCRYPT_DEBUG,
server: process.env.LETSENCRYPT_STAGING ? 'staging' : LEX.productionServerUrl,
configDir: moduleConfig.configDir,
challenge: leChallenge,
Expand Down Expand Up @@ -98,7 +99,8 @@ module.exports = function LetsEncrypt(commService, master, worker, moduleConfig,
});

let getCertificatesAsync = require('memoizee')(lex.getCertificatesAsync, {
maxAge: 10000,
maxAge: 10000, // prevent DoS
promise: 'then' // cache also errors
});

comm.onRequest('getCertificates', data => {
Expand Down
11 changes: 9 additions & 2 deletions modules/services/comm.js
Expand Up @@ -17,6 +17,10 @@ module.exports = function CommService(events, master, worker) {
events.on('msg:' + namespace + ':request:' + name, (reqData, worker) => {
Promise.resolve().then(() => handler(reqData.data, worker)).then(resData => {
worker.sendMessage(reqData.uuid, resData);;
}).catch(err => {
worker.sendMessage(reqData.uuid, {
error: err.message
})
});
});
},
Expand All @@ -30,8 +34,8 @@ module.exports = function CommService(events, master, worker) {

process.on('msg', msg => {
if(requestMap[msg.type]) {
if(msg.error) {
requestMap[msg.type].error(msg.error);
if(msg.data && msg.data.error) {
requestMap[msg.type].error(msg.data.error);
} else {
requestMap[msg.type](msg.data);
}
Expand All @@ -49,6 +53,9 @@ module.exports = function CommService(events, master, worker) {
};
requestMap[__uuid].error = err => {
delete requestMap[__uuid];
if(!(err instanceof Error)) {
err = new Error(err);
}
reject(err);
};

Expand Down
29 changes: 15 additions & 14 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "http-master",
"version": "1.2.5",
"version": "1.2.6",
"description": "Easy to setup, convenient, universal, parallel, http/https proxy daemon. Setup in 1 minute, run, configure, adapt. Proxying based on excellent node-http-proxy.",
"main": "src/HttpMaster.js",
"scripts": {
Expand All @@ -26,47 +26,48 @@
],
"license": "MIT",
"dependencies": {
"async": "^2.0.1",
"async": "^2.1.4",
"bluebird": "^3.4.3",
"bugsnag": "1.8.0",
"compression": "1.6.2",
"connect-gzip-static": "1.0.0",
"eventemitter3": "1.2.0",
"compression": "^1.6.2",
"connect-gzip-static": "^1.0.0",
"eventemitter3": "^1.2.0",
"extend": "3.0.0",
"greenlock": "^2.1.11",
"http-auth": "~2.2.9",
"http-proxy": "^1.14.0",
"http-proxy": "^1.16.2",
"js-yaml": "3.6.1",
"jsonfn": "0.31.0",
"jsonlint-lines": "1.7.1",
"le-challenge-standalone": "^2.0.0",
"le-sni-auto": "^2.0.1",
"greenlock": "^2.1.11",
"memoizee": "^0.4.1",
"moment": "2.14.1",
"moment": "^2.17.1",
"morgan": "1.7.0",
"node-watch": "^0.4.0",
"ocsp": "^1.1.0",
"parseurl": "1.3.1",
"send": "0.14.1",
"parseurl": "^1.3.1",
"send": "^0.14.2",
"spdy": "^3.4.0",
"uid-number": "0.0.6",
"uuid": "^2.0.2",
"ws": "^1.1.1",
"x509.js": "1.0.0",
"xregexp": "3.1.1",
"yargs": "5.0.0"
"xregexp": "^3.1.1",
"yargs": "^6.6.0"
},
"devDependencies": {
"chai": "^3.5.0",
"fs.extra": "1.3.2",
"istanbul": "^0.4.5",
"mocha": "^3.0.2",
"request": "^2.79.0",
"request-promise": "^4.1.1",
"should": "^11.1.0"
},
"optionalDependencies": {
"bufferutil": "^1.2.1",
"codeclimate-test-reporter": "~0.3.3",
"bufferutil": "1.2.1",
"utf-8-validate": "1.2.1"
"utf-8-validate": "^1.2.1"
}
}

0 comments on commit 2851248

Please sign in to comment.