Compare commits
No commits in common. "d5f4abeeb0740fc7f1b19bcad065905d29afde4a" and "56c278d84e619dd20aa099b9867e610d8964de6d" have entirely different histories.
d5f4abeeb0
...
56c278d84e
@ -1,8 +1,4 @@
|
|||||||
### 27/07/2023 (1.0.10)
|
### 14/07/2023 (1.0.8)
|
||||||
|
|
||||||
- Add list profiles
|
|
||||||
|
|
||||||
### 14/07/2023 (1.0.9)
|
|
||||||
|
|
||||||
- Fixed the start with port unable to start
|
- Fixed the start with port unable to start
|
||||||
|
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -178,9 +178,9 @@
|
|||||||
"devOptional": true
|
"devOptional": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.4.5",
|
"version": "20.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.5.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz",
|
||||||
"integrity": "sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg=="
|
"integrity": "sha512-JIzsAvJeA/5iY6Y/OxZbv1lUcc8dNSE77lb2gnBH+/PJ3lFR1Ccvgwl5JWnHAkNHcRsT0TbpVOsiMKZ1F/yyJg=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/qs": {
|
"node_modules/@types/qs": {
|
||||||
"version": "6.9.7",
|
"version": "6.9.7",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cubetiq/hlt",
|
"name": "@cubetiq/hlt",
|
||||||
"version": "0.1.10",
|
"version": "0.1.9",
|
||||||
"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": {
|
||||||
|
34
src/cli.ts
34
src/cli.ts
@ -4,7 +4,6 @@ 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';
|
||||||
@ -23,20 +22,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);
|
||||||
});
|
});
|
||||||
@ -92,7 +91,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!");
|
||||||
@ -180,7 +179,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!");
|
||||||
@ -272,7 +271,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) {
|
||||||
@ -323,17 +322,4 @@ 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();
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
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}`);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user