minor bugfixes, log enchancements, etc

This commit is contained in:
AJ ONeal 2015-12-30 11:48:33 -05:00
parent e8e23388d0
commit 62509a4800
6 changed files with 41 additions and 16 deletions

View File

@ -40,7 +40,7 @@ cli.main(function(_, options) {
} }
if (options.debug) { if (options.debug) {
console.log('options'); console.log('[HP CLI] options');
console.log(options); console.log(options);
} }

View File

@ -41,18 +41,40 @@ module.exports.create = function (opts) {
process.nextTick(function () { process.nextTick(function () {
results.plainServers.forEach(function (plainServer) { results.plainServers.forEach(function (plainServer) {
plainServer.listen( plainServer.on('error', function (err) {
plainServer.__plainPort.internal || plainServer.__plainPort.port plainServer.error = err;
, plainServer.__plainPort.address || '0.0.0.0' console.warn("[HP loop] Error with plain HTTP server:");
, onListen console.warn(err.stack);
); });
try {
plainServer.listen(
plainServer.__plainPort.internal || plainServer.__plainPort.port
, plainServer.__plainPort.address || '0.0.0.0'
, onListen
);
} catch(e) {
plainServer.error = e;
console.warn("[HP loop] Could not create plain HTTP listener:");
console.warn(e.stack);
}
}); });
results.tlsServers.forEach(function (tlsServer) { results.tlsServers.forEach(function (tlsServer) {
tlsServer.listen( tlsServer.on('error', function (err) {
tlsServer.__tlsPort.internal || tlsServer.__tlsPort.port tlsServer.error = err;
, tlsServer.__tlsPort.address || '0.0.0.0' console.warn("[HP loop] Error with HTTPS server:");
, onListen console.warn(err.stack);
); });
try {
tlsServer.listen(
tlsServer.__tlsPort.internal || tlsServer.__tlsPort.port
, tlsServer.__tlsPort.address || '0.0.0.0'
, onListen
);
} catch(e) {
tlsServer.error = e;
console.warn("[HP loop] Could not create HTTPS listener:");
console.warn(e.stack);
}
}); });
}); });

View File

@ -65,9 +65,12 @@ function pmpForwardHelper(gw, portInfo) {
} }
// explicitly ask for the current external IP address // explicitly ask for the current external IP address
// TODO why did I use a setTimeout here? event loop / timing bug?
setTimeout(function () { setTimeout(function () {
client.externalIp(function (err, info) { client.externalIp(function (err, info) {
if (err) { throw err; } console.error('[HP] Error: setTimeout client.externalIp:');
console.error(err.stack);
if (err) { return PromiseA.reject(err); }
console.log('Current external IP address: %s', info.ip.join('.')); console.log('Current external IP address: %s', info.ip.join('.'));
setPortForward(); setPortForward();
}); });

View File

@ -9,7 +9,6 @@ function requestAsync(opts) {
var httpr = (false === opts.secure) ? http : https; var httpr = (false === opts.secure) ? http : https;
console.log('[HP] loopback test opts'); console.log('[HP] loopback test opts');
console.log(typeof opts.port, opts.port);
console.log(opts); console.log(opts);
var req = httpr.request(opts, function (res) { var req = httpr.request(opts, function (res) {

View File

@ -88,9 +88,9 @@ function run() {
exports.upnpForward(options).then(function () { exports.upnpForward(options).then(function () {
console.log('done'); console.log('done');
}).catch(function (err) { }).catch(function (err) {
console.error('ERROR'); console.error('[HP] Error: upnpForward:');
console.error(err); console.error(err.stack);
throw err; return PromiseA.reject(err);
}); });
} }

View File

@ -11,6 +11,7 @@
}, },
"dependencies": { "dependencies": {
"bluebird": "^3.1.1", "bluebird": "^3.1.1",
"cli": "^0.11.1",
"express": "^4.13.3", "express": "^4.13.3",
"holepunch-nat-pmp": "^1.0.0-alpha.1", "holepunch-nat-pmp": "^1.0.0-alpha.1",
"holepunch-upnp": "^1.0.0-alpha.1", "holepunch-upnp": "^1.0.0-alpha.1",