bdy 1.7.48-dev → 1.7.52-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.7.48-dev",
4
+ "version": "1.7.52-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "dependencies": {
package/src/cfg.js CHANGED
@@ -2,6 +2,7 @@ const { resolve } = require('path');
2
2
  const {
3
3
  mkdirSync,
4
4
  readFileSync,
5
+ chmodSync,
5
6
  statSync,
6
7
  writeFileSync
7
8
  } = require('fs');
@@ -31,11 +32,16 @@ class Cfg {
31
32
  createDir() {
32
33
  try {
33
34
  mkdirSync(this.dir, {
34
- recursive: true
35
+ recursive: true,
35
36
  });
36
37
  } catch (err) {
37
38
  throw new Error(ERR_CANT_CREATE_DIR_IN_HOME('.bdy'));
38
39
  }
40
+ try {
41
+ chmodSync(this.dir, 0o777);
42
+ } catch {
43
+ // do nothing
44
+ }
39
45
  }
40
46
 
41
47
  createEmptyFile() {
@@ -44,6 +50,11 @@ class Cfg {
44
50
  } catch (err) {
45
51
  throw new Error(ERR_CANT_CREATE_DIR_IN_HOME('.bdy/cfg.json'));
46
52
  }
53
+ try {
54
+ chmodSync(this.file, 0o666);
55
+ } catch {
56
+ // do nothing
57
+ }
47
58
  }
48
59
 
49
60
  ensureDir() {
@@ -67,7 +78,7 @@ class Cfg {
67
78
  if (!this.json.tunnels) this.json.tunnels = {};
68
79
  }
69
80
 
70
- async prepareTunnel(tunnelType, target, options, useDefaults, myIp) {
81
+ async prepareTunnel(tunnelType, target, options, useDefaults) {
71
82
  const type = Input.type(tunnelType);
72
83
  const tunnel = {
73
84
  type,
@@ -76,12 +87,7 @@ class Cfg {
76
87
  if (options.region !== undefined) tunnel.region = Input.region(options.region);
77
88
  else if (useDefaults) tunnel.region = this.getRegion();
78
89
  if (options.whitelist !== undefined) tunnel.whitelist = Input.whitelist(options.whitelist);
79
- else if (useDefaults) {
80
- tunnel.whitelist = this.getWhitelist();
81
- if (!tunnel.whitelist.length) {
82
- tunnel.whitelist.push(myIp);
83
- }
84
- }
90
+ else if (useDefaults) tunnel.whitelist = this.getWhitelist();
85
91
  if (options.timeout !== undefined) tunnel.timeout = Input.timeout(options.timeout);
86
92
  else if (useDefaults) tunnel.timeout = this.getTimeout();
87
93
  if (options.domain !== undefined) tunnel.domain = Input.domain(options.domain);
@@ -116,12 +122,12 @@ class Cfg {
116
122
  return tunnel;
117
123
  }
118
124
 
119
- async addTunnel(name, type, target, options, myIp) {
125
+ async addTunnel(name, type, target, options) {
120
126
  this.ensureTunnels();
121
127
  this.json.tunnels[name] = await this.prepareTunnel(type, target, {
122
128
  name,
123
129
  ...options
124
- }, false, myIp);
130
+ }, false);
125
131
  this.save();
126
132
  }
127
133
 
@@ -222,6 +228,11 @@ class Cfg {
222
228
  } catch (err) {
223
229
  throw new Error(ERR_CANT_CREATE_DIR_IN_HOME('.bdy/cfg.json'));
224
230
  }
231
+ try {
232
+ chmodSync(this.file, 0o666);
233
+ } catch {
234
+ // do nothing
235
+ }
225
236
  }
226
237
  }
227
238
 
@@ -2,7 +2,7 @@ const { Command } = require('commander');
2
2
  const Output = require('../../output.js');
3
3
  const Input = require('../../input.js');
4
4
  const {
5
- DESC_COMMAND_AGENT_ENABLE,
5
+ DESC_COMMAND_AGENT_INSTALL,
6
6
  ERR_SWW_AGENT_ENABLING,
7
7
  OPTION_AGENT_ID,
8
8
  OPTION_AGENT_PORT,
@@ -45,16 +45,16 @@ const removeAllAndExit = async (txt, id, host, token) => {
45
45
  Output.exitError(txt);
46
46
  };
47
47
 
48
- const commandAgentEnable = new Command('enable');
49
- commandAgentEnable.description(DESC_COMMAND_AGENT_ENABLE);
50
- commandAgentEnable.option('-s, --start', OPTION_AGENT_START);
51
- commandAgentEnable.option('-i, --id <id>', OPTION_AGENT_ID);
52
- commandAgentEnable.option('-t, --token <token>', OPTION_AGENT_TOKEN);
53
- commandAgentEnable.option('-p, --port <port>', OPTION_AGENT_PORT, '7456');
54
- commandAgentEnable.option('-u, --user <user>', OPTION_USER);
55
- commandAgentEnable.option('--pass <password>', OPTION_PASS);
56
- commandAgentEnable.option('-d, --debug', OPTION_AGENT_DEBUG);
57
- commandAgentEnable.action(async (options) => {
48
+ const commandAgentInstall = new Command('install');
49
+ commandAgentInstall.description(DESC_COMMAND_AGENT_INSTALL);
50
+ commandAgentInstall.option('-s, --start', OPTION_AGENT_START);
51
+ commandAgentInstall.option('-i, --id <id>', OPTION_AGENT_ID);
52
+ commandAgentInstall.option('-t, --token <token>', OPTION_AGENT_TOKEN);
53
+ commandAgentInstall.option('-p, --port <port>', OPTION_AGENT_PORT, '7456');
54
+ commandAgentInstall.option('-u, --user <user>', OPTION_USER);
55
+ commandAgentInstall.option('--pass <password>', OPTION_PASS);
56
+ commandAgentInstall.option('-d, --debug', OPTION_AGENT_DEBUG);
57
+ commandAgentInstall.action(async (options) => {
58
58
  const hasAdminRights = await AgentManager.system.hasAdminRights();
59
59
  if (!hasAdminRights) {
60
60
  Output.exitError(ERR_AGENT_ADMIN_RIGHTS);
@@ -114,4 +114,4 @@ commandAgentEnable.action(async (options) => {
114
114
  });
115
115
  });
116
116
 
117
- module.exports = commandAgentEnable;
117
+ module.exports = commandAgentInstall;
@@ -9,7 +9,6 @@ const {
9
9
  TXT_TUNNEL_STARTED
10
10
  } = require('../../../texts.js');
11
11
  const ApiAgent = require('../../../api/agent.js');
12
- const ApiBuddy = require('../../../api/buddy');
13
12
  const { getBasicCommandHttp } = require('../../../utils');
14
13
  const AgentManager = require('../../../agent/manager');
15
14
  const { OPTION_FOLLOW } = require('../../../texts');
@@ -24,8 +23,7 @@ commandAgentTunnelHttp.action(async (target, options) => {
24
23
  if (!isEnabled) {
25
24
  Output.exitError(ERR_AGENT_NOT_ENABLED);
26
25
  }
27
- const myIp = await ApiBuddy.fetchMyIp();
28
- const prepared = await Cfg.prepareTunnel(TUNNEL_HTTP, target, options, true, myIp);
26
+ const prepared = await Cfg.prepareTunnel(TUNNEL_HTTP, target, options, true);
29
27
  try {
30
28
  await Output.spinner(TXT_OPENING_TUNNEL);
31
29
  const json = AgentManager.system.loadSystemConfig();
@@ -11,7 +11,6 @@ const {
11
11
  } = require('../../../texts.js');
12
12
  const ApiAgent = require('../../../api/agent.js');
13
13
  const AgentSocketTunnel = require('../../../agent/socket/tunnel.js');
14
- const ApiBuddy = require('../../../api/buddy');
15
14
  const { getBasicCommandTcp } = require('../../../utils');
16
15
  const AgentManager = require('../../../agent/manager');
17
16
 
@@ -24,8 +23,7 @@ commandAgentTunnelTcp.action(async (target, options) => {
24
23
  if (!isEnabled) {
25
24
  Output.exitError(ERR_AGENT_NOT_ENABLED);
26
25
  }
27
- const myIp = await ApiBuddy.fetchMyIp();
28
- const prepared = await Cfg.prepareTunnel(TUNNEL_TCP, target, options, true, myIp);
26
+ const prepared = await Cfg.prepareTunnel(TUNNEL_TCP, target, options, true);
29
27
  try {
30
28
  await Output.spinner(TXT_OPENING_TUNNEL);
31
29
  const json = AgentManager.system.loadSystemConfig();
@@ -9,7 +9,6 @@ const {
9
9
  TXT_TUNNEL_STARTED
10
10
  } = require('../../../texts.js');
11
11
  const ApiAgent = require('../../../api/agent.js');
12
- const ApiBuddy = require('../../../api/buddy');
13
12
  const { getBasicCommandTls } = require('../../../utils');
14
13
  const AgentManager = require('../../../agent/manager');
15
14
  const { OPTION_FOLLOW } = require('../../../texts');
@@ -24,8 +23,7 @@ commandAgentTunnelTls.action(async (target, options) => {
24
23
  if (!isEnabled) {
25
24
  Output.exitError(ERR_AGENT_NOT_ENABLED);
26
25
  }
27
- const myIp = await ApiBuddy.fetchMyIp();
28
- const prepared = await Cfg.prepareTunnel(TUNNEL_TLS, target, options, true, myIp);
26
+ const prepared = await Cfg.prepareTunnel(TUNNEL_TLS, target, options, true);
29
27
  try {
30
28
  await Output.spinner(TXT_OPENING_TUNNEL);
31
29
  const json = AgentManager.system.loadSystemConfig();
@@ -1,16 +1,16 @@
1
1
  const { Command } = require('commander');
2
2
  const Output = require('../../output.js');
3
3
  const {
4
- DESC_COMMAND_AGENT_DISABLE,
4
+ DESC_COMMAND_AGENT_UNINSTALL,
5
5
  TXT_AGENT_DISABLED
6
6
  } = require('../../texts.js');
7
7
  const AgentManager = require('../../agent/manager.js');
8
8
  const ApiBuddy = require('../../api/buddy.js');
9
9
  const { ERR_AGENT_ADMIN_RIGHTS } = require('../../texts');
10
10
 
11
- const commandAgentDisable = new Command('disable');
12
- commandAgentDisable.description(DESC_COMMAND_AGENT_DISABLE);
13
- commandAgentDisable.action(async () => {
11
+ const commandAgentUninstall = new Command('disable');
12
+ commandAgentUninstall.description(DESC_COMMAND_AGENT_UNINSTALL);
13
+ commandAgentUninstall.action(async () => {
14
14
  const hasAdminRights = await AgentManager.system.hasAdminRights();
15
15
  if (!hasAdminRights) {
16
16
  Output.exitError(ERR_AGENT_ADMIN_RIGHTS);
@@ -34,4 +34,4 @@ commandAgentDisable.action(async () => {
34
34
  Output.exitSuccess(TXT_AGENT_DISABLED);
35
35
  });
36
36
 
37
- module.exports = commandAgentDisable;
37
+ module.exports = commandAgentUninstall;
@@ -5,19 +5,19 @@ const commandAgentRestart = require('./agent/restart.js');
5
5
  const commandAgentStop = require('./agent/stop.js');
6
6
  const commandAgentUpdate = require('./agent/update.js');
7
7
  const commandAgentTunnel = require('./agent/tunnel.js');
8
- const commandAgentEnable = require('./agent/enable.js');
9
- const commandAgentDisable = require('./agent/disable.js');
8
+ const commandAgentInstall = require('./agent/install');
9
+ const commandAgentUninstall = require('./agent/uninstall.js');
10
10
  const commandAgentVersion = require('./agent/version.js');
11
11
  const { DESC_COMMAND_AGENT } = require('../texts.js');
12
12
  const commandAgentRun = require('./agent/run');
13
13
 
14
14
  const commandAgent = new Command('agent');
15
15
  commandAgent.description(DESC_COMMAND_AGENT);
16
- commandAgent.addCommand(commandAgentEnable);
16
+ commandAgent.addCommand(commandAgentInstall);
17
17
  commandAgent.addCommand(commandAgentStart);
18
18
  commandAgent.addCommand(commandAgentStop);
19
19
  commandAgent.addCommand(commandAgentRestart);
20
- commandAgent.addCommand(commandAgentDisable);
20
+ commandAgent.addCommand(commandAgentUninstall);
21
21
  commandAgent.addCommand(commandAgentStatus);
22
22
  commandAgent.addCommand(commandAgentTunnel);
23
23
  commandAgent.addCommand(commandAgentUpdate);
@@ -12,7 +12,6 @@ const {
12
12
  OPTION_TARGET,
13
13
  TXT_TUNNEL_ADDED
14
14
  } = require('../../../texts.js');
15
- const ApiBuddy = require('../../../api/buddy');
16
15
  const { getBasicCommandHttp } = require('../../../utils');
17
16
 
18
17
  const commandConfigAddHttp = getBasicCommandHttp();
@@ -25,8 +24,7 @@ commandConfigAddHttp.action(async (n, target, options) => {
25
24
  if (Cfg.hasTunnel(name) && !options.force) {
26
25
  Output.exitError(ERR_TUNNEL_ALREADY_EXISTS);
27
26
  }
28
- const myIp = await ApiBuddy.fetchMyIp();
29
- await Cfg.addTunnel(name, TUNNEL_HTTP, target, options, myIp);
27
+ await Cfg.addTunnel(name, TUNNEL_HTTP, target, options);
30
28
  Output.exitSuccess(TXT_TUNNEL_ADDED);
31
29
  });
32
30
 
@@ -12,7 +12,6 @@ const {
12
12
  OPTION_TARGET,
13
13
  TXT_TUNNEL_ADDED
14
14
  } = require('../../../texts.js');
15
- const ApiBuddy = require('../../../api/buddy');
16
15
  const { getBasicCommandTcp } = require('../../../utils');
17
16
 
18
17
  const commandConfigAddTcp = getBasicCommandTcp();
@@ -25,8 +24,7 @@ commandConfigAddTcp.action(async (n, target, options) => {
25
24
  if (Cfg.hasTunnel(name) && !options.force) {
26
25
  Output.exitError(ERR_TUNNEL_ALREADY_EXISTS);
27
26
  }
28
- const myIp = await ApiBuddy.fetchMyIp();
29
- await Cfg.addTunnel(name, TUNNEL_TCP, target, options, myIp);
27
+ await Cfg.addTunnel(name, TUNNEL_TCP, target, options);
30
28
  Output.exitSuccess(TXT_TUNNEL_ADDED);
31
29
  });
32
30
 
@@ -12,7 +12,6 @@ const {
12
12
  OPTION_TARGET,
13
13
  TXT_TUNNEL_ADDED
14
14
  } = require('../../../texts.js');
15
- const ApiBuddy = require('../../../api/buddy');
16
15
  const { getBasicCommandTls } = require('../../../utils');
17
16
 
18
17
  const commandConfigAddTls = getBasicCommandTls();
@@ -25,8 +24,7 @@ commandConfigAddTls.action(async (n, target, options) => {
25
24
  if (Cfg.hasTunnel(name) && !options.force) {
26
25
  Output.exitError(ERR_TUNNEL_ALREADY_EXISTS);
27
26
  }
28
- const myIp = await ApiBuddy.fetchMyIp();
29
- await Cfg.addTunnel(name, TUNNEL_TLS, target, options, myIp);
27
+ await Cfg.addTunnel(name, TUNNEL_TLS, target, options);
30
28
  Output.exitSuccess(TXT_TUNNEL_ADDED);
31
29
  });
32
30
 
@@ -18,8 +18,7 @@ commandHttp.option('--token <token>', OPTION_TOKEN);
18
18
  commandHttp.argument('[protocol://host:port]', OPTION_TARGET);
19
19
  commandHttp.action(async (target, options) => {
20
20
  if (options.token) Cfg.setToken(options.token);
21
- const myIp = await ApiBuddy.fetchMyIp();
22
- const prepared = await Cfg.prepareTunnel(TUNNEL_HTTP, target, options, true, myIp);
21
+ const prepared = await Cfg.prepareTunnel(TUNNEL_HTTP, target, options, true);
23
22
  await Output.spinner(TXT_OPENING_TUNNEL);
24
23
  const agent = await ApiBuddy.register(false, Cfg.getTokenHost(), Cfg.getToken(), (region) => {
25
24
  Cfg.setRegionIfNotSet(region);
@@ -16,8 +16,7 @@ commandTcp.option('--token <token>', OPTION_TOKEN);
16
16
  commandTcp.argument('[host:port]', OPTION_TARGET);
17
17
  commandTcp.action(async (target, options) => {
18
18
  if (options.token) Cfg.setToken(options.token);
19
- const myIp = await ApiBuddy.fetchMyIp();
20
- const prepared = await Cfg.prepareTunnel(TUNNEL_TCP, target, options, true, myIp);
19
+ const prepared = await Cfg.prepareTunnel(TUNNEL_TCP, target, options, true);
21
20
  await Output.spinner(TXT_OPENING_TUNNEL);
22
21
  const agent = await ApiBuddy.register(false, Cfg.getTokenHost(), Cfg.getToken(), (region) => {
23
22
  Cfg.setRegionIfNotSet(region);
@@ -16,8 +16,7 @@ commandTls.option('--token <token>', OPTION_TOKEN);
16
16
  commandTls.argument('[host:port]', OPTION_TARGET);
17
17
  commandTls.action(async (target, options) => {
18
18
  if (options.token) Cfg.setToken(options.token);
19
- const myIp = await ApiBuddy.fetchMyIp();
20
- const prepared = await Cfg.prepareTunnel(TUNNEL_TLS, target, options, true, myIp);
19
+ const prepared = await Cfg.prepareTunnel(TUNNEL_TLS, target, options, true);
21
20
  await Output.spinner(TXT_OPENING_TUNNEL);
22
21
  const agent = await ApiBuddy.register(false, Cfg.getTokenHost(), Cfg.getToken(), (region) => {
23
22
  Cfg.setRegionIfNotSet(region);
package/src/format.js CHANGED
@@ -37,7 +37,7 @@ class Format {
37
37
  }
38
38
 
39
39
  static whitelist(whitelist) {
40
- if (!whitelist || !whitelist.length) return 'No one';
40
+ if (!whitelist || !whitelist.length) return 'Everyone';
41
41
  if (whitelist.includes('*')) return 'Everyone';
42
42
  return whitelist.join('\n');
43
43
  }
package/src/index.js CHANGED
@@ -11,6 +11,7 @@ const commandVersion = require('./command/version.js');
11
11
  const commandPre = require('./command/pre.js');
12
12
  const stream = require('stream');
13
13
  const { isDocker } = require('./utils');
14
+ const { DESC_PROGRAM } = require('./texts');
14
15
 
15
16
  stream.setDefaultHighWaterMark(false, 67108864);
16
17
  process.title = 'bdy';
@@ -20,6 +21,7 @@ process.on('uncaughtException', (err) => {
20
21
  });
21
22
 
22
23
  const program = new Command();
24
+ program.description(DESC_PROGRAM);
23
25
  program.hook('preAction', commandPre);
24
26
  program.addCommand(commandConfig);
25
27
  program.addCommand(commandTcp);
package/src/logger.js CHANGED
@@ -31,6 +31,11 @@ class Logger {
31
31
  this.logPath = resolve(this.rootPath, 'cli.log');
32
32
  this.log1Path = resolve(this.rootPath, 'cli.1.log');
33
33
  this.logStream = fs.openSync(this.logPath, 'w');
34
+ try {
35
+ fs.chmodSync(this.logPath, 0o666);
36
+ } catch {
37
+ // do nothing
38
+ }
34
39
  this.p = pino({
35
40
  level: process.env.DEBUG === '1' ? 'debug' : 'info',
36
41
  timestamp: () => `, "time": "${new Date().toISOString()}"`,
package/src/texts.js CHANGED
@@ -98,7 +98,7 @@ const DESC_COMMAND_CONFIG_SET_WHITELIST = 'set default whitelist';
98
98
  const DESC_COMMAND_CONFIG_ADD = 'add configuration';
99
99
  const DESC_COMMAND_CONFIG_GET = 'get configuration';
100
100
  const DESC_COMMAND_CONFIG_REMOVE = 'remove configuration';
101
- const DESC_COMMAND_CONFIG_SET = 'set configuration';
101
+ const DESC_COMMAND_CONFIG_SET = 'Set configuration token/region/whitelist/timeout';
102
102
  const DESC_COMMAND_AGENT_TUNNEL_HTTP = 'start HTTP tunnel in agent';
103
103
  const DESC_COMMAND_AGENT_TUNNEL_LIST = 'list tunnels in agent';
104
104
  const DESC_COMMAND_AGENT_TUNNEL_START = 'start tunnel in agent from config';
@@ -106,21 +106,22 @@ const DESC_COMMAND_AGENT_TUNNEL_STATUS = 'status of tunnel in agent';
106
106
  const DESC_COMMAND_AGENT_TUNNEL_STOP = 'stop tunnel in agent';
107
107
  const DESC_COMMAND_AGENT_TUNNEL_TCP = 'start TCP tunnel in agent';
108
108
  const DESC_COMMAND_AGENT_TUNNEL_TLS = 'start TLS tunnel in agent';
109
- const DESC_COMMAND_AGENT_DISABLE = 'disable agent';
110
- const DESC_COMMAND_AGENT_ENABLE = 'enable agent';
111
- const DESC_COMMAND_AGENT_START = 'start agent';
112
- const DESC_COMMAND_AGENT_RESTART = 'restart agent';
113
- const DESC_COMMAND_AGENT_STATUS = 'agent status';
114
- const DESC_COMMAND_AGENT_STOP = 'stop agent';
115
- const DESC_COMMAND_AGENT_TUNNEL = 'manage agent tunnels';
116
- const DESC_COMMAND_AGENT_UPDATE = 'update agent version';
117
- const DESC_COMMAND_AGENT_VERSION = 'agent version';
118
- const DESC_COMMAND_CONFIG = 'manage configuration';
119
- const DESC_COMMAND_HTTP = 'start HTTP tunnel';
120
- const DESC_COMMAND_AGENT = 'manage agent';
121
- const DESC_COMMAND_START = 'start tunnel from config';
122
- const DESC_COMMAND_TCP = 'start TCP tunnel';
123
- const DESC_COMMAND_TLS = 'start TLS tunnel';
109
+ const DESC_COMMAND_AGENT_UNINSTALL = 'Uninstall bdy service';
110
+ const DESC_COMMAND_AGENT_INSTALL = 'Install bdy as operating system service on Windows, OS X and Linux systems';
111
+ const DESC_COMMAND_AGENT_START = 'Starts agent and all tunnels from configuration file';
112
+ const DESC_COMMAND_AGENT_RESTART = 'Restarts agent and all tunnels';
113
+ const DESC_COMMAND_AGENT_STATUS = 'Show the status of Buddy agent';
114
+ const DESC_COMMAND_AGENT_STOP = 'Stops agent and all tunnels';
115
+ const DESC_COMMAND_AGENT_TUNNEL = 'Manage agent\'s tunnels';
116
+ const DESC_COMMAND_AGENT_UPDATE = 'Install a new version of Buddy agent';
117
+ const DESC_COMMAND_AGENT_VERSION = 'Show the currently installed version';
118
+ const DESC_COMMAND_CONFIG = 'The config command gives a quick way to create or update configuration file.';
119
+ const DESC_COMMAND_HTTP = 'Starts a tunnel listening for HTTP/HTTPS traffic with a specific hostname.';
120
+ const DESC_COMMAND_AGENT = 'The agent command manages installation and execution of bdy as an operating system service on Windows, OS X and Linux systems';
121
+ const DESC_COMMAND_START = 'Starts tunnel from the configuration file.';
122
+ const DESC_COMMAND_TCP = 'Starts a tunnel which forwards all TCP traffic on a public port to a local address. This is extremely useful for exposing services that run non-HTTP traffic (ssh, sip, rdp, game servers, etc).';
123
+ const DESC_COMMAND_TLS = 'Starts a tunnel listening for TLS traffic on port 443 with a specific hostname.';
124
+ const DESC_PROGRAM = 'Buddy exposes local networked services behinds NATs and firewalls to the public internet over a secure tunnel. Share local websites, build/test webhook consumers, and self-host personal services.';
124
125
 
125
126
  const TXT_NEW_CLI_DOCKER_VERSION = (version) => `There is a new CLI Docker image version (${version})\n\n`;
126
127
  const TXT_NEW_CLI_VERSION = (version) => `There is a new CLI version (${version})\n\n`;
@@ -297,6 +298,7 @@ module.exports = {
297
298
  OPTION_USER,
298
299
  OPTION_PASS,
299
300
  OPTION_REGION,
301
+ DESC_PROGRAM,
300
302
  DESC_COMMAND_TLS,
301
303
  DESC_COMMAND_TCP,
302
304
  DESC_COMMAND_START,
@@ -310,8 +312,8 @@ module.exports = {
310
312
  DESC_COMMAND_AGENT_STATUS,
311
313
  DESC_COMMAND_AGENT_START,
312
314
  DESC_COMMAND_AGENT_RESTART,
313
- DESC_COMMAND_AGENT_ENABLE,
314
- DESC_COMMAND_AGENT_DISABLE,
315
+ DESC_COMMAND_AGENT_INSTALL,
316
+ DESC_COMMAND_AGENT_UNINSTALL,
315
317
  DESC_COMMAND_AGENT_TUNNEL_TLS,
316
318
  DESC_COMMAND_AGENT_TUNNEL_TCP,
317
319
  DESC_COMMAND_AGENT_TUNNEL_STOP,
package/src/utils.js CHANGED
@@ -1,11 +1,19 @@
1
1
  const { resolve } = require('path');
2
2
  const path = require('path');
3
- const { readFileSync, mkdirSync, existsSync } = require('fs');
3
+ const {
4
+ readFileSync,
5
+ mkdirSync,
6
+ existsSync,
7
+ chmodSync
8
+ } = require('fs');
4
9
  const { homedir } = require('os');
5
10
  const os = require('os');
6
11
  const { ERR_FETCH_VERSION } = require('./texts.js');
7
12
  const { Command } = require('commander');
8
- const { getAsset, isSea } = require('node:sea');
13
+ const {
14
+ getAsset,
15
+ isSea
16
+ } = require('node:sea');
9
17
  const Ssh2 = require('ssh2');
10
18
  const {
11
19
  OPTION_REGION,
@@ -138,7 +146,7 @@ const SOCKET_IO_EVENT_FETCH_FAILED = 'fetch failed';
138
146
  const SOCKET_IO_EVENT_AGENT = 'agent';
139
147
  const SOCKET_IO_EVENT_TUNNEL = 'tunnel';
140
148
 
141
- function apiErrorCodeToClass (code, host) {
149
+ function apiErrorCodeToClass(code, host) {
142
150
  if (code === 234000) {
143
151
  return new ApiErrorAgentNotFound();
144
152
  }
@@ -165,16 +173,19 @@ class ApiErrorAgentNotFound extends Error {
165
173
  super(ERR_AGENT_REMOVED);
166
174
  }
167
175
  }
176
+
168
177
  class ApiErrorFailedToConnect extends Error {
169
178
  constructor(host) {
170
179
  super(ERR_FAILED_TO_CONNECT(host));
171
180
  }
172
181
  }
182
+
173
183
  class ApiErrorWrongToken extends Error {
174
184
  constructor() {
175
185
  super(ERR_WRONG_TOKEN);
176
186
  }
177
187
  }
188
+
178
189
  class ApiErrorSubdomainTaken extends Error {
179
190
  constructor() {
180
191
  super(ERR_SUBDOMAIN_TAKEN);
@@ -236,7 +247,14 @@ const getHomeDirectory = () => {
236
247
  if (isDocker()) return '/buddy';
237
248
  const r = homedir();
238
249
  const p = path.join(r, '.bdy');
239
- if (!existsSync(p)) mkdirSync(p, { recursive: true });
250
+ if (!existsSync(p)) {
251
+ mkdirSync(p, { recursive: true });
252
+ try {
253
+ chmodSync(p, 0o777);
254
+ } catch {
255
+ // do nothing
256
+ }
257
+ }
240
258
  return p;
241
259
  };
242
260