Compare commits

..

14 Commits

Author SHA1 Message Date
d5f4abeeb0 Add list profiles 2023-07-27 09:13:44 +07:00
Sambo Chea
7d17ee38a4 Merge pull request #146 from CUBETIQ/dependabot/npm_and_yarn/types/node-20.4.5
Bump @types/node from 20.4.4 to 20.4.5
2023-07-26 08:33:01 +07:00
dependabot[bot]
d500dac31c Bump @types/node from 20.4.4 to 20.4.5
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.4.4 to 20.4.5.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-25 20:53:00 +00:00
Sambo Chea
fbda263da2 Merge pull request #145 from CUBETIQ/dependabot/npm_and_yarn/types/node-20.4.4
Bump @types/node from 20.4.1 to 20.4.4
2023-07-25 21:25:46 +07:00
dependabot[bot]
3d94eae00b Bump @types/node from 20.4.1 to 20.4.4
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.4.1 to 20.4.4.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 20:49:54 +00:00
56c278d84e Updated 2023-07-14 08:32:27 +07:00
20932e3b12 Merge branch 'main' of https://github.com/CUBETIQ/http-tunnel-client 2023-07-14 08:31:29 +07:00
62db7f8145 Fixed the start port 2023-07-14 08:31:10 +07:00
Sambo Chea
10ce27ecac Merge pull request #141 from CUBETIQ/dependabot/npm_and_yarn/types/express-4.17.17
Bump @types/express from 4.17.15 to 4.17.17
2023-07-12 18:20:29 +07:00
Sambo Chea
43c383c84b Merge pull request #142 from CUBETIQ/dependabot/npm_and_yarn/axios-1.4.0
Bump axios from 1.2.2 to 1.4.0
2023-07-12 18:20:21 +07:00
Sambo Chea
d5724f5c46 Merge pull request #143 from CUBETIQ/dependabot/npm_and_yarn/socket.io-client-4.7.1
Bump socket.io-client from 4.5.4 to 4.7.1
2023-07-12 18:20:14 +07:00
dependabot[bot]
0a48c548db Bump socket.io-client from 4.5.4 to 4.7.1
Bumps [socket.io-client](https://github.com/socketio/socket.io-client) from 4.5.4 to 4.7.1.
- [Release notes](https://github.com/socketio/socket.io-client/releases)
- [Changelog](https://github.com/socketio/socket.io-client/blob/main/CHANGELOG.md)
- [Commits](https://github.com/socketio/socket.io-client/compare/4.5.4...4.7.1)

---
updated-dependencies:
- dependency-name: socket.io-client
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-11 20:53:57 +00:00
dependabot[bot]
07b75a0298 Bump axios from 1.2.2 to 1.4.0
Bumps [axios](https://github.com/axios/axios) from 1.2.2 to 1.4.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/1.2.2...v1.4.0)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-11 20:53:49 +00:00
dependabot[bot]
d60c6fe57f Bump @types/express from 4.17.15 to 4.17.17
Bumps [@types/express](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/express) from 4.17.15 to 4.17.17.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/express)

---
updated-dependencies:
- dependency-name: "@types/express"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-11 20:53:43 +00:00
6 changed files with 112 additions and 44 deletions

View File

@@ -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)
- Support tunnel with host with port

81
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@cubetiq/hlt",
"version": "0.1.6",
"version": "0.1.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@cubetiq/hlt",
"version": "0.1.6",
"version": "0.1.9",
"license": "ISC",
"dependencies": {
"axios": "^1.2.0",
@@ -140,26 +140,27 @@
}
},
"node_modules/@types/express": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.15.tgz",
"integrity": "sha512-Yv0k4bXGOH+8a+7bELd2PqHQsuiANB+A8a4gnQrkRWzrkKlb6KHaVvyXhqs04sVW/OWlbPyYxRgYlIXLfrufMQ==",
"version": "4.17.17",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz",
"integrity": "sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q==",
"devOptional": true,
"dependencies": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^4.17.31",
"@types/express-serve-static-core": "^4.17.33",
"@types/qs": "*",
"@types/serve-static": "*"
}
},
"node_modules/@types/express-serve-static-core": {
"version": "4.17.32",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.32.tgz",
"integrity": "sha512-aI5h/VOkxOF2Z1saPy0Zsxs5avets/iaiAJYznQFm5By/pamU31xWKL//epiF4OfUA2qTOc9PV6tCUjhO8wlZA==",
"version": "4.17.35",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.35.tgz",
"integrity": "sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==",
"devOptional": true,
"dependencies": {
"@types/node": "*",
"@types/qs": "*",
"@types/range-parser": "*"
"@types/range-parser": "*",
"@types/send": "*"
}
},
"node_modules/@types/http-proxy": {
@@ -177,9 +178,9 @@
"devOptional": true
},
"node_modules/@types/node": {
"version": "20.4.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz",
"integrity": "sha512-JIzsAvJeA/5iY6Y/OxZbv1lUcc8dNSE77lb2gnBH+/PJ3lFR1Ccvgwl5JWnHAkNHcRsT0TbpVOsiMKZ1F/yyJg=="
"version": "20.4.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.5.tgz",
"integrity": "sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg=="
},
"node_modules/@types/qs": {
"version": "6.9.7",
@@ -193,6 +194,22 @@
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
"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": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.0.tgz",
@@ -313,9 +330,9 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.2.2.tgz",
"integrity": "sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
@@ -626,21 +643,21 @@
}
},
"node_modules/engine.io-client": {
"version": "6.2.3",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.3.tgz",
"integrity": "sha512-aXPtgF1JS3RuuKcpSrBtimSjYvrbhKW9froICH4s0F3XQWLxsKNxqzG39nnvQZQnva4CMvUK63T7shevxRyYHw==",
"version": "6.5.1",
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.1.tgz",
"integrity": "sha512-hE5wKXH8Ru4L19MbM1GgYV/2Qo54JSMh1rlJbfpa40bEWkCKNo3ol2eOtGmowcr+ysgbI7+SGL+by42Q3pt/Ng==",
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.1",
"engine.io-parser": "~5.0.3",
"ws": "~8.2.3",
"engine.io-parser": "~5.1.0",
"ws": "~8.11.0",
"xmlhttprequest-ssl": "~2.0.0"
}
},
"node_modules/engine.io-parser": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.4.tgz",
"integrity": "sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg==",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.1.0.tgz",
"integrity": "sha512-enySgNiK5tyZFynt3z7iqBR+Bto9EVVVvDFuTT0ioHCGbzirZVGDGiQjZzEp8hWl6hd5FSVytJGuScX1C1C35w==",
"engines": {
"node": ">=10.0.0"
}
@@ -1564,14 +1581,14 @@
}
},
"node_modules/socket.io-client": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.4.tgz",
"integrity": "sha512-ZpKteoA06RzkD32IbqILZ+Cnst4xewU7ZYK12aS1mzHftFFjpoMz69IuhP/nL25pJfao/amoPI527KnuhFm01g==",
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.1.tgz",
"integrity": "sha512-Qk3Xj8ekbnzKu3faejo4wk2MzXA029XppiXtTF/PkbTg+fcwaTw1PlDrTrrrU4mKoYC4dvlApOnSeyLCKwek2w==",
"dependencies": {
"@socket.io/component-emitter": "~3.1.0",
"debug": "~4.3.2",
"engine.io-client": "~6.2.3",
"socket.io-parser": "~4.2.1"
"engine.io-client": "~6.5.1",
"socket.io-parser": "~4.2.4"
},
"engines": {
"node": ">=10.0.0"
@@ -2081,9 +2098,9 @@
"dev": true
},
"node_modules/ws": {
"version": "8.2.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
"integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
"version": "8.11.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
"engines": {
"node": ">=10.0.0"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@cubetiq/hlt",
"version": "0.1.8",
"version": "0.1.10",
"description": "A lightweight http tunnel client using nodejs and socket.io client",
"main": "dist/cli.js",
"bin": {

View File

@@ -305,7 +305,7 @@ class HttpTunnelClient implements Client {
return;
}
} else {
if (address) {
if (typeof address !== "number" && address && address.includes(":")) {
const [host, portStr] = address.split(":");
if (host) {
options.host = host;
@@ -321,6 +321,7 @@ class HttpTunnelClient implements Client {
}
} else {
options.port = port;
console.log(`default port: ${port} will be forwared`);
}
}

View File

@@ -4,6 +4,7 @@ import * as os from "os";
import * as path from "path";
import { initConfigFileClient, startClient } from "./api";
import { PROFILE_DEFAULT, PROFILE_PATH, SERVER_DEFAULT_URL, TOKEN_FREE } from "./constant";
import { listProfile } from "./manage";
import { createProxyServer } from "./proxy";
import { createProxyServer as createProxyTCPServer } from "./proxy_tcp";
import { getTokenFree } from './sdk';
@@ -22,20 +23,20 @@ program
program
.command("init")
.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(
"-t --token <string>",
"-t, --token <string>",
"setting token (default generate FREE access token)",
""
)
.option("-a --access <string>", "setting token access type", TOKEN_FREE)
.option("-c --client <string>", "setting client (auto generate uuid)")
.option("-a, --access <string>", "setting token access type", TOKEN_FREE)
.option("-c, --client <string>", "setting client (auto generate uuid)")
.option(
"-k --key <string>",
"-k, --key <string>",
"setting client api key for authentication access"
)
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
.option("-f --force", "force to generate new client and token", false)
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
.option("-f, --force", "force to generate new client and token", false)
.action(async (options) => {
initConfigFileClient(options);
});
@@ -91,7 +92,7 @@ program
])
)
.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) => {
if (!type) {
console.error("type config is required!");
@@ -179,7 +180,7 @@ program
"key",
])
)
.option("-p --profile <string>", "setting profile name", PROFILE_DEFAULT)
.option("-p, --profile <string>", "setting profile name", PROFILE_DEFAULT)
.action(async (type, options) => {
if (!type) {
console.error("type config is required!");
@@ -271,7 +272,7 @@ program
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) => {
const isTcp = target.indexOf("tcp") === 0;
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();

28
src/manage.ts Normal file
View 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}`);
}