bdy 1.7.52-dev → 1.7.54-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/command/agent/install.js +2 -3
- package/src/command/agent/restart.js +2 -3
- package/src/command/agent/run.js +2 -2
- package/src/command/agent/start.js +2 -3
- package/src/command/agent/status.js +2 -3
- package/src/command/agent/stop.js +2 -3
- package/src/command/agent/tunnel/list.js +2 -3
- package/src/command/agent/tunnel/start.js +2 -3
- package/src/command/agent/tunnel/status.js +2 -3
- package/src/command/agent/tunnel/stop.js +2 -3
- package/src/command/agent/tunnel.js +2 -3
- package/src/command/agent/uninstall.js +2 -3
- package/src/command/agent/update.js +2 -3
- package/src/command/agent/version.js +2 -3
- package/src/command/agent.js +2 -3
- package/src/command/config/add.js +2 -3
- package/src/command/config/get/region.js +2 -3
- package/src/command/config/get/timeout.js +2 -3
- package/src/command/config/get/token.js +2 -3
- package/src/command/config/get/tunnel.js +2 -3
- package/src/command/config/get/tunnels.js +2 -3
- package/src/command/config/get/whitelist.js +2 -3
- package/src/command/config/get.js +2 -3
- package/src/command/config/remove/tunnel.js +2 -3
- package/src/command/config/remove.js +2 -3
- package/src/command/config/set/region.js +2 -3
- package/src/command/config/set/timeout.js +2 -3
- package/src/command/config/set/token.js +2 -3
- package/src/command/config/set/whitelist.js +2 -3
- package/src/command/config/set.js +2 -3
- package/src/command/config.js +2 -3
- package/src/command/start.js +2 -3
- package/src/command/version.js +2 -2
- package/src/index.js +8 -4
- package/src/utils.js +67 -4
package/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../output.js');
|
|
3
2
|
const Input = require('../../input.js');
|
|
4
3
|
const {
|
|
@@ -25,6 +24,7 @@ const {
|
|
|
25
24
|
TXT_AGENT_ENABLED,
|
|
26
25
|
OPTION_AGENT_DEBUG
|
|
27
26
|
} = require('../../texts');
|
|
27
|
+
const { newCommand } = require('../../utils');
|
|
28
28
|
|
|
29
29
|
const removeAllAndExit = async (txt, id, host, token) => {
|
|
30
30
|
try {
|
|
@@ -45,8 +45,7 @@ const removeAllAndExit = async (txt, id, host, token) => {
|
|
|
45
45
|
Output.exitError(txt);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const commandAgentInstall =
|
|
49
|
-
commandAgentInstall.description(DESC_COMMAND_AGENT_INSTALL);
|
|
48
|
+
const commandAgentInstall = newCommand('install', DESC_COMMAND_AGENT_INSTALL);
|
|
50
49
|
commandAgentInstall.option('-s, --start', OPTION_AGENT_START);
|
|
51
50
|
commandAgentInstall.option('-i, --id <id>', OPTION_AGENT_ID);
|
|
52
51
|
commandAgentInstall.option('-t, --token <token>', OPTION_AGENT_TOKEN);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_RESTART,
|
|
@@ -7,9 +6,9 @@ const {
|
|
|
7
6
|
const ApiAgent = require('../../api/agent.js');
|
|
8
7
|
const AgentManager = require('../../agent/manager');
|
|
9
8
|
const { ERR_AGENT_NOT_ENABLED } = require('../../texts');
|
|
9
|
+
const { newCommand } = require('../../utils');
|
|
10
10
|
|
|
11
|
-
const commandAgentRestart =
|
|
12
|
-
commandAgentRestart.description(DESC_COMMAND_AGENT_RESTART);
|
|
11
|
+
const commandAgentRestart = newCommand('restart', DESC_COMMAND_AGENT_RESTART);
|
|
13
12
|
commandAgentRestart.action(async () => {
|
|
14
13
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
15
14
|
if (!isEnabled) {
|
package/src/command/agent/run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const AgentManager = require('../../agent/manager');
|
|
3
2
|
const logger = require('../../logger');
|
|
3
|
+
const { newCommand } = require('../../utils');
|
|
4
4
|
|
|
5
|
-
const commandAgentRun =
|
|
5
|
+
const commandAgentRun = newCommand('run');
|
|
6
6
|
commandAgentRun.option('--id <id>');
|
|
7
7
|
commandAgentRun.option('--host <host>');
|
|
8
8
|
commandAgentRun.option('--token <token>');
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_START,
|
|
@@ -7,9 +6,9 @@ const {
|
|
|
7
6
|
const ApiAgent = require('../../api/agent.js');
|
|
8
7
|
const AgentManager = require('../../agent/manager');
|
|
9
8
|
const { ERR_AGENT_NOT_ENABLED } = require('../../texts');
|
|
9
|
+
const { newCommand } = require('../../utils');
|
|
10
10
|
|
|
11
|
-
const commandAgentStart =
|
|
12
|
-
commandAgentStart.description(DESC_COMMAND_AGENT_START);
|
|
11
|
+
const commandAgentStart = newCommand('start', DESC_COMMAND_AGENT_START);
|
|
13
12
|
commandAgentStart.action(async () => {
|
|
14
13
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
15
14
|
if (!isEnabled) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_STATUS,
|
|
@@ -16,9 +15,9 @@ const {
|
|
|
16
15
|
} = require('../../utils.js');
|
|
17
16
|
const AgentManager = require('../../agent/manager');
|
|
18
17
|
const { ERR_AGENT_NOT_RUNNING } = require('../../texts');
|
|
18
|
+
const { newCommand } = require('../../utils');
|
|
19
19
|
|
|
20
|
-
const commandAgentStatus =
|
|
21
|
-
commandAgentStatus.description(DESC_COMMAND_AGENT_STATUS);
|
|
20
|
+
const commandAgentStatus = newCommand('status', DESC_COMMAND_AGENT_STATUS);
|
|
22
21
|
commandAgentStatus.action(async () => {
|
|
23
22
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
24
23
|
if (!isEnabled) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_STOP,
|
|
@@ -7,9 +6,9 @@ const {
|
|
|
7
6
|
const ApiAgent = require('../../api/agent.js');
|
|
8
7
|
const AgentManager = require('../../agent/manager');
|
|
9
8
|
const { ERR_AGENT_NOT_ENABLED } = require('../../texts');
|
|
9
|
+
const { newCommand } = require('../../utils');
|
|
10
10
|
|
|
11
|
-
const commandAgentStop =
|
|
12
|
-
commandAgentStop.description(DESC_COMMAND_AGENT_STOP);
|
|
11
|
+
const commandAgentStop = newCommand('stop', DESC_COMMAND_AGENT_STOP);
|
|
13
12
|
commandAgentStop.action(async () => {
|
|
14
13
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
15
14
|
if (!isEnabled) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_TUNNEL_LIST,
|
|
@@ -6,9 +5,9 @@ const {
|
|
|
6
5
|
} = require('../../../texts.js');
|
|
7
6
|
const ApiAgent = require('../../../api/agent');
|
|
8
7
|
const AgentManager = require('../../../agent/manager');
|
|
8
|
+
const { newCommand } = require('../../../utils');
|
|
9
9
|
|
|
10
|
-
const commandAgentTunnelList =
|
|
11
|
-
commandAgentTunnelList.description(DESC_COMMAND_AGENT_TUNNEL_LIST);
|
|
10
|
+
const commandAgentTunnelList = newCommand('list', DESC_COMMAND_AGENT_TUNNEL_LIST);
|
|
12
11
|
commandAgentTunnelList.action(async () => {
|
|
13
12
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
14
13
|
if (!isEnabled) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const {
|
|
@@ -11,9 +10,9 @@ const {
|
|
|
11
10
|
} = require('../../../texts.js');
|
|
12
11
|
const ApiAgent = require('../../../api/agent.js');
|
|
13
12
|
const AgentManager = require('../../../agent/manager');
|
|
13
|
+
const { newCommand } = require('../../../utils');
|
|
14
14
|
|
|
15
|
-
const commandAgentTunnelStart =
|
|
16
|
-
commandAgentTunnelStart.description(DESC_COMMAND_AGENT_TUNNEL_START);
|
|
15
|
+
const commandAgentTunnelStart = newCommand('start', DESC_COMMAND_AGENT_TUNNEL_START);
|
|
17
16
|
commandAgentTunnelStart.argument('<name>', OPTION_NAME);
|
|
18
17
|
commandAgentTunnelStart.action(async (name) => {
|
|
19
18
|
if (!Cfg.hasTunnel(name)) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const {
|
|
3
2
|
DESC_COMMAND_AGENT_TUNNEL_STATUS,
|
|
4
3
|
ERR_AGENT_NOT_ENABLED,
|
|
@@ -8,9 +7,9 @@ const Output = require('../../../output.js');
|
|
|
8
7
|
const ApiAgent = require('../../../api/agent.js');
|
|
9
8
|
const AgentSocketTunnel = require('../../../agent/socket/tunnel.js');
|
|
10
9
|
const AgentManager = require('../../../agent/manager');
|
|
10
|
+
const { newCommand } = require('../../../utils');
|
|
11
11
|
|
|
12
|
-
const commandAgentTunnelStatus =
|
|
13
|
-
commandAgentTunnelStatus.description(DESC_COMMAND_AGENT_TUNNEL_STATUS);
|
|
12
|
+
const commandAgentTunnelStatus = newCommand('status', DESC_COMMAND_AGENT_TUNNEL_STATUS);
|
|
14
13
|
commandAgentTunnelStatus.argument('<id>', OPTION_ID);
|
|
15
14
|
commandAgentTunnelStatus.action(async (id) => {
|
|
16
15
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_TUNNEL_STOP,
|
|
@@ -8,9 +7,9 @@ const {
|
|
|
8
7
|
} = require('../../../texts.js');
|
|
9
8
|
const ApiAgent = require('../../../api/agent.js');
|
|
10
9
|
const AgentManager = require('../../../agent/manager');
|
|
10
|
+
const { newCommand } = require('../../../utils');
|
|
11
11
|
|
|
12
|
-
const commandAgentTunnelStop =
|
|
13
|
-
commandAgentTunnelStop.description(DESC_COMMAND_AGENT_TUNNEL_STOP);
|
|
12
|
+
const commandAgentTunnelStop = newCommand('stop', DESC_COMMAND_AGENT_TUNNEL_STOP);
|
|
14
13
|
commandAgentTunnelStop.argument('<id>', OPTION_ID);
|
|
15
14
|
commandAgentTunnelStop.action(async (id) => {
|
|
16
15
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandAgentTunnelTcp = require('./tunnel/tcp.js');
|
|
3
2
|
const commandAgentTunnelList = require('./tunnel/list.js');
|
|
4
3
|
const commandAgentTunnelStop = require('./tunnel/stop.js');
|
|
@@ -7,9 +6,9 @@ const commandAgentTunnelHttp = require('./tunnel/http.js');
|
|
|
7
6
|
const commandAgentTunnelStart = require('./tunnel/start.js');
|
|
8
7
|
const { DESC_COMMAND_AGENT_TUNNEL } = require('../../texts.js');
|
|
9
8
|
const commandAgentTunnelStatus = require('./tunnel/status.js');
|
|
9
|
+
const { newCommand } = require('../../utils');
|
|
10
10
|
|
|
11
|
-
const commandAgentTunnel =
|
|
12
|
-
commandAgentTunnel.description(DESC_COMMAND_AGENT_TUNNEL);
|
|
11
|
+
const commandAgentTunnel = newCommand('tunnel', DESC_COMMAND_AGENT_TUNNEL);
|
|
13
12
|
commandAgentTunnel.addCommand(commandAgentTunnelTcp);
|
|
14
13
|
commandAgentTunnel.addCommand(commandAgentTunnelTls);
|
|
15
14
|
commandAgentTunnel.addCommand(commandAgentTunnelHttp);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_UNINSTALL,
|
|
@@ -7,9 +6,9 @@ const {
|
|
|
7
6
|
const AgentManager = require('../../agent/manager.js');
|
|
8
7
|
const ApiBuddy = require('../../api/buddy.js');
|
|
9
8
|
const { ERR_AGENT_ADMIN_RIGHTS } = require('../../texts');
|
|
9
|
+
const { newCommand } = require('../../utils');
|
|
10
10
|
|
|
11
|
-
const commandAgentUninstall =
|
|
12
|
-
commandAgentUninstall.description(DESC_COMMAND_AGENT_UNINSTALL);
|
|
11
|
+
const commandAgentUninstall = newCommand('disable', DESC_COMMAND_AGENT_UNINSTALL);
|
|
13
12
|
commandAgentUninstall.action(async () => {
|
|
14
13
|
const hasAdminRights = await AgentManager.system.hasAdminRights();
|
|
15
14
|
if (!hasAdminRights) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const {
|
|
3
2
|
DESC_COMMAND_AGENT_UPDATE,
|
|
4
3
|
ERR_AGENT_NOT_ENABLED,
|
|
@@ -12,9 +11,9 @@ const { ERR_AGENT_ADMIN_RIGHTS,
|
|
|
12
11
|
TXT_UPDATING_AGENT
|
|
13
12
|
} = require('../../texts');
|
|
14
13
|
const ApiAgent = require('../../api/agent');
|
|
14
|
+
const { newCommand } = require('../../utils');
|
|
15
15
|
|
|
16
|
-
const commandAgentUpdate =
|
|
17
|
-
commandAgentUpdate.description(DESC_COMMAND_AGENT_UPDATE);
|
|
16
|
+
const commandAgentUpdate = newCommand('update', DESC_COMMAND_AGENT_UPDATE);
|
|
18
17
|
commandAgentUpdate.hideVersionUpdate = true;
|
|
19
18
|
commandAgentUpdate.action(async () => {
|
|
20
19
|
const hasAdminRights = await AgentManager.system.hasAdminRights();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../output.js');
|
|
3
2
|
const {
|
|
4
3
|
DESC_COMMAND_AGENT_VERSION,
|
|
@@ -6,9 +5,9 @@ const {
|
|
|
6
5
|
ERR_SWW
|
|
7
6
|
} = require('../../texts.js');
|
|
8
7
|
const AgentManager = require('../../agent/manager');
|
|
8
|
+
const { newCommand } = require('../../utils');
|
|
9
9
|
|
|
10
|
-
const commandAgentVersion =
|
|
11
|
-
commandAgentVersion.description(DESC_COMMAND_AGENT_VERSION);
|
|
10
|
+
const commandAgentVersion = newCommand('version', DESC_COMMAND_AGENT_VERSION);
|
|
12
11
|
commandAgentVersion.action(async () => {
|
|
13
12
|
const isEnabled = await AgentManager.system.isEnabled();
|
|
14
13
|
if (!isEnabled) {
|
package/src/command/agent.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandAgentStart = require('./agent/start.js');
|
|
3
2
|
const commandAgentStatus = require('./agent/status.js');
|
|
4
3
|
const commandAgentRestart = require('./agent/restart.js');
|
|
@@ -10,9 +9,9 @@ const commandAgentUninstall = require('./agent/uninstall.js');
|
|
|
10
9
|
const commandAgentVersion = require('./agent/version.js');
|
|
11
10
|
const { DESC_COMMAND_AGENT } = require('../texts.js');
|
|
12
11
|
const commandAgentRun = require('./agent/run');
|
|
12
|
+
const { newCommand } = require('../utils');
|
|
13
13
|
|
|
14
|
-
const commandAgent =
|
|
15
|
-
commandAgent.description(DESC_COMMAND_AGENT);
|
|
14
|
+
const commandAgent = newCommand('agent', DESC_COMMAND_AGENT);
|
|
16
15
|
commandAgent.addCommand(commandAgentInstall);
|
|
17
16
|
commandAgent.addCommand(commandAgentStart);
|
|
18
17
|
commandAgent.addCommand(commandAgentStop);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandConfigAddTcp = require('./add/tcp.js');
|
|
3
2
|
const commandConfigAddHttp = require('./add/http.js');
|
|
4
3
|
const commandConfigAddTls = require('./add/tls.js');
|
|
5
4
|
const { DESC_COMMAND_CONFIG_ADD } = require('../../texts.js');
|
|
5
|
+
const { newCommand } = require('../../utils');
|
|
6
6
|
|
|
7
|
-
const commandConfigAdd =
|
|
8
|
-
commandConfigAdd.description(DESC_COMMAND_CONFIG_ADD);
|
|
7
|
+
const commandConfigAdd = newCommand('add', DESC_COMMAND_CONFIG_ADD);
|
|
9
8
|
commandConfigAdd.addCommand(commandConfigAddTcp);
|
|
10
9
|
commandConfigAdd.addCommand(commandConfigAddTls);
|
|
11
10
|
commandConfigAdd.addCommand(commandConfigAddHttp);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const { DESC_COMMAND_CONFIG_GET_REGION } = require('../../../texts.js');
|
|
5
4
|
const Format = require('../../../format');
|
|
5
|
+
const { newCommand } = require('../../../utils');
|
|
6
6
|
|
|
7
|
-
const commandConfigGetRegion =
|
|
8
|
-
commandConfigGetRegion.description(DESC_COMMAND_CONFIG_GET_REGION);
|
|
7
|
+
const commandConfigGetRegion = newCommand('region', DESC_COMMAND_CONFIG_GET_REGION);
|
|
9
8
|
commandConfigGetRegion.action(() => {
|
|
10
9
|
Output.exitNormal(Format.region(Cfg.getRegion()));
|
|
11
10
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../../output.js');
|
|
3
2
|
const Cfg = require('../../../cfg.js');
|
|
4
3
|
const { DESC_COMMAND_CONFIG_GET_TIMEOUT } = require('../../../texts.js');
|
|
5
4
|
const Format = require('../../../format');
|
|
5
|
+
const { newCommand } = require('../../../utils');
|
|
6
6
|
|
|
7
|
-
const commandConfigGetTimeout =
|
|
8
|
-
commandConfigGetTimeout.description(DESC_COMMAND_CONFIG_GET_TIMEOUT);
|
|
7
|
+
const commandConfigGetTimeout = newCommand('timeout', DESC_COMMAND_CONFIG_GET_TIMEOUT);
|
|
9
8
|
commandConfigGetTimeout.action(() => {
|
|
10
9
|
Output.exitNormal(Format.timeout(Cfg.getTimeout()));
|
|
11
10
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const { DESC_COMMAND_CONFIG_GET_TOKEN } = require('../../../texts.js');
|
|
5
4
|
const Format = require('../../../format');
|
|
5
|
+
const { newCommand } = require('../../../utils');
|
|
6
6
|
|
|
7
|
-
const commandConfigGetToken =
|
|
8
|
-
commandConfigGetToken.description(DESC_COMMAND_CONFIG_GET_TOKEN);
|
|
7
|
+
const commandConfigGetToken = newCommand('token', DESC_COMMAND_CONFIG_GET_TOKEN);
|
|
9
8
|
commandConfigGetToken.action(() => {
|
|
10
9
|
Output.exitNormal(Format.token(Cfg.getToken()));
|
|
11
10
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const {
|
|
@@ -6,9 +5,9 @@ const {
|
|
|
6
5
|
ERR_TUNNEL_NOT_FOUND,
|
|
7
6
|
OPTION_NAME
|
|
8
7
|
} = require('../../../texts.js');
|
|
8
|
+
const { newCommand } = require('../../../utils');
|
|
9
9
|
|
|
10
|
-
const commandConfigGetTunnel =
|
|
11
|
-
commandConfigGetTunnel.description(DESC_COMMAND_CONFIG_GET_TUNNEL);
|
|
10
|
+
const commandConfigGetTunnel = newCommand('tunnel', DESC_COMMAND_CONFIG_GET_TUNNEL);
|
|
12
11
|
commandConfigGetTunnel.argument('<name>', OPTION_NAME);
|
|
13
12
|
commandConfigGetTunnel.action((name) => {
|
|
14
13
|
if (!Cfg.hasTunnel(name)) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const { DESC_COMMAND_CONFIG_GET_TUNNELS } = require('../../../texts.js');
|
|
4
|
+
const { newCommand } = require('../../../utils');
|
|
5
5
|
|
|
6
|
-
const commandConfigGetTunnels =
|
|
7
|
-
commandConfigGetTunnels.description(DESC_COMMAND_CONFIG_GET_TUNNELS);
|
|
6
|
+
const commandConfigGetTunnels = newCommand('tunnels', DESC_COMMAND_CONFIG_GET_TUNNELS);
|
|
8
7
|
commandConfigGetTunnels.action(() => {
|
|
9
8
|
Output.configTunnels(Cfg.getTunnels());
|
|
10
9
|
Output.exitNormal();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../../output.js');
|
|
3
2
|
const Cfg = require('../../../cfg.js');
|
|
4
3
|
const { DESC_COMMAND_CONFIG_GET_WHITELIST } = require('../../../texts.js');
|
|
5
4
|
const Format = require('../../../format');
|
|
5
|
+
const { newCommand } = require('../../../utils');
|
|
6
6
|
|
|
7
|
-
const commandConfigGetWhitelist =
|
|
8
|
-
commandConfigGetWhitelist.description(DESC_COMMAND_CONFIG_GET_WHITELIST);
|
|
7
|
+
const commandConfigGetWhitelist = newCommand('whitelist', DESC_COMMAND_CONFIG_GET_WHITELIST);
|
|
9
8
|
commandConfigGetWhitelist.action(() => {
|
|
10
9
|
Output.exitNormal(Format.whitelist(Cfg.getWhitelist()));
|
|
11
10
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandConfigGetRegion = require('./get/region.js');
|
|
3
2
|
const commandConfigGetToken = require('./get/token.js');
|
|
4
3
|
const commandConfigGetTunnel = require('./get/tunnel.js');
|
|
@@ -6,9 +5,9 @@ const commandConfigGetWhitelist = require('./get/whitelist.js');
|
|
|
6
5
|
const commandConfigGetTimeout = require('./get/timeout.js');
|
|
7
6
|
const commandConfigGetTunnels = require('./get/tunnels.js');
|
|
8
7
|
const { DESC_COMMAND_CONFIG_GET } = require('../../texts.js');
|
|
8
|
+
const { newCommand } = require('../../utils');
|
|
9
9
|
|
|
10
|
-
const commandConfigGet =
|
|
11
|
-
commandConfigGet.description(DESC_COMMAND_CONFIG_GET);
|
|
10
|
+
const commandConfigGet = newCommand('get', DESC_COMMAND_CONFIG_GET);
|
|
12
11
|
commandConfigGet.addCommand(commandConfigGetRegion);
|
|
13
12
|
commandConfigGet.addCommand(commandConfigGetToken);
|
|
14
13
|
commandConfigGet.addCommand(commandConfigGetWhitelist);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const {
|
|
@@ -7,9 +6,9 @@ const {
|
|
|
7
6
|
OPTION_NAME,
|
|
8
7
|
TXT_TUNNEL_REMOVED
|
|
9
8
|
} = require('../../../texts.js');
|
|
9
|
+
const { newCommand } = require('../../../utils');
|
|
10
10
|
|
|
11
|
-
const commandConfigRemoveTunnel =
|
|
12
|
-
commandConfigRemoveTunnel.description(DESC_COMMAND_CONFIG_REMOVE_TUNNEL);
|
|
11
|
+
const commandConfigRemoveTunnel = newCommand('tunnel', DESC_COMMAND_CONFIG_REMOVE_TUNNEL);
|
|
13
12
|
commandConfigRemoveTunnel.argument('<name>', OPTION_NAME);
|
|
14
13
|
commandConfigRemoveTunnel.action((name) => {
|
|
15
14
|
if (!Cfg.hasTunnel(name)) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandConfigRemoveTunnel = require('./remove/tunnel.js');
|
|
3
2
|
const { DESC_COMMAND_CONFIG_REMOVE } = require('../../texts.js');
|
|
3
|
+
const { newCommand } = require('../../utils');
|
|
4
4
|
|
|
5
|
-
const commandConfigRemove =
|
|
6
|
-
commandConfigRemove.description(DESC_COMMAND_CONFIG_REMOVE);
|
|
5
|
+
const commandConfigRemove = newCommand('rm', DESC_COMMAND_CONFIG_REMOVE);
|
|
7
6
|
commandConfigRemove.addCommand(commandConfigRemoveTunnel);
|
|
8
7
|
|
|
9
8
|
module.exports = commandConfigRemove;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const Input = require('../../../input.js');
|
|
@@ -7,9 +6,9 @@ const {
|
|
|
7
6
|
OPTION_DEFAULT_REGION,
|
|
8
7
|
TXT_REGION_SAVED
|
|
9
8
|
} = require('../../../texts.js');
|
|
9
|
+
const { newCommand } = require('../../../utils');
|
|
10
10
|
|
|
11
|
-
const commandConfigSetRegion =
|
|
12
|
-
commandConfigSetRegion.description(DESC_COMMAND_CONFIG_SET_REGION);
|
|
11
|
+
const commandConfigSetRegion = newCommand('region', DESC_COMMAND_CONFIG_SET_REGION);
|
|
13
12
|
commandConfigSetRegion.argument('<region>', OPTION_DEFAULT_REGION);
|
|
14
13
|
commandConfigSetRegion.action((region) => {
|
|
15
14
|
Cfg.setRegion(Input.region(region));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Output = require('../../../output.js');
|
|
3
2
|
const Cfg = require('../../../cfg.js');
|
|
4
3
|
const Input = require('../../../input.js');
|
|
@@ -10,9 +9,9 @@ const {
|
|
|
10
9
|
OPTION_TIMEOUT,
|
|
11
10
|
TXT_TIMEOUT_SAVED
|
|
12
11
|
} = require('../../../texts.js');
|
|
12
|
+
const { newCommand } = require('../../../utils');
|
|
13
13
|
|
|
14
|
-
const commandConfigSetTimeout =
|
|
15
|
-
commandConfigSetTimeout.description(DESC_COMMAND_CONFIG_SET_TIMEOUT);
|
|
14
|
+
const commandConfigSetTimeout = newCommand('timeout', DESC_COMMAND_CONFIG_SET_TIMEOUT);
|
|
16
15
|
commandConfigSetTimeout.argument('[timeout]', OPTION_TIMEOUT, DEFAULT_TIMEOUT);
|
|
17
16
|
commandConfigSetTimeout.action((timeout) => {
|
|
18
17
|
Cfg.setTimeout(Input.timeout(timeout));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const {
|
|
@@ -6,9 +5,9 @@ const {
|
|
|
6
5
|
OPTION_TOKEN,
|
|
7
6
|
TXT_TOKEN_SAVED
|
|
8
7
|
} = require('../../../texts.js');
|
|
8
|
+
const { newCommand } = require('../../../utils');
|
|
9
9
|
|
|
10
|
-
const commandConfigSetToken =
|
|
11
|
-
commandConfigSetToken.description(DESC_COMMAND_CONFIG_SET_TOKEN);
|
|
10
|
+
const commandConfigSetToken = newCommand('token', DESC_COMMAND_CONFIG_SET_TOKEN);
|
|
12
11
|
commandConfigSetToken.argument('[token]', OPTION_TOKEN, '');
|
|
13
12
|
commandConfigSetToken.action((token) => {
|
|
14
13
|
Cfg.setToken(token);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../../../cfg.js');
|
|
3
2
|
const Output = require('../../../output.js');
|
|
4
3
|
const Input = require('../../../input.js');
|
|
@@ -7,9 +6,9 @@ const {
|
|
|
7
6
|
OPTION_WHITELIST,
|
|
8
7
|
TXT_WHITELIST_SAVED
|
|
9
8
|
} = require('../../../texts.js');
|
|
9
|
+
const { newCommand } = require('../../../utils');
|
|
10
10
|
|
|
11
|
-
const commandConfigSetWhitelist =
|
|
12
|
-
commandConfigSetWhitelist.description(DESC_COMMAND_CONFIG_SET_WHITELIST);
|
|
11
|
+
const commandConfigSetWhitelist = newCommand('whitelist', DESC_COMMAND_CONFIG_SET_WHITELIST);
|
|
13
12
|
commandConfigSetWhitelist.argument('[cidrs...]', OPTION_WHITELIST, []);
|
|
14
13
|
commandConfigSetWhitelist.action((whitelist) => {
|
|
15
14
|
Cfg.setWhitelist(Input.whitelist(whitelist));
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandConfigSetToken = require('./set/token.js');
|
|
3
2
|
const commandConfigSetRegion = require('./set/region.js');
|
|
4
3
|
const commandConfigSetWhitelist = require('./set/whitelist.js');
|
|
5
4
|
const commandConfigSetTimeout = require('./set/timeout.js');
|
|
6
5
|
const { DESC_COMMAND_CONFIG_SET } = require('../../texts.js');
|
|
6
|
+
const { newCommand } = require('../../utils');
|
|
7
7
|
|
|
8
|
-
const commandConfigSet =
|
|
9
|
-
commandConfigSet.description(DESC_COMMAND_CONFIG_SET);
|
|
8
|
+
const commandConfigSet = newCommand('set', DESC_COMMAND_CONFIG_SET);
|
|
10
9
|
commandConfigSet.addCommand(commandConfigSetToken);
|
|
11
10
|
commandConfigSet.addCommand(commandConfigSetRegion);
|
|
12
11
|
commandConfigSet.addCommand(commandConfigSetWhitelist);
|
package/src/command/config.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandConfigSet = require('./config/set.js');
|
|
3
2
|
const commandConfigGet = require('./config/get.js');
|
|
4
3
|
const commandConfigAdd = require('./config/add.js');
|
|
5
4
|
const commandConfigRemove = require('./config/remove.js');
|
|
6
5
|
const { DESC_COMMAND_CONFIG } = require('../texts.js');
|
|
6
|
+
const { newCommand } = require('../utils');
|
|
7
7
|
|
|
8
|
-
const commandConfig =
|
|
9
|
-
commandConfig.description(DESC_COMMAND_CONFIG);
|
|
8
|
+
const commandConfig = newCommand('config', DESC_COMMAND_CONFIG);
|
|
10
9
|
commandConfig.addCommand(commandConfigSet);
|
|
11
10
|
commandConfig.addCommand(commandConfigAdd);
|
|
12
11
|
commandConfig.addCommand(commandConfigGet);
|
package/src/command/start.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const Cfg = require('../cfg.js');
|
|
3
2
|
const Output = require('../output.js');
|
|
4
3
|
const {
|
|
@@ -8,9 +7,9 @@ const {
|
|
|
8
7
|
TXT_OPENING_TUNNEL
|
|
9
8
|
} = require('../texts.js');
|
|
10
9
|
const ApiBuddy = require('../api/buddy.js');
|
|
10
|
+
const { newCommand } = require('../utils');
|
|
11
11
|
|
|
12
|
-
const commandStart =
|
|
13
|
-
commandStart.description(DESC_COMMAND_START);
|
|
12
|
+
const commandStart = newCommand('start', DESC_COMMAND_START);
|
|
14
13
|
commandStart.argument('<name>', OPTION_NAME);
|
|
15
14
|
commandStart.action(async (name) => {
|
|
16
15
|
if (!Cfg.hasTunnel(name)) {
|
package/src/command/version.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const { getVersion } = require('../utils.js');
|
|
3
2
|
const Output = require('../output.js');
|
|
3
|
+
const { newCommand } = require('../utils');
|
|
4
4
|
|
|
5
|
-
const commandVersion =
|
|
5
|
+
const commandVersion = newCommand('version');
|
|
6
6
|
commandVersion.action(() => {
|
|
7
7
|
Output.exitNormal(getVersion());
|
|
8
8
|
});
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { Command } = require('commander');
|
|
2
1
|
const commandConfig = require('./command/config.js');
|
|
3
2
|
const Output = require('./output.js');
|
|
4
3
|
const commandTcp = require('./command/tcp.js');
|
|
@@ -10,7 +9,10 @@ const logger = require('./logger.js');
|
|
|
10
9
|
const commandVersion = require('./command/version.js');
|
|
11
10
|
const commandPre = require('./command/pre.js');
|
|
12
11
|
const stream = require('stream');
|
|
13
|
-
const { isDocker
|
|
12
|
+
const { isDocker,
|
|
13
|
+
formatHelp,
|
|
14
|
+
newCommand
|
|
15
|
+
} = require('./utils');
|
|
14
16
|
const { DESC_PROGRAM } = require('./texts');
|
|
15
17
|
|
|
16
18
|
stream.setDefaultHighWaterMark(false, 67108864);
|
|
@@ -20,9 +22,11 @@ process.on('uncaughtException', (err) => {
|
|
|
20
22
|
Output.exitError(err);
|
|
21
23
|
});
|
|
22
24
|
|
|
23
|
-
const program =
|
|
24
|
-
program.description(DESC_PROGRAM);
|
|
25
|
+
const program = newCommand(null, DESC_PROGRAM);
|
|
25
26
|
program.hook('preAction', commandPre);
|
|
27
|
+
program.configureHelp({
|
|
28
|
+
formatHelp: formatHelp
|
|
29
|
+
});
|
|
26
30
|
program.addCommand(commandConfig);
|
|
27
31
|
program.addCommand(commandTcp);
|
|
28
32
|
program.addCommand(commandTls);
|
package/src/utils.js
CHANGED
|
@@ -41,7 +41,7 @@ const {
|
|
|
41
41
|
ERR_SUBDOMAIN_TAKEN,
|
|
42
42
|
ERR_TUNNELS_DISABLED,
|
|
43
43
|
ERR_AGENT_LIMIT_REACHED,
|
|
44
|
-
ERR_TUNNEL_LIMIT_REACHED
|
|
44
|
+
ERR_TUNNEL_LIMIT_REACHED,
|
|
45
45
|
} = require('./texts');
|
|
46
46
|
|
|
47
47
|
const REGION_US = 'US';
|
|
@@ -243,6 +243,67 @@ const getPlatform = () => {
|
|
|
243
243
|
return os.platform();
|
|
244
244
|
};
|
|
245
245
|
|
|
246
|
+
const formatHelp = (cmd, helper) => {
|
|
247
|
+
const termWidth = helper.padWidth(cmd, helper);
|
|
248
|
+
const helpWidth = helper.helpWidth || 80;
|
|
249
|
+
const itemIndentWidth = 2;
|
|
250
|
+
const itemSeparatorWidth = 2; // between term and description
|
|
251
|
+
function formatItem(term, description) {
|
|
252
|
+
if (description) {
|
|
253
|
+
const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
|
|
254
|
+
return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
|
|
255
|
+
}
|
|
256
|
+
return term;
|
|
257
|
+
}
|
|
258
|
+
function formatList(textArray) {
|
|
259
|
+
return textArray.join('\n').replace(/^/gm, ' '.repeat(itemIndentWidth));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Usage
|
|
263
|
+
let output = ['USAGE:', ` ${helper.commandUsage(cmd)}`, ''];
|
|
264
|
+
|
|
265
|
+
// Description
|
|
266
|
+
const commandDescription = helper.commandDescription(cmd);
|
|
267
|
+
if (commandDescription.length > 0) {
|
|
268
|
+
output = output.concat(['DESCRIPTION:', ` ${helper.wrap(commandDescription, helpWidth, itemIndentWidth)}`, '']);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Arguments
|
|
272
|
+
const argumentList = helper.visibleArguments(cmd).map((argument) => {
|
|
273
|
+
return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
|
|
274
|
+
});
|
|
275
|
+
if (argumentList.length > 0) {
|
|
276
|
+
output = output.concat(['ARGUMENTS:', formatList(argumentList), '']);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Options
|
|
280
|
+
const optionList = helper.visibleOptions(cmd).map((option) => {
|
|
281
|
+
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
|
|
282
|
+
});
|
|
283
|
+
if (optionList.length > 0) {
|
|
284
|
+
output = output.concat(['OPTIONS:', formatList(optionList), '']);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Commands
|
|
288
|
+
const commandList = helper.visibleCommands(cmd).map((cmd) => {
|
|
289
|
+
return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
|
|
290
|
+
});
|
|
291
|
+
if (commandList.length > 0) {
|
|
292
|
+
output = output.concat(['COMMANDS:', formatList(commandList), '']);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return output.join('\n');
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const newCommand = (name, desc) => {
|
|
299
|
+
const cmd = new Command(name);
|
|
300
|
+
if (desc) cmd.description(desc);
|
|
301
|
+
cmd.configureHelp({
|
|
302
|
+
formatHelp: formatHelp
|
|
303
|
+
});
|
|
304
|
+
return cmd;
|
|
305
|
+
};
|
|
306
|
+
|
|
246
307
|
const getHomeDirectory = () => {
|
|
247
308
|
if (isDocker()) return '/buddy';
|
|
248
309
|
const r = homedir();
|
|
@@ -344,7 +405,7 @@ const createSshHostKey = () => {
|
|
|
344
405
|
};
|
|
345
406
|
|
|
346
407
|
const getBasicCommandTcp = () => {
|
|
347
|
-
const commandTcp =
|
|
408
|
+
const commandTcp = newCommand('tcp');
|
|
348
409
|
commandTcp.alias('TCP');
|
|
349
410
|
commandTcp.option('-r, --region <region>', OPTION_REGION);
|
|
350
411
|
commandTcp.option('-w, --whitelist <cidrs...>', OPTION_WHITELIST);
|
|
@@ -355,7 +416,7 @@ const getBasicCommandTcp = () => {
|
|
|
355
416
|
};
|
|
356
417
|
|
|
357
418
|
const getBasicCommandHttp = () => {
|
|
358
|
-
const commandHttp =
|
|
419
|
+
const commandHttp = newCommand('http');
|
|
359
420
|
commandHttp.alias('HTTP');
|
|
360
421
|
commandHttp.option('-r, --region <region>', OPTION_REGION);
|
|
361
422
|
commandHttp.option('-w, --whitelist <cidrs...>', OPTION_WHITELIST);
|
|
@@ -377,7 +438,7 @@ const getBasicCommandHttp = () => {
|
|
|
377
438
|
};
|
|
378
439
|
|
|
379
440
|
const getBasicCommandTls = () => {
|
|
380
|
-
const commandTls =
|
|
441
|
+
const commandTls = newCommand('tls');
|
|
381
442
|
commandTls.alias('TLS');
|
|
382
443
|
commandTls.option('-r, --region <region>', OPTION_REGION);
|
|
383
444
|
commandTls.option('-w, --whitelist <cidrs...>', OPTION_WHITELIST);
|
|
@@ -452,6 +513,8 @@ module.exports = {
|
|
|
452
513
|
isLinux,
|
|
453
514
|
isWindows,
|
|
454
515
|
createSshHostKey,
|
|
516
|
+
formatHelp,
|
|
517
|
+
newCommand,
|
|
455
518
|
AGENT_STATUS_INITIALIZING,
|
|
456
519
|
AGENT_STATUS_FETCH_FAILED,
|
|
457
520
|
AGENT_STATUS_DISABLED,
|