bdy 1.18.5-dev → 1.18.6-stage
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/distTs/package.json +1 -1
- package/distTs/src/agent/manager.js +20 -18
- package/distTs/src/autocomplete.js +10 -5
- package/distTs/src/command/agent/debug.js +6 -6
- package/distTs/src/command/agent/disable.js +2 -2
- package/distTs/src/command/agent/enable.js +2 -2
- package/distTs/src/command/agent/install.js +31 -26
- package/distTs/src/command/agent/proxy/disable.js +2 -2
- package/distTs/src/command/agent/proxy/enable.js +2 -2
- package/distTs/src/command/agent/proxy/status.js +2 -2
- package/distTs/src/command/agent/restart.js +6 -6
- package/distTs/src/command/agent/run.js +3 -3
- package/distTs/src/command/agent/start.js +7 -7
- package/distTs/src/command/agent/stop.js +6 -6
- package/distTs/src/command/agent/tags/get.js +2 -2
- package/distTs/src/command/agent/tags/set.js +2 -2
- package/distTs/src/command/agent/target/disable.js +2 -2
- package/distTs/src/command/agent/target/enable.js +2 -2
- package/distTs/src/command/agent/target/status.js +2 -2
- package/distTs/src/command/agent/tunnel/disable.js +2 -2
- package/distTs/src/command/agent/tunnel/enable.js +2 -2
- package/distTs/src/command/agent/tunnel/http.js +7 -7
- package/distTs/src/command/agent/tunnel/list.js +2 -2
- package/distTs/src/command/agent/tunnel/remove.js +2 -2
- package/distTs/src/command/agent/tunnel/start.js +5 -5
- package/distTs/src/command/agent/tunnel/status.js +4 -4
- package/distTs/src/command/agent/tunnel/tcp.js +7 -7
- package/distTs/src/command/agent/tunnel/tls.js +7 -7
- package/distTs/src/command/agent/uninstall.js +12 -12
- package/distTs/src/command/agent/update.js +9 -9
- package/distTs/src/command/api/info.js +2 -1
- package/distTs/src/command/api/list.js +2 -1
- package/distTs/src/command/api/request.js +2 -2
- package/distTs/src/command/login.js +8 -6
- package/distTs/src/command/package/create.js +2 -2
- package/distTs/src/command/package/download.js +5 -37
- package/distTs/src/command/package/publish.js +7 -6
- package/distTs/src/command/pre.js +5 -5
- package/distTs/src/command/project/link.js +4 -3
- package/distTs/src/command/sandbox/cp.js +7 -39
- package/distTs/src/command/sandbox/create.js +2 -2
- package/distTs/src/command/sandbox/snapshot/create.js +2 -2
- package/distTs/src/command/scrape.js +15 -14
- package/distTs/src/command/tunnel/http.js +8 -8
- package/distTs/src/command/tunnel/start.js +9 -9
- package/distTs/src/command/tunnel/tcp.js +8 -8
- package/distTs/src/command/tunnel/tls.js +8 -8
- package/distTs/src/command/ut/upload.js +16 -48
- package/distTs/src/command/vt/close.js +5 -5
- package/distTs/src/command/vt/compare.js +18 -16
- package/distTs/src/command/vt/exec.js +28 -28
- package/distTs/src/command/vt/installBrowser.js +2 -2
- package/distTs/src/command/vt/storybook.js +14 -14
- package/distTs/src/input.js +8 -7
- package/distTs/src/logger.js +3 -3
- package/distTs/src/openapi.js +24 -0
- package/distTs/src/output.js +21 -16
- package/distTs/src/sshKeygen.js +9 -0
- package/distTs/src/tunnel/cfg.js +17 -20
- package/distTs/src/tunnel/tunnel.js +2 -1
- package/distTs/src/utils.js +1 -27
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AgentManagerClass = void 0;
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
-
const ws_1 = require("ws");
|
|
9
8
|
const logger_1 = __importDefault(require("../logger"));
|
|
10
9
|
const http_1 = __importDefault(require("http"));
|
|
11
10
|
const output_1 = __importDefault(require("../output"));
|
|
@@ -14,9 +13,8 @@ const windows_1 = __importDefault(require("./windows"));
|
|
|
14
13
|
const linux_1 = __importDefault(require("./linux"));
|
|
15
14
|
const system_1 = __importDefault(require("./system"));
|
|
16
15
|
const osx_1 = __importDefault(require("./osx"));
|
|
17
|
-
const buddy_1 = __importDefault(require("../tunnel/api/buddy"));
|
|
18
|
-
const socket_1 = __importDefault(require("./socket"));
|
|
19
16
|
const tunnel_1 = require("../types/tunnel");
|
|
17
|
+
const getApiBuddy = () => require('../tunnel/api/buddy').default;
|
|
20
18
|
class AgentManagerClass {
|
|
21
19
|
status;
|
|
22
20
|
id;
|
|
@@ -56,7 +54,7 @@ class AgentManagerClass {
|
|
|
56
54
|
}
|
|
57
55
|
async tryFetch() {
|
|
58
56
|
try {
|
|
59
|
-
this.agent = await
|
|
57
|
+
this.agent = await getApiBuddy().fetchAgent(this.id || '', this.host || '', this.token || '');
|
|
60
58
|
this.agent.manager = this;
|
|
61
59
|
this.agent.startRefreshingConfiguration((success) => {
|
|
62
60
|
if (success)
|
|
@@ -166,7 +164,7 @@ class AgentManagerClass {
|
|
|
166
164
|
return;
|
|
167
165
|
}
|
|
168
166
|
try {
|
|
169
|
-
await
|
|
167
|
+
await getApiBuddy().enableTarget(this.id || '', this.host || '', this.token || '');
|
|
170
168
|
this.agent.changeTarget(true);
|
|
171
169
|
}
|
|
172
170
|
catch (err) {
|
|
@@ -181,7 +179,7 @@ class AgentManagerClass {
|
|
|
181
179
|
return;
|
|
182
180
|
}
|
|
183
181
|
try {
|
|
184
|
-
await
|
|
182
|
+
await getApiBuddy().enableTunneling(this.id || '', this.host || '', this.token || '');
|
|
185
183
|
this.agent.changeTunneling(true);
|
|
186
184
|
}
|
|
187
185
|
catch (err) {
|
|
@@ -196,7 +194,7 @@ class AgentManagerClass {
|
|
|
196
194
|
return;
|
|
197
195
|
}
|
|
198
196
|
try {
|
|
199
|
-
await
|
|
197
|
+
await getApiBuddy().enableProxy(this.id || '', this.host || '', this.token || '');
|
|
200
198
|
this.agent.changeProxy(true);
|
|
201
199
|
}
|
|
202
200
|
catch (err) {
|
|
@@ -211,7 +209,7 @@ class AgentManagerClass {
|
|
|
211
209
|
return;
|
|
212
210
|
}
|
|
213
211
|
try {
|
|
214
|
-
await
|
|
212
|
+
await getApiBuddy().disableTarget(this.id || '', this.host || '', this.token || '');
|
|
215
213
|
this.agent.changeTarget(false);
|
|
216
214
|
}
|
|
217
215
|
catch (err) {
|
|
@@ -226,7 +224,7 @@ class AgentManagerClass {
|
|
|
226
224
|
return;
|
|
227
225
|
}
|
|
228
226
|
try {
|
|
229
|
-
await
|
|
227
|
+
await getApiBuddy().disableTunneling(this.id || '', this.host || '', this.token || '');
|
|
230
228
|
this.agent.changeTunneling(false);
|
|
231
229
|
}
|
|
232
230
|
catch (err) {
|
|
@@ -241,7 +239,7 @@ class AgentManagerClass {
|
|
|
241
239
|
return;
|
|
242
240
|
}
|
|
243
241
|
try {
|
|
244
|
-
await
|
|
242
|
+
await getApiBuddy().disableProxy(this.id || '', this.host || '', this.token || '');
|
|
245
243
|
this.agent.changeProxy(false);
|
|
246
244
|
}
|
|
247
245
|
catch (err) {
|
|
@@ -292,7 +290,7 @@ class AgentManagerClass {
|
|
|
292
290
|
return;
|
|
293
291
|
}
|
|
294
292
|
try {
|
|
295
|
-
await
|
|
293
|
+
await getApiBuddy().updateTags(this.id || '', this.host || '', this.token || '', data.tags || []);
|
|
296
294
|
this.serverOutput(res, {});
|
|
297
295
|
}
|
|
298
296
|
catch (err) {
|
|
@@ -338,7 +336,7 @@ class AgentManagerClass {
|
|
|
338
336
|
return;
|
|
339
337
|
}
|
|
340
338
|
try {
|
|
341
|
-
await
|
|
339
|
+
await getApiBuddy().removeTunnel(this.id || '', tunnel.id, this.host || '', this.token || '');
|
|
342
340
|
}
|
|
343
341
|
catch (err) {
|
|
344
342
|
this.serverError(res, err.message);
|
|
@@ -357,7 +355,7 @@ class AgentManagerClass {
|
|
|
357
355
|
// do nothing
|
|
358
356
|
}
|
|
359
357
|
try {
|
|
360
|
-
await
|
|
358
|
+
await getApiBuddy().unregister(this.id || '', this.host || '', this.token || '');
|
|
361
359
|
}
|
|
362
360
|
catch {
|
|
363
361
|
// do nothing
|
|
@@ -447,7 +445,7 @@ class AgentManagerClass {
|
|
|
447
445
|
}
|
|
448
446
|
let tunnel;
|
|
449
447
|
try {
|
|
450
|
-
tunnel = await
|
|
448
|
+
tunnel = await getApiBuddy().addTunnel(this.id || '', this.host || '', this.token || '', data, this.sshHostKey || '');
|
|
451
449
|
}
|
|
452
450
|
catch (err) {
|
|
453
451
|
this.serverError(res, err.message);
|
|
@@ -524,11 +522,13 @@ class AgentManagerClass {
|
|
|
524
522
|
con.close();
|
|
525
523
|
return;
|
|
526
524
|
}
|
|
527
|
-
|
|
525
|
+
const AgentSocket = require('./socket').default;
|
|
526
|
+
new AgentSocket(con, tunnel);
|
|
528
527
|
}
|
|
529
528
|
createServer() {
|
|
530
529
|
this.server = http_1.default.createServer((req, res) => this.processRequest(req, res));
|
|
531
|
-
|
|
530
|
+
const { WebSocketServer: WsServer } = require('ws');
|
|
531
|
+
this.ws = new WsServer({ noServer: true });
|
|
532
532
|
this.ws.on('connection', (con, id) => this.processWebsocketConnection(con, id));
|
|
533
533
|
this.server.on('upgrade', (req, socket, head) => this.processUpgrade(req, socket, head));
|
|
534
534
|
this.server.on('error', async (err) => {
|
|
@@ -552,8 +552,10 @@ class AgentManagerClass {
|
|
|
552
552
|
catch {
|
|
553
553
|
// save from param
|
|
554
554
|
}
|
|
555
|
-
if (!this.sshHostKey)
|
|
556
|
-
|
|
555
|
+
if (!this.sshHostKey) {
|
|
556
|
+
const { createSshHostKey } = require('../sshKeygen');
|
|
557
|
+
this.sshHostKey = createSshHostKey();
|
|
558
|
+
}
|
|
557
559
|
try {
|
|
558
560
|
// resave config
|
|
559
561
|
this.system.saveNewAgentConfig(this.sshHostKey || '');
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const tabtab_1 = __importDefault(require("tabtab"));
|
|
7
6
|
const logger_1 = __importDefault(require("./logger"));
|
|
8
7
|
class Autocomplete {
|
|
9
8
|
getCommandsMap(command) {
|
|
@@ -37,7 +36,11 @@ class Autocomplete {
|
|
|
37
36
|
return commands;
|
|
38
37
|
}
|
|
39
38
|
init(rootCommand) {
|
|
40
|
-
|
|
39
|
+
// COMP_LINE is set by all shells (bash natively, zsh/fish via tabtab scripts) when invoking completion
|
|
40
|
+
if (!process.env.COMP_LINE)
|
|
41
|
+
return false;
|
|
42
|
+
const tabtab = require('tabtab');
|
|
43
|
+
const env = tabtab.parseEnv(process.env);
|
|
41
44
|
if (!env.complete)
|
|
42
45
|
return false;
|
|
43
46
|
let map = {
|
|
@@ -67,17 +70,19 @@ class Autocomplete {
|
|
|
67
70
|
if (arg)
|
|
68
71
|
map = map[arg];
|
|
69
72
|
}
|
|
70
|
-
|
|
73
|
+
tabtab.log(Object.keys(map));
|
|
71
74
|
return true;
|
|
72
75
|
}
|
|
73
76
|
async install() {
|
|
74
|
-
|
|
77
|
+
const tabtab = require('tabtab');
|
|
78
|
+
await tabtab.install({
|
|
75
79
|
name: process.title,
|
|
76
80
|
completer: process.title
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
83
|
async uninstall() {
|
|
80
|
-
|
|
84
|
+
const tabtab = require('tabtab');
|
|
85
|
+
await tabtab.uninstall({
|
|
81
86
|
name: process.title
|
|
82
87
|
});
|
|
83
88
|
}
|
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
8
|
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
11
9
|
const commandAgentDebug = (0, utils_1.newCommand)('debug', texts_1.DESC_COMMAND_AGENT_DEBUG);
|
|
12
10
|
commandAgentDebug.argument('<on/off>');
|
|
13
11
|
commandAgentDebug.action(async (debug) => {
|
|
14
|
-
const
|
|
12
|
+
const AgentManager = require('../../agent/manager').default;
|
|
13
|
+
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
14
|
+
const hasAdminRights = await AgentManager.system.hasAdminRights();
|
|
15
15
|
if (!hasAdminRights) {
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
17
17
|
}
|
|
@@ -23,10 +23,10 @@ commandAgentDebug.action(async (debug) => {
|
|
|
23
23
|
}
|
|
24
24
|
try {
|
|
25
25
|
const debugOn = debug === 'on';
|
|
26
|
-
const json =
|
|
27
|
-
const api = new
|
|
26
|
+
const json = AgentManager.system.loadSystemConfig();
|
|
27
|
+
const api = new ApiAgent(json.port);
|
|
28
28
|
await api.debugChange(debugOn);
|
|
29
|
-
|
|
29
|
+
AgentManager.system.saveSystemConfig(json.id, json.host, json.token, json.port, !!json.standalone, debugOn);
|
|
30
30
|
output_1.default.exitSuccess(debugOn ? texts_1.TXT_AGENT_DEBUG_ON : texts_1.TXT_AGENT_DEBUG_OFF);
|
|
31
31
|
}
|
|
32
32
|
catch (err) {
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
10
9
|
const commandAgentDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_DISABLE);
|
|
11
10
|
commandAgentDisable.action(async () => {
|
|
11
|
+
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
12
12
|
if (!commandAgentDisable.agentInstalled) {
|
|
13
13
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ commandAgentDisable.action(async () => {
|
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
-
const api = new
|
|
19
|
+
const api = new ApiAgent(commandAgentDisable.agentPort || 0);
|
|
20
20
|
await api.disableAgent();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_STOPPED);
|
|
22
22
|
}
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../output"));
|
|
9
|
-
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
10
9
|
const commandAgentEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_ENABLE);
|
|
11
10
|
commandAgentEnable.action(async () => {
|
|
11
|
+
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
12
12
|
if (!commandAgentEnable.agentInstalled) {
|
|
13
13
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ commandAgentEnable.action(async () => {
|
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
-
const api = new
|
|
19
|
+
const api = new ApiAgent(commandAgentEnable.agentPort || 0);
|
|
20
20
|
await api.enableAgent();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_STARTED);
|
|
22
22
|
}
|
|
@@ -7,39 +7,37 @@ const output_1 = __importDefault(require("../../output"));
|
|
|
7
7
|
const input_1 = __importDefault(require("../../input"));
|
|
8
8
|
const texts_1 = require("../../texts");
|
|
9
9
|
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
10
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
11
|
-
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
12
|
-
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
13
|
-
const wait_1 = __importDefault(require("../../agent/wait"));
|
|
14
10
|
const utils_1 = require("../../utils");
|
|
15
11
|
const logger_1 = __importDefault(require("../../logger"));
|
|
16
12
|
const removeAllAndExit = async (txt, id, host, token) => {
|
|
13
|
+
const AgentManager = require('../../agent/manager').default;
|
|
14
|
+
const ApiBuddy = require('../../tunnel/api/buddy').default;
|
|
17
15
|
try {
|
|
18
|
-
await
|
|
16
|
+
await AgentManager.system.uninstall();
|
|
19
17
|
}
|
|
20
18
|
catch {
|
|
21
19
|
// do nothing
|
|
22
20
|
}
|
|
23
21
|
try {
|
|
24
|
-
await
|
|
22
|
+
await ApiBuddy.unregister(id, host, token);
|
|
25
23
|
}
|
|
26
24
|
catch {
|
|
27
25
|
// do nothing
|
|
28
26
|
}
|
|
29
27
|
try {
|
|
30
|
-
|
|
28
|
+
AgentManager.system.clearSystemFiles();
|
|
31
29
|
}
|
|
32
30
|
catch {
|
|
33
31
|
// do nothing
|
|
34
32
|
}
|
|
35
33
|
try {
|
|
36
|
-
|
|
34
|
+
AgentManager.system.clearAgentFiles();
|
|
37
35
|
}
|
|
38
36
|
catch {
|
|
39
37
|
// do nothing
|
|
40
38
|
}
|
|
41
39
|
try {
|
|
42
|
-
|
|
40
|
+
AgentManager.system.clearNewAgentFiles();
|
|
43
41
|
}
|
|
44
42
|
catch {
|
|
45
43
|
// do nothing
|
|
@@ -60,7 +58,11 @@ const prepareTags = (tags) => {
|
|
|
60
58
|
return validTags;
|
|
61
59
|
};
|
|
62
60
|
const installService = async (options) => {
|
|
63
|
-
const
|
|
61
|
+
const AgentManager = require('../../agent/manager').default;
|
|
62
|
+
const ApiBuddy = require('../../tunnel/api/buddy').default;
|
|
63
|
+
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
64
|
+
const waitUntilAgentEnabled = require('../../agent/wait').default;
|
|
65
|
+
const isSupported = await AgentManager.system.isSupported();
|
|
64
66
|
if (!isSupported) {
|
|
65
67
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_SUPPORTED);
|
|
66
68
|
}
|
|
@@ -80,7 +82,7 @@ const installService = async (options) => {
|
|
|
80
82
|
let agent;
|
|
81
83
|
if (id) {
|
|
82
84
|
try {
|
|
83
|
-
agent = await
|
|
85
|
+
agent = await ApiBuddy.fetchAgent(id, host, agentToken);
|
|
84
86
|
}
|
|
85
87
|
catch {
|
|
86
88
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_FOUND);
|
|
@@ -88,7 +90,7 @@ const installService = async (options) => {
|
|
|
88
90
|
}
|
|
89
91
|
if (!agent) {
|
|
90
92
|
const tags = prepareTags(options.tag);
|
|
91
|
-
agent = await
|
|
93
|
+
agent = await ApiBuddy.register(true, target, tunneling, proxy, host, token, tags, (region) => {
|
|
92
94
|
cfg_1.default.setRegionIfNotSet(region);
|
|
93
95
|
});
|
|
94
96
|
id = agent.id;
|
|
@@ -96,32 +98,32 @@ const installService = async (options) => {
|
|
|
96
98
|
agent.destroy();
|
|
97
99
|
agent = null;
|
|
98
100
|
}
|
|
99
|
-
const saved =
|
|
101
|
+
const saved = AgentManager.system.saveSystemConfig(id, host, agentToken, port, false, !!options.debug);
|
|
100
102
|
if (!saved) {
|
|
101
103
|
await removeAllAndExit(texts_1.ERR_SWW_AGENT_ENABLING, id, host, agentToken);
|
|
102
104
|
}
|
|
103
105
|
try {
|
|
104
|
-
|
|
106
|
+
AgentManager.system.clearAgentFiles();
|
|
105
107
|
}
|
|
106
108
|
catch {
|
|
107
109
|
// do nothing
|
|
108
110
|
}
|
|
109
111
|
try {
|
|
110
|
-
|
|
112
|
+
AgentManager.system.clearNewAgentFiles();
|
|
111
113
|
}
|
|
112
114
|
catch {
|
|
113
115
|
// do nothing
|
|
114
116
|
}
|
|
115
117
|
await output_1.default.spinner(texts_1.TXT_ENABLING_AGENT);
|
|
116
118
|
try {
|
|
117
|
-
await
|
|
119
|
+
await AgentManager.system.install(id, host, agentToken, port, !!options.start, options.user, options.pass, !!options.debug);
|
|
118
120
|
}
|
|
119
121
|
catch {
|
|
120
122
|
await removeAllAndExit(texts_1.ERR_SWW_AGENT_ENABLING, id, host, agentToken);
|
|
121
123
|
}
|
|
122
124
|
if (options.start) {
|
|
123
|
-
const api = new
|
|
124
|
-
await (
|
|
125
|
+
const api = new ApiAgent(port);
|
|
126
|
+
await waitUntilAgentEnabled(api, 15000, () => {
|
|
125
127
|
removeAllAndExit(texts_1.ERR_SWW_AGENT_ENABLING, id, host, agentToken);
|
|
126
128
|
}, () => {
|
|
127
129
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_INSTALLED);
|
|
@@ -129,7 +131,7 @@ const installService = async (options) => {
|
|
|
129
131
|
}
|
|
130
132
|
else {
|
|
131
133
|
try {
|
|
132
|
-
await
|
|
134
|
+
await ApiBuddy.markAgentAsInactive(id, host, agentToken);
|
|
133
135
|
}
|
|
134
136
|
catch {
|
|
135
137
|
// do nothing
|
|
@@ -138,6 +140,8 @@ const installService = async (options) => {
|
|
|
138
140
|
}
|
|
139
141
|
};
|
|
140
142
|
const installApp = async (options) => {
|
|
143
|
+
const AgentManager = require('../../agent/manager').default;
|
|
144
|
+
const ApiBuddy = require('../../tunnel/api/buddy').default;
|
|
141
145
|
if (options.debug) {
|
|
142
146
|
logger_1.default.setDebug(true);
|
|
143
147
|
}
|
|
@@ -155,7 +159,7 @@ const installApp = async (options) => {
|
|
|
155
159
|
const tags = prepareTags(options.tag);
|
|
156
160
|
try {
|
|
157
161
|
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERING, false);
|
|
158
|
-
const agent = await
|
|
162
|
+
const agent = await ApiBuddy.register(true, !!options.target, !!options.tunnels, !!options.proxy, host, token, tags, (region) => {
|
|
159
163
|
cfg_1.default.setRegionIfNotSet(region);
|
|
160
164
|
});
|
|
161
165
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERED);
|
|
@@ -175,7 +179,7 @@ const installApp = async (options) => {
|
|
|
175
179
|
try {
|
|
176
180
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHING);
|
|
177
181
|
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHING, false);
|
|
178
|
-
const agent = await
|
|
182
|
+
const agent = await ApiBuddy.fetchAgent(id, host, agentToken);
|
|
179
183
|
agent.destroy();
|
|
180
184
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHED);
|
|
181
185
|
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHED);
|
|
@@ -187,16 +191,16 @@ const installApp = async (options) => {
|
|
|
187
191
|
output_1.default.exitError(err);
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
|
-
const saved =
|
|
194
|
+
const saved = AgentManager.system.saveSystemConfig(id, host, agentToken, port, true, !!options.debug);
|
|
191
195
|
if (!saved) {
|
|
192
196
|
output_1.default.exitError(texts_1.ERR_SWW_AGENT_ENABLING);
|
|
193
197
|
}
|
|
194
198
|
if (options.start) {
|
|
195
|
-
|
|
199
|
+
AgentManager.system.startStandaloneProc();
|
|
196
200
|
}
|
|
197
201
|
else {
|
|
198
202
|
try {
|
|
199
|
-
await
|
|
203
|
+
await ApiBuddy.markAgentAsInactive(id, host, agentToken);
|
|
200
204
|
}
|
|
201
205
|
catch {
|
|
202
206
|
// do nothing
|
|
@@ -218,12 +222,13 @@ commandAgentInstall.option('--no-tunnels', texts_1.OPTION_AGENT_TUNNELING);
|
|
|
218
222
|
commandAgentInstall.option('--tag <tag...>', texts_1.OPTION_AGENT_TAG);
|
|
219
223
|
commandAgentInstall.option('-d, --debug', texts_1.OPTION_AGENT_DEBUG);
|
|
220
224
|
commandAgentInstall.action(async (options) => {
|
|
225
|
+
const AgentManager = require('../../agent/manager').default;
|
|
221
226
|
options.start = options.start === 'true' || options.start === true;
|
|
222
|
-
const hasAdminRights = await
|
|
227
|
+
const hasAdminRights = await AgentManager.system.hasAdminRights();
|
|
223
228
|
if (!hasAdminRights) {
|
|
224
229
|
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
225
230
|
}
|
|
226
|
-
const hasSystemConfig =
|
|
231
|
+
const hasSystemConfig = AgentManager.system.hasSystemConfig();
|
|
227
232
|
if (hasSystemConfig) {
|
|
228
233
|
output_1.default.exitError(texts_1.TXT_AGENT_ALREADY_INSTALLED);
|
|
229
234
|
}
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
9
|
const commandAgentProxyDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_PROXY_DISABLE);
|
|
11
10
|
commandAgentProxyDisable.action(async () => {
|
|
11
|
+
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
12
|
if (!commandAgentProxyDisable.agentInstalled) {
|
|
13
13
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ commandAgentProxyDisable.action(async () => {
|
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
-
const api = new
|
|
19
|
+
const api = new ApiAgent(commandAgentProxyDisable.agentPort || 0);
|
|
20
20
|
await api.disableAgentProxy();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_PROXY_DISABLED);
|
|
22
22
|
}
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
9
|
const commandAgentProxyEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_PROXY_ENABLE);
|
|
11
10
|
commandAgentProxyEnable.action(async () => {
|
|
11
|
+
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
12
|
if (!commandAgentProxyEnable.agentInstalled) {
|
|
13
13
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ commandAgentProxyEnable.action(async () => {
|
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
-
const api = new
|
|
19
|
+
const api = new ApiAgent(commandAgentProxyEnable.agentPort || 0);
|
|
20
20
|
await api.enableAgentProxy();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_TARGET_ENABLED);
|
|
22
22
|
}
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
-
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
9
|
const commandAgentProxyStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_PROXY_STATUS);
|
|
11
10
|
commandAgentProxyStatus.action(async () => {
|
|
11
|
+
const ApiAgent = require('../../../tunnel/api/agent').default;
|
|
12
12
|
if (!commandAgentProxyStatus.agentInstalled) {
|
|
13
13
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
14
|
}
|
|
@@ -16,7 +16,7 @@ commandAgentProxyStatus.action(async () => {
|
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
-
const api = new
|
|
19
|
+
const api = new ApiAgent(commandAgentProxyStatus.agentPort || 0);
|
|
20
20
|
const data = await api.fetchAgentProxy();
|
|
21
21
|
if (data.proxy) {
|
|
22
22
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_PROXY_ENABLED);
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const output_1 = __importDefault(require("../../output"));
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
8
|
const utils_1 = require("../../utils");
|
|
10
9
|
const logger_1 = __importDefault(require("../../logger"));
|
|
11
10
|
const commandAgentRestart = (0, utils_1.newCommand)('restart', texts_1.DESC_COMMAND_AGENT_RESTART);
|
|
12
11
|
commandAgentRestart.action(async () => {
|
|
13
|
-
const
|
|
12
|
+
const AgentManager = require('../../agent/manager').default;
|
|
13
|
+
const hasAdminRights = await AgentManager.system.hasAdminRights();
|
|
14
14
|
if (!hasAdminRights) {
|
|
15
15
|
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
16
16
|
}
|
|
@@ -18,14 +18,14 @@ commandAgentRestart.action(async () => {
|
|
|
18
18
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
19
19
|
}
|
|
20
20
|
if (commandAgentRestart.agentStandalone) {
|
|
21
|
-
await
|
|
22
|
-
|
|
21
|
+
await AgentManager.system.killStandaloneProc();
|
|
22
|
+
AgentManager.system.startStandaloneProc();
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
try {
|
|
26
|
-
await
|
|
26
|
+
await AgentManager.system.stop();
|
|
27
27
|
output_1.default.normal(texts_1.TXT_AGENT_STOPPED);
|
|
28
|
-
await
|
|
28
|
+
await AgentManager.system.start();
|
|
29
29
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_RESTARTED);
|
|
30
30
|
}
|
|
31
31
|
catch (err) {
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
7
6
|
const logger_1 = __importDefault(require("../../logger"));
|
|
8
7
|
const utils_1 = require("../../utils");
|
|
9
8
|
const commandAgentRun = (0, utils_1.newCommand)('run');
|
|
@@ -13,7 +12,8 @@ commandAgentRun.option('--token <token>');
|
|
|
13
12
|
commandAgentRun.option('--port <port>');
|
|
14
13
|
commandAgentRun.option('--start <start>');
|
|
15
14
|
commandAgentRun.action(async (options) => {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const AgentManager = require('../../agent/manager').default;
|
|
16
|
+
logger_1.default.changeRootPath(AgentManager.system.getNewAgentConfigDir());
|
|
17
|
+
AgentManager.start(options.id, options.host, options.token, parseInt(options.port, 10));
|
|
18
18
|
});
|
|
19
19
|
exports.default = commandAgentRun;
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const output_1 = __importDefault(require("../../output"));
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
8
|
const utils_1 = require("../../utils");
|
|
10
|
-
const logger_1 = __importDefault(require("../../logger"));
|
|
11
9
|
const commandAgentStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_AGENT_START);
|
|
12
10
|
commandAgentStart.action(async () => {
|
|
13
|
-
const
|
|
11
|
+
const AgentManager = require('../../agent/manager').default;
|
|
12
|
+
const logger = require('../../logger').default;
|
|
13
|
+
const hasAdminRights = await AgentManager.system.hasAdminRights();
|
|
14
14
|
if (!hasAdminRights) {
|
|
15
15
|
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
16
16
|
}
|
|
@@ -18,16 +18,16 @@ commandAgentStart.action(async () => {
|
|
|
18
18
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
19
19
|
}
|
|
20
20
|
if (commandAgentStart.agentStandalone) {
|
|
21
|
-
await
|
|
22
|
-
|
|
21
|
+
await AgentManager.system.killStandaloneProc();
|
|
22
|
+
AgentManager.system.startStandaloneProc();
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
25
|
try {
|
|
26
|
-
await
|
|
26
|
+
await AgentManager.system.start();
|
|
27
27
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_STARTED);
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
30
|
-
|
|
30
|
+
logger.error(err);
|
|
31
31
|
output_1.default.exitError(err);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
8
|
const output_1 = __importDefault(require("../../output"));
|
|
10
9
|
const logger_1 = __importDefault(require("../../logger"));
|
|
11
|
-
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
12
10
|
const commandAgentStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_AGENT_STOP);
|
|
13
11
|
commandAgentStop.action(async () => {
|
|
14
|
-
const
|
|
12
|
+
const AgentManager = require('../../agent/manager').default;
|
|
13
|
+
const ApiAgent = require('../../tunnel/api/agent').default;
|
|
14
|
+
const hasAdminRights = await AgentManager.system.hasAdminRights();
|
|
15
15
|
if (!hasAdminRights) {
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
17
17
|
}
|
|
@@ -19,19 +19,19 @@ commandAgentStop.action(async () => {
|
|
|
19
19
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
|
-
const api = new
|
|
22
|
+
const api = new ApiAgent(commandAgentStop.agentPort || 0);
|
|
23
23
|
await api.markInactive();
|
|
24
24
|
}
|
|
25
25
|
catch {
|
|
26
26
|
// do nothing
|
|
27
27
|
}
|
|
28
28
|
if (commandAgentStop.agentStandalone) {
|
|
29
|
-
await
|
|
29
|
+
await AgentManager.system.killStandaloneProc();
|
|
30
30
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_STOPPED);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
try {
|
|
34
|
-
await
|
|
34
|
+
await AgentManager.system.stop();
|
|
35
35
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_STOPPED);
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|