v0.19.22: only interpret strings with / or \ as paths

This commit is contained in:
AJ ONeal 2018-07-05 22:33:05 -06:00
parent 9c7a6c6eec
commit 96424aad4b
2 changed files with 14 additions and 2 deletions

View File

@ -622,6 +622,10 @@ function getToken(err, state) {
} }
function parseCli(/*state*/) { function parseCli(/*state*/) {
var special = [
'false', 'none', 'off', 'disable'
, 'true', 'auto', 'on', 'enable'
];
if (-1 !== argv.indexOf('init')) { if (-1 !== argv.indexOf('init')) {
utils.putConfig('list', []/*, function (err) { utils.putConfig('list', []/*, function (err) {
}*/); }*/);
@ -633,8 +637,16 @@ function parseCli(/*state*/) {
return false; return false;
} }
if (argv[1]) { if (argv[1]) {
if (String(argv[1]) !== String(parseInt(argv[1], 10))) { if (String(argv[1]) === String(parseInt(argv[1], 10))) {
// looks like a port
argv[1] = parseInt(argv[1], 10);
} else if (/\/|\\/.test(argv[1])) {
// looks like a path
argv[1] = path.resolve(argv[1]); argv[1] = path.resolve(argv[1]);
} else if (-1 === special.indexOf(argv[1])) {
console.error("Not sure what you meant by '" + argv[1] + "'.");
console.error("Remember: paths should begin with ." + path.sep + ", like '." + path.sep + argv[1] + "'");
return true;
} }
utils.putConfig(argv[0], argv.slice(1)); utils.putConfig(argv[0], argv.slice(1));
return true; return true;

View File

@ -1,6 +1,6 @@
{ {
"name": "telebit", "name": "telebit",
"version": "0.19.21", "version": "0.19.22",
"description": "Break out of localhost. Connect to any device from anywhere over any tcp port or securely in a browser. A secure tunnel. A poor man's reverse VPN.", "description": "Break out of localhost. Connect to any device from anywhere over any tcp port or securely in a browser. A secure tunnel. A poor man's reverse VPN.",
"main": "lib/remote.js", "main": "lib/remote.js",
"files": [ "files": [