pass nat-pmp

This commit is contained in:
AJ ONeal 2015-12-30 08:46:22 +00:00
parent 8e5accc6ce
commit 4f12286b55
5 changed files with 21 additions and 7 deletions

View File

@ -71,6 +71,7 @@ cli.main(function(_, options) {
}
return hp.create(args).then(function () {
process.exit(0);
console.log('wishing wanting waiting');
//process.exit(0);
});
});

View File

@ -28,6 +28,10 @@ module.exports.create = function (args) {
function testOpenPort(ip, portInfo) {
var requestAsync = require('./request');
if (args.debug) {
console.log('[HP] hostname', args.loopbackHostname);
}
return requestAsync({
secure: portInfo.secure
, rejectUnauthorized: false
@ -92,7 +96,10 @@ module.exports.create = function (args) {
return getExternalIps().then(function (ips) {
var pretest = (-1 !== args.protocols.indexOf('none'));
var portInfos = args.plainPorts.concat(args.tlsPorts.map(function (info) {
var portInfos = args.plainPorts.map(function (info) {
info.secure = false;
return info;
}).concat(args.tlsPorts.map(function (info) {
info.secure = true;
return info;
}));

View File

@ -58,6 +58,8 @@ module.exports.create = function (opts) {
results.key = opts.key;
results.value = opts.value;
results.loopbackHostname = opts.loopbackHostname;
results.loopbackPrefix = opts.loopbackPrefix;
return results;
};

View File

@ -43,16 +43,20 @@ function middleware(opts) {
if (0 !== urlpath.indexOf(pathnamePrefix)) {
if (opts.debug) {
console.log("[HP] Pathname '" + urlpath + "'"
+ " failed to match '" + pathnamePrefix + "'");
+ " failed to match prefix '" + pathnamePrefix + ": "
+ urlpath.indexOf(pathnamePrefix)
);
}
next();
return;
}
if (scmp(key, urlpath.substr(pathnamePrefix.length, key.length))) {
if (!scmp(key, urlpath.substr(pathnamePrefix.length))) {
if (opts.debug) {
console.log("[HP] Pathname '" + urlpath + "'"
+ " failed to match '" + pathnamePrefix + key + "'");
console.log("[HP] key '" + urlpath.substr(pathnamePrefix.length) + "'"
+ " failed to match '" + key + "': "
+ scmp(key, urlpath.substr(pathnamePrefix.length))
);
}
next();
return;

View File

@ -45,7 +45,7 @@ function pmpForwardHelper(gw, portInfo) {
|| portInfo.external || portInfo.public
, public: portInfo.external || portInfo.public
|| portInfo.internal || portInfo.private
, ttl: portInfo.ttl || 0 // 600
, ttl: portInfo.ttl || 7200 // 0 // 600
}, function (err, info) {
if (err) {
reject(err);