Compare commits
14 Commits
775c5da038
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
d5f4abeeb0
|
|||
|
|
7d17ee38a4 | ||
|
|
d500dac31c | ||
|
|
fbda263da2 | ||
|
|
3d94eae00b | ||
|
56c278d84e
|
|||
|
20932e3b12
|
|||
|
62db7f8145
|
|||
|
|
10ce27ecac | ||
|
|
43c383c84b | ||
|
|
d5724f5c46 | ||
|
|
0a48c548db | ||
|
|
07b75a0298 | ||
|
|
d60c6fe57f |
@@ -1,3 +1,11 @@
|
|||||||
|
### 27/07/2023 (1.0.10)
|
||||||
|
|
||||||
|
- Add list profiles
|
||||||
|
|
||||||
|
### 14/07/2023 (1.0.9)
|
||||||
|
|
||||||
|
- Fixed the start with port unable to start
|
||||||
|
|
||||||
### 11/07/2023 (1.0.8)
|
### 11/07/2023 (1.0.8)
|
||||||
|
|
||||||
- Support tunnel with host with port
|
- Support tunnel with host with port
|
||||||
|
|||||||
81
package-lock.json
generated
81
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@cubetiq/hlt",
|
"name": "@cubetiq/hlt",
|
||||||
"version": "0.1.6",
|
"version": "0.1.9",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@cubetiq/hlt",
|
"name": "@cubetiq/hlt",
|
||||||
"version": "0.1.6",
|
"version": "0.1.9",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.2.0",
|
"axios": "^1.2.0",
|
||||||
@@ -140,26 +140,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/express": {
|
"node_modules/@types/express": {
|
||||||
"version": "4.17.15",
|
"version": "4.17.17",
|
||||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.15.tgz",
|
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz",
|
||||||
"integrity": "sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==",
|
"integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/body-parser": "*",
|
"@types/body-parser": "*",
|
||||||
"@types/express-serve-static-core": "^4.17.31",
|
"@types/express-serve-static-core": "^4.17.33",
|
||||||
"@types/qs": "*",
|
"@types/qs": "*",
|
||||||
"@types/serve-static": "*"
|
"@types/serve-static": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/express-serve-static-core": {
|
"node_modules/@types/express-serve-static-core": {
|
||||||
"version": "4.17.32",
|
"version": "4.17.35",
|
||||||
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.32.tgz",
|
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.35.tgz",
|
||||||
"integrity": "sha512-aI5h/VOkxOF2Z1saPy0Zsxs5avets/iaiAJYznQFm5By/pamU31xWKL//epiF4OfUA2qTOc9PV6tCUjhO8wlZA==",
|
"integrity": "sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
"@types/qs": "*",
|
"@types/qs": "*",
|
||||||
"@types/range-parser": "*"
|
"@types/range-parser": "*",
|
||||||
|
"@types/send": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/http-proxy": {
|
"node_modules/@types/http-proxy": {
|
||||||
@@ -177,9 +178,9 @@
|
|||||||
"devOptional": true
|
"devOptional": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.4.1",
|
"version": "20.4.5",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.5.tgz",
|
||||||
"integrity": "sha512-JIzsAvJeA/5iY6Y/OxZbv1lUcc8dNSE77lb2gnBH+/PJ3lFR1Ccvgwl5JWnHAkNHcRsT0TbpVOsiMKZ1F/yyJg=="
|
"integrity": "sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/qs": {
|
"node_modules/@types/qs": {
|
||||||
"version": "6.9.7",
|
"version": "6.9.7",
|
||||||
@@ -193,6 +194,22 @@
|
|||||||
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
|
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
|
||||||
"devOptional": true
|
"devOptional": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/send": {
|
||||||
|
"version": "0.17.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.1.tgz",
|
||||||
|
"integrity": "sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==",
|
||||||
|
"devOptional": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mime": "^1",
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/send/node_modules/@types/mime": {
|
||||||
|
"version": "1.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
|
||||||
|
"integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==",
|
||||||
|
"devOptional": true
|
||||||
|
},
|
||||||
"node_modules/@types/serve-static": {
|
"node_modules/@types/serve-static": {
|
||||||
"version": "1.15.0",
|
"version": "1.15.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz",
|
||||||
@@ -313,9 +330,9 @@
|
|||||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.2.2",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
|
||||||
"integrity": "sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q==",
|
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.0",
|
"follow-redirects": "^1.15.0",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
@@ -626,21 +643,21 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io-client": {
|
"node_modules/engine.io-client": {
|
||||||
"version": "6.2.3",
|
"version": "6.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.1.tgz",
|
||||||
"integrity": "sha512-aXPtgF1JS3RuuKcpSrBtimSjYvrbhKW9froICH4s0F3XQWLxsKNxqzG39nnvQZQnva4CMvUK63T7shevxRyYHw==",
|
"integrity": "sha512-hE5wKXH8Ru4L19MbM1GgYV/2Qo54JSMh1rlJbfpa40bEWkCKNo3ol2eOtGmowcr+ysgbI7+SGL+by42Q3pt/Ng==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@socket.io/component-emitter": "~3.1.0",
|
"@socket.io/component-emitter": "~3.1.0",
|
||||||
"debug": "~4.3.1",
|
"debug": "~4.3.1",
|
||||||
"engine.io-parser": "~5.0.3",
|
"engine.io-parser": "~5.1.0",
|
||||||
"ws": "~8.2.3",
|
"ws": "~8.11.0",
|
||||||
"xmlhttprequest-ssl": "~2.0.0"
|
"xmlhttprequest-ssl": "~2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io-parser": {
|
"node_modules/engine.io-parser": {
|
||||||
"version": "5.0.4",
|
"version": "5.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.1.0.tgz",
|
||||||
"integrity": "sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg==",
|
"integrity": "sha512-enySgNiK5tyZFynt3z7iqBR+Bto9EVVVvDFuTT0ioHCGbzirZVGDGiQjZzEp8hWl6hd5FSVytJGuScX1C1C35w==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
}
|
}
|
||||||
@@ -1564,14 +1581,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/socket.io-client": {
|
"node_modules/socket.io-client": {
|
||||||
"version": "4.5.4",
|
"version": "4.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.1.tgz",
|
||||||
"integrity": "sha512-ZpKteoA06RzkD32IbqILZ+Cnst4xewU7ZYK12aS1mzHftFFjpoMz69IuhP/nL25pJfao/amoPI527KnuhFm01g==",
|
"integrity": "sha512-Qk3Xj8ekbnzKu3faejo4wk2MzXA029XppiXtTF/PkbTg+fcwaTw1PlDrTrrrU4mKoYC4dvlApOnSeyLCKwek2w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@socket.io/component-emitter": "~3.1.0",
|
"@socket.io/component-emitter": "~3.1.0",
|
||||||
"debug": "~4.3.2",
|
"debug": "~4.3.2",
|
||||||
"engine.io-client": "~6.2.3",
|
"engine.io-client": "~6.5.1",
|
||||||
"socket.io-parser": "~4.2.1"
|
"socket.io-parser": "~4.2.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
@@ -2081,9 +2098,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/ws": {
|
"node_modules/ws": {
|
||||||
"version": "8.2.3",
|
"version": "8.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
|
||||||
"integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
|
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cubetiq/hlt",
|
"name": "@cubetiq/hlt",
|
||||||
"version": "0.1.8",
|
"version": "0.1.10",
|
||||||
"description": "A lightweight http tunnel client using nodejs and socket.io client",
|
"description": "A lightweight http tunnel client using nodejs and socket.io client",
|
||||||
"main": "dist/cli.js",
|
"main": "dist/cli.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ class HttpTunnelClient implements Client {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (address) {
|
if (typeof address !== "number" && address && address.includes(":")) {
|
||||||
const [host, portStr] = address.split(":");
|
const [host, portStr] = address.split(":");
|
||||||
if (host) {
|
if (host) {
|
||||||
options.host = host;
|
options.host = host;
|
||||||
@@ -321,6 +321,7 @@ class HttpTunnelClient implements Client {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
options.port = port;
|
options.port = port;
|
||||||
|
console.log(`default port: ${port} will be forwared`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
src/cli.ts
34
src/cli.ts
@@ -4,6 +4,7 @@ import * as os from "os";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { initConfigFileClient, startClient } from "./api";
|
import { initConfigFileClient, startClient } from "./api";
|
||||||
import { PROFILE_DEFAULT, PROFILE_PATH, SERVER_DEFAULT_URL, TOKEN_FREE } from "./constant";
|
import { PROFILE_DEFAULT, PROFILE_PATH, SERVER_DEFAULT_URL, TOKEN_FREE } from "./constant";
|
||||||
|
import { listProfile } from "./manage";
|
||||||
import { createProxyServer } from "./proxy";
|
import { createProxyServer } from "./proxy";
|
||||||
import { createProxyServer as createProxyTCPServer } from "./proxy_tcp";
|
import { createProxyServer as createProxyTCPServer } from "./proxy_tcp";
|
||||||
import { getTokenFree } from './sdk';
|
import { getTokenFree } from './sdk';
|
||||||
@@ -22,20 +23,20 @@ program
|
|||||||
program
|
program
|
||||||
.command("init")
|
.command("init")
|
||||||
.description("generate a new client and token with free access")
|
.description("generate a new client and token with free access")
|
||||||
.option("-s --server <string>", "setting server url", SERVER_DEFAULT_URL)
|
.option("-s, --server <string>", "setting server url", SERVER_DEFAULT_URL)
|
||||||
.option(
|
.option(
|
||||||
"-t --token <string>",
|
"-t, --token <string>",
|
||||||
"setting token (default generate FREE access token)",
|
"setting token (default generate FREE access token)",
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
.option("-a --access <string>", "setting token access type", TOKEN_FREE)
|
.option("-a, --access <string>", "setting token access type", TOKEN_FREE)
|
||||||
.option("-c --client <string>", "setting client (auto generate uuid)")
|
.option("-c, --client <string>", "setting client (auto generate uuid)")
|
||||||
.option(
|
.option(
|
||||||
"-k --key <string>",
|
"-k, --key <string>",
|
||||||
"setting client api key for authentication access"
|
"setting client api key for authentication access"
|
||||||
)
|
)
|
||||||
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||||
.option("-f --force", "force to generate new client and token", false)
|
.option("-f, --force", "force to generate new client and token", false)
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
initConfigFileClient(options);
|
initConfigFileClient(options);
|
||||||
});
|
});
|
||||||
@@ -91,7 +92,7 @@ program
|
|||||||
])
|
])
|
||||||
)
|
)
|
||||||
.argument("<value>", "config value")
|
.argument("<value>", "config value")
|
||||||
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||||
.action(async (type, value, options) => {
|
.action(async (type, value, options) => {
|
||||||
if (!type) {
|
if (!type) {
|
||||||
console.error("type config is required!");
|
console.error("type config is required!");
|
||||||
@@ -179,7 +180,7 @@ program
|
|||||||
"key",
|
"key",
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
|
||||||
.action(async (type, options) => {
|
.action(async (type, options) => {
|
||||||
if (!type) {
|
if (!type) {
|
||||||
console.error("type config is required!");
|
console.error("type config is required!");
|
||||||
@@ -271,7 +272,7 @@ program
|
|||||||
|
|
||||||
throw new InvalidArgumentError("Target is not a url or host with port.");
|
throw new InvalidArgumentError("Target is not a url or host with port.");
|
||||||
})
|
})
|
||||||
.option("-p --profile <string>", "setting profile name for connect with hlt server (proxy with current local port)")
|
.option("-p, --profile <string>", "setting profile name for connect with hlt server (proxy with current local port)")
|
||||||
.action((port, target, options) => {
|
.action((port, target, options) => {
|
||||||
const isTcp = target.indexOf("tcp") === 0;
|
const isTcp = target.indexOf("tcp") === 0;
|
||||||
if (isTcp) {
|
if (isTcp) {
|
||||||
@@ -322,4 +323,17 @@ const onConnectProxy = (port: number, options: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// profile
|
||||||
|
program
|
||||||
|
.command("profile")
|
||||||
|
.description("manage profile")
|
||||||
|
.option("-l, --list", "list all profiles", false)
|
||||||
|
.action((options) => {
|
||||||
|
if (options.list) {
|
||||||
|
listProfile();
|
||||||
|
} else {
|
||||||
|
console.log("profile command is required");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
program.parse();
|
program.parse();
|
||||||
|
|||||||
28
src/manage.ts
Normal file
28
src/manage.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import * as fs from "fs";
|
||||||
|
import * as os from "os";
|
||||||
|
import * as path from "path";
|
||||||
|
import { PROFILE_DEFAULT, PROFILE_PATH } from "./constant";
|
||||||
|
|
||||||
|
export const listProfile = () => {
|
||||||
|
const configDir = path.resolve(os.homedir(), PROFILE_PATH);
|
||||||
|
if (!fs.existsSync(configDir)) {
|
||||||
|
console.log(`config file ${configDir} not found`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const configFiles = fs.readdirSync(configDir);
|
||||||
|
if (configFiles.length === 0) {
|
||||||
|
console.log(`config file ${configDir} not found`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("List of profile:");
|
||||||
|
configFiles.forEach((file) => {
|
||||||
|
const configFilePath = path.resolve(configDir, file);
|
||||||
|
const config = JSON.parse(fs.readFileSync(configFilePath, "utf8"));
|
||||||
|
const name = file.replace(".json", "");
|
||||||
|
console.log(`- ${name} (${config.clientId})`);
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`\nCurrent profile: ${PROFILE_DEFAULT}`);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user