pass nat-pmp
This commit is contained in:
parent
8e5accc6ce
commit
4f12286b55
|
@ -71,6 +71,7 @@ cli.main(function(_, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return hp.create(args).then(function () {
|
return hp.create(args).then(function () {
|
||||||
process.exit(0);
|
console.log('wishing wanting waiting');
|
||||||
|
//process.exit(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,6 +28,10 @@ module.exports.create = function (args) {
|
||||||
function testOpenPort(ip, portInfo) {
|
function testOpenPort(ip, portInfo) {
|
||||||
var requestAsync = require('./request');
|
var requestAsync = require('./request');
|
||||||
|
|
||||||
|
if (args.debug) {
|
||||||
|
console.log('[HP] hostname', args.loopbackHostname);
|
||||||
|
}
|
||||||
|
|
||||||
return requestAsync({
|
return requestAsync({
|
||||||
secure: portInfo.secure
|
secure: portInfo.secure
|
||||||
, rejectUnauthorized: false
|
, rejectUnauthorized: false
|
||||||
|
@ -92,7 +96,10 @@ module.exports.create = function (args) {
|
||||||
|
|
||||||
return getExternalIps().then(function (ips) {
|
return getExternalIps().then(function (ips) {
|
||||||
var pretest = (-1 !== args.protocols.indexOf('none'));
|
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;
|
info.secure = true;
|
||||||
return info;
|
return info;
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -58,6 +58,8 @@ module.exports.create = function (opts) {
|
||||||
|
|
||||||
results.key = opts.key;
|
results.key = opts.key;
|
||||||
results.value = opts.value;
|
results.value = opts.value;
|
||||||
|
results.loopbackHostname = opts.loopbackHostname;
|
||||||
|
results.loopbackPrefix = opts.loopbackPrefix;
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,16 +43,20 @@ function middleware(opts) {
|
||||||
if (0 !== urlpath.indexOf(pathnamePrefix)) {
|
if (0 !== urlpath.indexOf(pathnamePrefix)) {
|
||||||
if (opts.debug) {
|
if (opts.debug) {
|
||||||
console.log("[HP] Pathname '" + urlpath + "'"
|
console.log("[HP] Pathname '" + urlpath + "'"
|
||||||
+ " failed to match '" + pathnamePrefix + "'");
|
+ " failed to match prefix '" + pathnamePrefix + ": "
|
||||||
|
+ urlpath.indexOf(pathnamePrefix)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scmp(key, urlpath.substr(pathnamePrefix.length, key.length))) {
|
if (!scmp(key, urlpath.substr(pathnamePrefix.length))) {
|
||||||
if (opts.debug) {
|
if (opts.debug) {
|
||||||
console.log("[HP] Pathname '" + urlpath + "'"
|
console.log("[HP] key '" + urlpath.substr(pathnamePrefix.length) + "'"
|
||||||
+ " failed to match '" + pathnamePrefix + key + "'");
|
+ " failed to match '" + key + "': "
|
||||||
|
+ scmp(key, urlpath.substr(pathnamePrefix.length))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -45,7 +45,7 @@ function pmpForwardHelper(gw, portInfo) {
|
||||||
|| portInfo.external || portInfo.public
|
|| portInfo.external || portInfo.public
|
||||||
, public: portInfo.external || portInfo.public
|
, public: portInfo.external || portInfo.public
|
||||||
|| portInfo.internal || portInfo.private
|
|| portInfo.internal || portInfo.private
|
||||||
, ttl: portInfo.ttl || 0 // 600
|
, ttl: portInfo.ttl || 7200 // 0 // 600
|
||||||
}, function (err, info) {
|
}, function (err, info) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
|
Loading…
Reference in New Issue