bdy 1.14.15 → 1.15.1-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/distTs/package.json +1 -1
- package/distTs/src/agent/linux.js +7 -0
- package/distTs/src/agent/manager.js +14 -18
- package/distTs/src/agent/osx.js +7 -0
- package/distTs/src/agent/system.js +69 -0
- package/distTs/src/agent/windows.js +7 -0
- package/distTs/src/command/agent/install.js +0 -4
- package/distTs/src/command/agent/standalone/kill.js +22 -0
- package/distTs/src/command/agent/standalone.js +136 -0
- package/distTs/src/command/agent/uninstall.js +6 -0
- package/distTs/src/command/agent/update.js +3 -0
- package/distTs/src/command/agent.js +2 -0
- package/distTs/src/output.js +5 -2
- package/distTs/src/texts.js +32 -11
- package/distTs/src/tunnel/server/ssh.js +10 -2
- package/package.json +1 -1
package/distTs/package.json
CHANGED
|
@@ -32,6 +32,10 @@ class AgentLinux extends system_1.default {
|
|
|
32
32
|
}
|
|
33
33
|
isEnabled() {
|
|
34
34
|
return new Promise((resolve) => {
|
|
35
|
+
if (this.isStandaloneProcRunning()) {
|
|
36
|
+
resolve(true);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
this.systemctl('is-enabled bdy')
|
|
36
40
|
.then(() => {
|
|
37
41
|
resolve(true);
|
|
@@ -50,6 +54,9 @@ class AgentLinux extends system_1.default {
|
|
|
50
54
|
getSystemConfigPath() {
|
|
51
55
|
return path_1.default.join(this.getSystemConfigDir(), 'agent.json');
|
|
52
56
|
}
|
|
57
|
+
getSystemStandalonePath() {
|
|
58
|
+
return path_1.default.join(this.getSystemConfigDir(), 'pid.lock');
|
|
59
|
+
}
|
|
53
60
|
getServicePath() {
|
|
54
61
|
return '/etc/systemd/system/bdy.service';
|
|
55
62
|
}
|
|
@@ -53,8 +53,8 @@ class AgentManagerClass {
|
|
|
53
53
|
this.system = new system_1.default();
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
start(id, host, token, port, start) {
|
|
57
|
-
this.load(id, host, token, port, start).then();
|
|
56
|
+
start(id, host, token, port, start, force = false) {
|
|
57
|
+
this.load(id, host, token, port, start, force).then();
|
|
58
58
|
}
|
|
59
59
|
async tryFetch() {
|
|
60
60
|
try {
|
|
@@ -494,24 +494,20 @@ class AgentManagerClass {
|
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
496
|
resaveAgentConfig(shouldStart, forceParam = false) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
this.sshHostKey = json.sshHostKey;
|
|
503
|
-
}
|
|
504
|
-
catch {
|
|
505
|
-
// save from param
|
|
506
|
-
this.shouldStart = shouldStart;
|
|
507
|
-
}
|
|
508
|
-
if (!this.sshHostKey)
|
|
509
|
-
this.sshHostKey = (0, utils_1.createSshHostKey)();
|
|
497
|
+
try {
|
|
498
|
+
// load from config
|
|
499
|
+
const json = this.system.loadNewAgentConfig();
|
|
500
|
+
this.shouldStart = !!json.shouldStart;
|
|
501
|
+
this.sshHostKey = json.sshHostKey;
|
|
510
502
|
}
|
|
511
|
-
|
|
503
|
+
catch {
|
|
512
504
|
// save from param
|
|
513
505
|
this.shouldStart = shouldStart;
|
|
514
506
|
}
|
|
507
|
+
if (!this.sshHostKey)
|
|
508
|
+
this.sshHostKey = (0, utils_1.createSshHostKey)();
|
|
509
|
+
if (forceParam)
|
|
510
|
+
this.shouldStart = shouldStart;
|
|
515
511
|
try {
|
|
516
512
|
// resave config
|
|
517
513
|
this.system.saveNewAgentConfig(this.shouldStart, this.sshHostKey || '');
|
|
@@ -521,7 +517,7 @@ class AgentManagerClass {
|
|
|
521
517
|
return false;
|
|
522
518
|
}
|
|
523
519
|
}
|
|
524
|
-
async load(id, host, token, port, start) {
|
|
520
|
+
async load(id, host, token, port, start, force = false) {
|
|
525
521
|
this.status = tunnel_1.TUNNEL_AGENT_STATUS.INITIALIZING;
|
|
526
522
|
this.id = id;
|
|
527
523
|
this.host = host;
|
|
@@ -531,7 +527,7 @@ class AgentManagerClass {
|
|
|
531
527
|
await this.disableAgentAndExit(texts_1.ERR_AGENT_NOT_REGISTERED);
|
|
532
528
|
return;
|
|
533
529
|
}
|
|
534
|
-
const ok = this.resaveAgentConfig(start);
|
|
530
|
+
const ok = this.resaveAgentConfig(start, force);
|
|
535
531
|
if (!ok) {
|
|
536
532
|
await this.disableAgentAndExit(texts_1.ERR_SAVING_AGENT_CONFIG);
|
|
537
533
|
return;
|
package/distTs/src/agent/osx.js
CHANGED
|
@@ -25,6 +25,10 @@ class AgentOsx extends system_1.default {
|
|
|
25
25
|
}
|
|
26
26
|
isEnabled() {
|
|
27
27
|
return new Promise((resolve) => {
|
|
28
|
+
if (this.isStandaloneProcRunning()) {
|
|
29
|
+
resolve(true);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
28
32
|
this.launchCtl('print system/bdy | grep domain')
|
|
29
33
|
.then((str) => {
|
|
30
34
|
resolve(!!str && !!str.match(/domain\s=\ssystem/i));
|
|
@@ -43,6 +47,9 @@ class AgentOsx extends system_1.default {
|
|
|
43
47
|
getSystemConfigPath() {
|
|
44
48
|
return path_1.default.join(this.getSystemConfigDir(), 'agent.json');
|
|
45
49
|
}
|
|
50
|
+
getSystemStandalonePath() {
|
|
51
|
+
return path_1.default.join(this.getSystemConfigDir(), 'pid.lock');
|
|
52
|
+
}
|
|
46
53
|
getServicePath() {
|
|
47
54
|
return '/Library/LaunchDaemons/bdy.plist';
|
|
48
55
|
}
|
|
@@ -31,6 +31,9 @@ class AgentSystem {
|
|
|
31
31
|
getSystemConfigPath() {
|
|
32
32
|
return '';
|
|
33
33
|
}
|
|
34
|
+
getSystemStandalonePath() {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
34
37
|
// extend
|
|
35
38
|
getSystemConfigDir() {
|
|
36
39
|
return '';
|
|
@@ -84,6 +87,26 @@ class AgentSystem {
|
|
|
84
87
|
const str = (0, fs_1.readFileSync)(this.getSystemConfigPath(), 'utf-8');
|
|
85
88
|
return JSON.parse(str);
|
|
86
89
|
}
|
|
90
|
+
loadStandaloneProcConfig() {
|
|
91
|
+
return (0, fs_1.readFileSync)(this.getSystemStandalonePath(), 'utf-8');
|
|
92
|
+
}
|
|
93
|
+
isStandaloneProcRunning() {
|
|
94
|
+
let pid;
|
|
95
|
+
try {
|
|
96
|
+
const str = this.loadStandaloneProcConfig();
|
|
97
|
+
pid = Number.parseInt(str, 10);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
process.kill(pid, 0);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
return err.code === 'EPERM';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
87
110
|
loadNewAgentConfig() {
|
|
88
111
|
const exists = (0, fs_1.existsSync)(this.getAgentConfigPath());
|
|
89
112
|
if (exists) {
|
|
@@ -158,6 +181,52 @@ class AgentSystem {
|
|
|
158
181
|
const archive = this.getBinaryArchive();
|
|
159
182
|
return this.downloadFile(`https://es.buddy.works/bdy/${env}/${version}/${archive}`, archivePath);
|
|
160
183
|
}
|
|
184
|
+
killStandaloneProc() {
|
|
185
|
+
try {
|
|
186
|
+
const str = this.loadStandaloneProcConfig();
|
|
187
|
+
const pid = Number.parseInt(str, 10);
|
|
188
|
+
if (pid) {
|
|
189
|
+
process.kill(pid);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
// do nothing
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
this.clearStandaloneProcConfig();
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// do nothing
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
clearStandaloneProcConfig() {
|
|
203
|
+
try {
|
|
204
|
+
logger_1.default.info(texts_1.LOG_REMOVING_AGENT_PROC_ID);
|
|
205
|
+
this.ensureSystemConfigDir();
|
|
206
|
+
(0, fs_1.rmSync)(this.getSystemStandalonePath(), {
|
|
207
|
+
force: true
|
|
208
|
+
});
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
logger_1.default.error(texts_1.LOG_ERROR_REMOVING_AGENT_STANDALONE_LOCK_FILE);
|
|
213
|
+
logger_1.default.error(err);
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
saveStandaloneProcConfig() {
|
|
218
|
+
try {
|
|
219
|
+
logger_1.default.info(texts_1.LOG_SAVING_AGENT_PROC_ID);
|
|
220
|
+
this.ensureSystemConfigDir();
|
|
221
|
+
(0, fs_1.writeFileSync)(this.getSystemStandalonePath(), String(process.pid), 'utf-8');
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
logger_1.default.error(texts_1.LOG_ERROR_SAVING_AGENT_STANDALONE_CONFIG);
|
|
226
|
+
logger_1.default.error(err);
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
161
230
|
saveSystemConfig(id, host, token, port) {
|
|
162
231
|
try {
|
|
163
232
|
logger_1.default.info(texts_1.LOG_SAVING_AGENT_SYSTEM_CONFIG);
|
|
@@ -22,6 +22,10 @@ class AgentWindows extends system_1.default {
|
|
|
22
22
|
}
|
|
23
23
|
isEnabled() {
|
|
24
24
|
return new Promise((resolve) => {
|
|
25
|
+
if (this.isStandaloneProcRunning()) {
|
|
26
|
+
resolve(true);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
25
29
|
this.sc('query bdy')
|
|
26
30
|
.then(() => {
|
|
27
31
|
resolve(true);
|
|
@@ -40,6 +44,9 @@ class AgentWindows extends system_1.default {
|
|
|
40
44
|
getSystemConfigPath() {
|
|
41
45
|
return path_1.default.join(this.getSystemConfigDir(), 'agent.json');
|
|
42
46
|
}
|
|
47
|
+
getSystemStandalonePath() {
|
|
48
|
+
return path_1.default.join(this.getSystemConfigDir(), 'pid.lock');
|
|
49
|
+
}
|
|
43
50
|
getNssmArchivePath() {
|
|
44
51
|
return path_1.default.join(this.getSystemConfigDir(), 'nssm.zip');
|
|
45
52
|
}
|
|
@@ -114,10 +114,6 @@ commandAgentInstall.action(async (options) => {
|
|
|
114
114
|
// do nothing
|
|
115
115
|
}
|
|
116
116
|
await output_1.default.spinner(texts_1.TXT_ENABLING_AGENT);
|
|
117
|
-
if (process.env.DEBUG === '1') {
|
|
118
|
-
manager_1.default.start(id, host, token, port, !!options.start);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
117
|
try {
|
|
122
118
|
await manager_1.default.system.enable(id, host, token, port, !!options.start, options.user, options.pass, !!options.debug);
|
|
123
119
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const commandAgentStandaloneKill = (0, utils_1.newCommand)('kill', texts_1.DESC_COMMAND_AGENT_STANDALONE_KILL);
|
|
11
|
+
commandAgentStandaloneKill.action(async () => {
|
|
12
|
+
const hasAdminRights = await manager_1.default.system.hasAdminRights();
|
|
13
|
+
if (!hasAdminRights) {
|
|
14
|
+
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
15
|
+
}
|
|
16
|
+
if (!manager_1.default.system.isStandaloneProcRunning()) {
|
|
17
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
18
|
+
}
|
|
19
|
+
manager_1.default.system.killStandaloneProc();
|
|
20
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_STANDALONE_STOPPED);
|
|
21
|
+
});
|
|
22
|
+
exports.default = commandAgentStandaloneKill;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
|
+
const output_1 = __importDefault(require("../../output"));
|
|
10
|
+
const buddy_1 = __importDefault(require("../../tunnel/api/buddy"));
|
|
11
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
12
|
+
const cfg_1 = __importDefault(require("../../tunnel/cfg"));
|
|
13
|
+
const input_1 = __importDefault(require("../../input"));
|
|
14
|
+
const kill_1 = __importDefault(require("./standalone/kill"));
|
|
15
|
+
const commandAgentStandalone = (0, utils_1.newCommand)('standalone', texts_1.DESC_COMMAND_AGENT_STANDALONE);
|
|
16
|
+
commandAgentStandalone.option('-i, --id <id>', texts_1.OPTION_AGENT_ID);
|
|
17
|
+
commandAgentStandalone.option('-t, --token <token>', texts_1.OPTION_AGENT_TOKEN);
|
|
18
|
+
commandAgentStandalone.option('-p, --port <port>', texts_1.OPTION_AGENT_PORT, '7456');
|
|
19
|
+
commandAgentStandalone.option('--target', texts_1.OPTION_AGENT_TARGET);
|
|
20
|
+
commandAgentStandalone.addCommand(kill_1.default);
|
|
21
|
+
commandAgentStandalone.action(async (options) => {
|
|
22
|
+
const hasAdminRights = await manager_1.default.system.hasAdminRights();
|
|
23
|
+
if (!hasAdminRights) {
|
|
24
|
+
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_PROC_CHECKING);
|
|
28
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_PROC_CHECKING, false);
|
|
29
|
+
manager_1.default.system.killStandaloneProc();
|
|
30
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_PROC_CHECKED);
|
|
31
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_PROC_CHECKED);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_PROC_ERROR);
|
|
35
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_PROC_ERROR);
|
|
36
|
+
logger_1.default.error(err);
|
|
37
|
+
output_1.default.exitError(err);
|
|
38
|
+
}
|
|
39
|
+
const isEnabled = await manager_1.default.system.isEnabled();
|
|
40
|
+
if (isEnabled) {
|
|
41
|
+
output_1.default.exitError(texts_1.ERR_AGENT_STANDALONE_SERVICE_INSTALLED);
|
|
42
|
+
}
|
|
43
|
+
let id;
|
|
44
|
+
let host;
|
|
45
|
+
let token;
|
|
46
|
+
let port;
|
|
47
|
+
try {
|
|
48
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_CONFIG_CHECKING);
|
|
49
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_CONFIG_CHECKING, false);
|
|
50
|
+
const json = manager_1.default.system.loadSystemConfig();
|
|
51
|
+
id = json.id;
|
|
52
|
+
host = json.host;
|
|
53
|
+
token = json.token;
|
|
54
|
+
port = json.port;
|
|
55
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_CONFIG_FOUND);
|
|
56
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_CONFIG_FOUND);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_CONFIG_NOT_FOUND);
|
|
60
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_CONFIG_NOT_FOUND);
|
|
61
|
+
}
|
|
62
|
+
if (!port) {
|
|
63
|
+
port = input_1.default.port(options.port);
|
|
64
|
+
}
|
|
65
|
+
if (!id && options.id) {
|
|
66
|
+
id = options.id;
|
|
67
|
+
logger_1.default.info((0, texts_1.TXT_AGENT_STANDALONE_USING_AGENT)(id));
|
|
68
|
+
output_1.default.normal((0, texts_1.TXT_AGENT_STANDALONE_USING_AGENT)(id));
|
|
69
|
+
}
|
|
70
|
+
if (!token) {
|
|
71
|
+
token = options.token;
|
|
72
|
+
}
|
|
73
|
+
if (!id) {
|
|
74
|
+
if (token)
|
|
75
|
+
cfg_1.default.setToken(token);
|
|
76
|
+
host = cfg_1.default.getTokenHost();
|
|
77
|
+
try {
|
|
78
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERING, false);
|
|
79
|
+
const agent = await buddy_1.default.register(true, !!options.target, host, cfg_1.default.getToken(), (region) => {
|
|
80
|
+
cfg_1.default.setRegionIfNotSet(region);
|
|
81
|
+
});
|
|
82
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERED);
|
|
83
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERED);
|
|
84
|
+
id = agent.id;
|
|
85
|
+
token = agent.token;
|
|
86
|
+
agent.destroy();
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTER_ERROR);
|
|
90
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTER_ERROR);
|
|
91
|
+
logger_1.default.error(err);
|
|
92
|
+
output_1.default.exitError(err);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (!host) {
|
|
97
|
+
host = cfg_1.default.getTokenHost();
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHING);
|
|
101
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHING, false);
|
|
102
|
+
const agent = await buddy_1.default.fetchAgent(id, host, token);
|
|
103
|
+
agent.destroy();
|
|
104
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHED);
|
|
105
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCHED);
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCH_ERROR);
|
|
109
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_FETCH_ERROR);
|
|
110
|
+
logger_1.default.error(err);
|
|
111
|
+
output_1.default.exitError(err);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
let saved = manager_1.default.system.saveSystemConfig(id, host, token, port);
|
|
115
|
+
if (!saved) {
|
|
116
|
+
output_1.default.exitError(texts_1.ERR_SWW_AGENT_ENABLING);
|
|
117
|
+
}
|
|
118
|
+
saved = manager_1.default.system.saveStandaloneProcConfig();
|
|
119
|
+
if (!saved) {
|
|
120
|
+
output_1.default.exitError(texts_1.ERR_SWW_AGENT_ENABLING);
|
|
121
|
+
}
|
|
122
|
+
logger_1.default.changeRootPath(manager_1.default.system.getNewAgentConfigDir());
|
|
123
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_STARTED);
|
|
124
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_STARTED);
|
|
125
|
+
process.on('SIGINT', onExit);
|
|
126
|
+
process.on('SIGTERM', onExit);
|
|
127
|
+
process.on('SIGQUIT', onExit);
|
|
128
|
+
manager_1.default.start(id, host, token, port, true, true);
|
|
129
|
+
});
|
|
130
|
+
const onExit = () => {
|
|
131
|
+
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_EXITING);
|
|
132
|
+
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_EXITING);
|
|
133
|
+
manager_1.default.system.clearStandaloneProcConfig();
|
|
134
|
+
process.exit(0);
|
|
135
|
+
};
|
|
136
|
+
exports.default = commandAgentStandalone;
|
|
@@ -20,6 +20,12 @@ commandAgentUninstall.action(async () => {
|
|
|
20
20
|
catch {
|
|
21
21
|
// do nothing
|
|
22
22
|
}
|
|
23
|
+
try {
|
|
24
|
+
manager_1.default.system.killStandaloneProc();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// do nothing
|
|
28
|
+
}
|
|
23
29
|
try {
|
|
24
30
|
const json = manager_1.default.system.loadSystemConfig();
|
|
25
31
|
await buddy_1.default.unregister(json.id, json.host, json.token);
|
|
@@ -20,6 +20,9 @@ commandAgentUpdate.action(async () => {
|
|
|
20
20
|
if (!isEnabled) {
|
|
21
21
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_ENABLED);
|
|
22
22
|
}
|
|
23
|
+
if (manager_1.default.system.isStandaloneProcRunning()) {
|
|
24
|
+
output_1.default.exitError(texts_1.ERR_AGENT_STANDALONE_UPDATE);
|
|
25
|
+
}
|
|
23
26
|
output_1.default.normal(texts_1.TXT_UPDATING_AGENT);
|
|
24
27
|
try {
|
|
25
28
|
await manager_1.default.system.update();
|
|
@@ -19,8 +19,10 @@ const target_1 = __importDefault(require("./agent/target"));
|
|
|
19
19
|
const enable_1 = __importDefault(require("./agent/enable"));
|
|
20
20
|
const disable_1 = __importDefault(require("./agent/disable"));
|
|
21
21
|
const debug_1 = __importDefault(require("./agent/debug"));
|
|
22
|
+
const standalone_1 = __importDefault(require("./agent/standalone"));
|
|
22
23
|
const commandAgent = (0, utils_1.newCommand)('agent', texts_1.DESC_COMMAND_AGENT);
|
|
23
24
|
commandAgent.addCommand(install_1.default);
|
|
25
|
+
commandAgent.addCommand(standalone_1.default);
|
|
24
26
|
commandAgent.addCommand(enable_1.default);
|
|
25
27
|
commandAgent.addCommand(disable_1.default);
|
|
26
28
|
commandAgent.addCommand(start_1.default);
|
package/distTs/src/output.js
CHANGED
|
@@ -29,8 +29,11 @@ class Output {
|
|
|
29
29
|
static newline() {
|
|
30
30
|
terminal('\n');
|
|
31
31
|
}
|
|
32
|
-
static normal(txt) {
|
|
33
|
-
|
|
32
|
+
static normal(txt, newLine = true) {
|
|
33
|
+
let msg = txt;
|
|
34
|
+
if (newLine)
|
|
35
|
+
msg += '\n';
|
|
36
|
+
terminal(msg);
|
|
34
37
|
}
|
|
35
38
|
static warning(txt) {
|
|
36
39
|
terminal.yellow(`${txt}\n`);
|
package/distTs/src/texts.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ERR_FAILED_TO_CONNECT = exports.ERR_TUNNEL_ALREADY_EXISTS = exports.ERR_AGENT_NOT_SUPPORTED = exports.ERR_AGENT_ADMIN_RIGHTS = exports.
|
|
3
|
+
exports.ERR_FAILED_TO_CONNECT = exports.ERR_TUNNEL_ALREADY_EXISTS = exports.ERR_AGENT_NOT_SUPPORTED = exports.ERR_AGENT_ADMIN_RIGHTS = exports.ERR_SWW_AGENT_UPDATING = exports.ERR_SWW_AGENT_ENABLING = exports.ERR_AGENT_NOT_FOUND = exports.ERR_AGENT_STANDALONE_SERVICE_INSTALLED = exports.ERR_AGENT_NOT_RUNNING = exports.ERR_AGENT_STANDALONE_UPDATE = exports.ERR_AGENT_NOT_ENABLED = exports.ERR_TUNNEL_NOT_FOUND = exports.ERR_WHITELIST_IS_NOT_VALID = exports.ERR_USER_AGENT_IS_NOT_VALID = exports.ERR_BA_IS_NOT_VALID = exports.ERR_BA_LOGIN_NOT_PROVIDED = exports.ERR_BA_PASSWORD_NOT_PROVIDED = exports.ERR_CB_THRESHOLD_IS_NOT_VALID = exports.ERR_CERT_PATH_IS_NOT_VALID = exports.ERR_KEY_PATH_IS_NOT_VALID = exports.ERR_CA_PATH_IS_NOT_VALID = exports.ERR_WRONG_CA = exports.ERR_WRONG_KEY_CERT = exports.ERR_NAME_WITHOUT_ASTERISK = exports.ERR_PORT_IS_NOT_VALID = exports.ERR_REGION_IS_NOT_VALID = exports.ERR_PATH_IS_NOT_DIRECTORY = exports.ERR_DIRECTORY_DOES_NOT_EXISTS = exports.ERR_TERMINATE_IS_NOT_VALID = exports.ERR_TIMEOUT_IS_NOT_VALID = exports.ERR_TYPE_IS_NOT_VALID = exports.ERR_TARGET_IS_NOT_VALID = exports.ERR_SAVING_AGENT_CONFIG = exports.ERR_AGENT_NOT_REGISTERED = exports.ERR_RUN_PIPELINE_WRONG_VARIABLE = exports.ERR_RUN_PIPELINE_WRONG_ACTION = exports.ERR_RUN_PIPELINE_WRONG_DELAY = exports.ERR_RUN_PIPELINE_WRONG_PRIORITY = exports.ERR_RUN_PIPELINE_WAIT_TIMEOUT = exports.ERR_RUN_PIPELINE_NOT_FOUND = exports.ERR_RUN_PIPELINE_PROJECT_NOT_FOUND = exports.ERR_RUN_PIPELINE_WORKSPACE_NOT_FOUND = exports.ERR_REST_API_PROJECT = exports.ERR_REST_API_WORKSPACE = exports.ERR_REST_API_URL = exports.ERR_REST_API_TOKEN = exports.ERR_REST_API_RATE_LIMIT = exports.ERR_REST_API_RESOURCE_NOT_FOUND = exports.ERR_REST_API_WRONG_TOKEN = exports.ERR_REST_API_GENERAL_ERROR = void 0;
|
|
4
4
|
exports.TXT_AGENT_IS_ENABLED_AND_STARTED = exports.TXT_AGENT_RESTARTED = exports.TXT_AGENT_DEBUG_OFF = exports.TXT_AGENT_DEBUG_ON = exports.TXT_AGENT_STARTED = exports.TXT_AGENT_STOPPED = exports.WARN_BROWSER_VERSION = exports.ERR_RESOURCE_DISCOVERY = exports.ERR_NO_SNAPSHOTS_TO_SEND = exports.ERR_INVALID_SNAPSHOT = exports.ERR_TEST_EXECUTION = exports.ERR_INVALID_JSON = exports.ERR_INVALID_DOWNLOAD_RESPONSE = exports.ERR_INVALID_SCRAPE_RESPONSE = exports.ERR_INVALID_COMPARE_LINKS_RESPONSE = exports.ERR_INVALID_STORYBOOK_RESPONSE = exports.ERR_INVALID_DEFAULT_SETTINGS_RESPONSE = exports.ERR_INVALID_CLOSE_SESSION_RESPONSE = exports.ERR_INVALID_SNAPSHOTS_RESPONSE = exports.ERR_INVALID_SNAPSHOT_RESPONSE = exports.ERR_MISSING_URLS = exports.ERR_RESOURCE_NOT_FOUND = exports.ERR_MISSING_EXEC_COMMAND = exports.ERR_PARSING_STORIES = exports.ERR_UNSUPPORTED_STORYBOOK = exports.ERR_MISSING_STORYBOOK_INDEX_FILE = exports.ERR_WRONG_STORYBOOK_DIRECTORY = exports.ERR_MISSING_BUILD_ID = exports.ERR_MISSING_UT_TOKEN = exports.ERR_MISSING_VT_TOKEN = exports.ERR_CONFIG_CORRUPTED = exports.ERR_WRONG_TOKEN = exports.ERR_TOKEN_NOT_PROVIDED = exports.ERR_CANT_CREATE_DIR_IN_HOME = exports.ERR_CONNECTION_ERROR = exports.ERR_CONNECTION_TIMEOUT = exports.ERR_WRONG_STREAM = exports.ERR_WRONG_HANDSHAKE = exports.ERR_FETCH_VERSION = exports.ERR_SWW = exports.ERR_NOT_FOUND = exports.ERR_FAILED_TO_CONNECT_TO_AGENT = exports.ERR_TUNNEL_REMOVED = exports.ERR_TUNNELS_DISABLED = exports.ERR_AGENT_LIMIT_REACHED = exports.ERR_TUNNEL_TARGET_INVALID = exports.ERR_WORKSPACE_FLAGGED = exports.ERR_TUNNEL_LIMIT_REACHED = exports.ERR_DOMAIN_RESTRICTED = exports.ERR_AGENT_REMOVED = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
5
|
+
exports.DESC_COMMAND_CONFIG_SET_TOKEN = exports.DESC_COMMAND_CONFIG_SET_TIMEOUT = exports.DESC_COMMAND_CONFIG_SET_REGION = exports.DESC_COMMAND_CONFIG_REMOVE_TUNNEL = exports.DESC_COMMAND_CONFIG_GET_WHITELIST = exports.DESC_COMMAND_CONFIG_GET_TUNNELS = exports.DESC_COMMAND_CONFIG_GET_TUNNEL = exports.DESC_COMMAND_CONFIG_GET_TOKEN = exports.DESC_COMMAND_CONFIG_GET_TIMEOUT = exports.DESC_COMMAND_CONFIG_GET_REGION = exports.DESC_COMMAND_CONFIG_ADD_TLS = exports.DESC_COMMAND_CONFIG_ADD_TCP = exports.DESC_COMMAND_CONFIG_ADD_HTTP = exports.AGENT_FETCH_RETRY = exports.NO_TUNNELS_STARTED = exports.TXT_AGENT_STANDALONE_USING_AGENT = exports.TXT_AGENT_STANDALONE_EXITING = exports.TXT_AGENT_STANDALONE_STOPPED = exports.TXT_AGENT_STANDALONE_STARTED = exports.TXT_AGENT_STANDALONE_AGENT_REGISTER_ERROR = exports.TXT_AGENT_STANDALONE_AGENT_REGISTERED = exports.TXT_AGENT_STANDALONE_AGENT_REGISTERING = exports.TXT_AGENT_STANDALONE_AGENT_FETCH_ERROR = exports.TXT_AGENT_STANDALONE_AGENT_FETCHED = exports.TXT_AGENT_STANDALONE_AGENT_FETCHING = exports.TXT_AGENT_STANDALONE_CONFIG_NOT_FOUND = exports.TXT_AGENT_STANDALONE_CONFIG_FOUND = exports.TXT_AGENT_STANDALONE_CONFIG_CHECKING = exports.TXT_AGENT_STANDALONE_PROC_ERROR = exports.TXT_AGENT_STANDALONE_PROC_CHECKED = exports.TXT_AGENT_STANDALONE_PROC_CHECKING = exports.TXT_TUNNEL_ADDED = exports.TXT_TUNNEL_REMOVED = exports.TXT_REGION_SAVED = exports.TXT_TIMEOUT_SAVED = exports.TXT_TOKEN_REMOVED = exports.TXT_TOKEN_SAVED = exports.TXT_WHITELIST_SAVED = exports.TXT_TUNNEL_STOPPED = exports.TXT_TUNNEL_STARTED = exports.TXT_AGENT_DISABLED = exports.TXT_AGENT_ALREADY_ENABLED = exports.TXT_AGENT_UPDATED = exports.TXT_AGENT_ENABLED = exports.TXT_AGENT_TARGET_DISABLED = exports.TXT_AGENT_TARGET_ENABLED = exports.TXT_AGENT_IS_DISABLED = exports.TXT_AGENT_IS_ENABLED_AND_HAVE_TROUBLES = exports.TXT_AGENT_IS_ENABLED_AND_INITIALIZING = exports.TXT_AGENT_IS_ENABLED_AND_STOPPED = void 0;
|
|
6
|
+
exports.TXT_NEW_CLI_VERSION = exports.TXT_NEW_CLI_DOCKER_VERSION = exports.OPTION_UPLOAD_DRY_RUN = exports.OPTION_UPLOAD_REPORT_FORMAT = exports.OPTION_UPLOAD_REPORT_GLOB = exports.DESC_COMMAND_UT_UPLOAD = exports.DESC_COMMAND_UT = exports.DESC_COMMAND_VT_INSTALL_BROWSER = exports.DESC_COMMAND_VT_EXEC = exports.DESC_COMMAND_VT_SCRAPE = exports.DESC_COMMAND_VT_COMPARE = exports.DESC_COMMAND_VT_STORYBOOK = exports.DESC_COMMAND_VT_CLOSE = exports.DESC_COMMAND_VT = exports.DESC_COMMAND_PIPELINE_RUN = exports.DESC_COMMAND_PIPELINE = exports.DESC_PROGRAM = exports.DESC_COMMAND_TLS = exports.DESC_COMMAND_TCP = exports.DESC_COMMAND_START = exports.DESC_COMMAND_TUNNEL = exports.DESC_COMMAND_AGENT = exports.DESC_COMMAND_HTTP = exports.DESC_COMMAND_CONFIG = exports.DESC_COMMAND_AGENT_VERSION = exports.DESC_COMMAND_AGENT_UPDATE = exports.DESC_COMMAND_AGENT_TARGET = exports.DESC_COMMAND_AGENT_TUNNEL = exports.DESC_COMMAND_AGENT_STOP = exports.DESC_COMMAND_AGENT_TARGET_DISABLE = exports.DESC_COMMAND_AGENT_TARGET_ENABLE = exports.DESC_COMMAND_AGENT_TARGET_STATUS = exports.DESC_COMMAND_AGENT_STATUS = exports.DESC_COMMAND_AGENT_RESTART = exports.DESC_COMMAND_AGENT_ENABLE = exports.DESC_COMMAND_AGENT_DEBUG = exports.DESC_COMMAND_AGENT_DISABLE = exports.DESC_COMMAND_AGENT_START = exports.DESC_COMMAND_AGENT_STANDALONE_KILL = exports.DESC_COMMAND_AGENT_STANDALONE = exports.DESC_COMMAND_AGENT_INSTALL = exports.DESC_COMMAND_AGENT_UNINSTALL = exports.DESC_COMMAND_AGENT_TUNNEL_REMOVE = exports.DESC_COMMAND_AGENT_TUNNEL_STATUS = exports.DESC_COMMAND_AGENT_TUNNEL_LIST = exports.DESC_COMMAND_CONFIG_SET = exports.DESC_COMMAND_CONFIG_REMOVE = exports.DESC_COMMAND_CONFIG_GET = exports.DESC_COMMAND_CONFIG_ADD = exports.DESC_COMMAND_CONFIG_SET_WHITELIST = void 0;
|
|
7
|
+
exports.OPTION_TLS_CA = exports.OPTION_TLS_CERT = exports.OPTION_TLS_KEY = exports.OPTION_HTTP_CIRCUIT_BREAKER = exports.OPTION_HTTP_COMPRESSION = exports.OPTION_HTTP_2 = exports.OPTION_HTTP_VERIFY = exports.OPTION_HTTP_LOG = exports.OPTION_HTTP_AUTH_BUDDY = exports.OPTION_HTTP_AUTH = exports.OPTION_HTTP_HOST = exports.OPTION_FORCE = exports.OPTION_TOKEN = exports.OPTION_TIMEOUT = exports.OPTION_FOLLOW = exports.OPTION_SERVE = exports.OPTION_HEADER_USER_AGENT = exports.OPTION_RESPONSE_HEADER = exports.OPTION_HEADER = exports.OPTION_WHITELIST = exports.OPTION_REST_API_PROJECT = exports.OPTION_REST_API_WORKSPACE = exports.OPTION_PIPELINE_RUN_WAIT = exports.OPTION_PIPELINE_RUN_ACTION = exports.OPTION_REST_API_TOKEN = exports.OPTION_PIPELINE_RUN_ARGUMENT = exports.OPTION_PIPELINE_RUN_DELAY = exports.OPTION_PIPELINE_RUN_VAR = exports.OPTION_PIPELINE_RUN_PRIORITY = exports.OPTION_PIPELINE_RUN_CLEAR_CACHE = exports.OPTION_PIPELINE_RUN_REFRESH = exports.OPTION_PIPELINE_RUN_COMMENT = exports.OPTION_PIPELINE_RUN_PULL_REQUEST = exports.OPTION_PIPELINE_RUN_REVISION = exports.OPTION_PIPELINE_RUN_TAG = exports.OPTION_PIPELINE_RUN_BRANCH = exports.OPTION_REST_API_REGION = exports.OPTION_REST_API_ENDPOINT = exports.OPTION_DEFAULT_REGION = exports.OPTION_REGION = exports.TXT_PIPELINE_RUN_FINISH_FAILED = exports.TXT_PIPELINE_RUN_FINISH_SUCCESSFULLY = exports.TXT_STORIES_AMOUNT = exports.TXT_PIPELINE_RUN_STILL_WAITING = exports.TXT_PIPELINE_RUN_WAIT = exports.TXT_PIPELINE_RUN_SUCCESS = exports.TXT_OPENING_TUNNEL = exports.TXT_UPDATING_AGENT = exports.TXT_ENABLING_AGENT = exports.TXT_NEW_AGENT_VERSION = void 0;
|
|
8
|
+
exports.LOG_ERROR_REMOVING_AGENT_STANDALONE_LOCK_FILE = exports.LOG_ERROR_SAVING_AGENT_STANDALONE_CONFIG = exports.LOG_ERROR_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_REMOVING_AGENT_PROC_ID = exports.LOG_SAVING_AGENT_PROC_ID = exports.LOG_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_REGISTERING_AGENT = exports.OPTION_SCRAPE_OUTPUT_DIR = exports.OPTION_SCRAPE_DELAY = exports.OPTION_SCRAPE_DARK_MODE = exports.OPTION_SCRAPE_WAIT_FOR_ELEMENT = exports.OPTION_SCRAPE_DEVICE_PIXEL_RATIO = exports.OPTION_SCRAPE_VIEWPORT = exports.OPTION_SCRAPE_BROWSER = exports.OPTION_SCRAPE_XPATH_SELECTOR = exports.OPTION_SCRAPE_CSS_SELECTOR = exports.OPTION_SCRAPE_FULL_PAGE = exports.OPTION_SCRAPE_QUALITY = exports.OPTION_SCRAPE_OUTPUT_TYPE = exports.OPTION_SCRAPE_FOLLOW = exports.OPTION_SCRAPE_URL = exports.OPTION_COMPARE_WAIT_FOR = exports.OPTION_COMPARE_DELAY = exports.OPTION_COMPARE_HEADER = exports.OPTION_COMPARE_COOKIE = exports.OPTION_COMPARE_IGNORE = exports.OPTION_COMPARE_IGNORE_URLS = exports.OPTION_COMPARE_DRY_RUN = exports.OPTION_COMPARE_URLS_FILE = exports.OPTION_COMPARE_SITEMAP = exports.OPTION_COMPARE_URLS = exports.OPTION_COMPARE_RESPECT_ROBOTS = exports.OPTION_COMPARE_FOLLOW = exports.OPTION_EXEC_PARALLEL = exports.OPTION_EXEC_ONE_BY_ONE = exports.OPTION_EXEC_SKIP_DISCOVERY = exports.OPTION_EXEC_COMMAND = exports.OPTION_AGENT_DEBUG = exports.OPTION_AGENT_PORT = exports.OPTION_AGENT_TARGET = exports.OPTION_PASS = exports.OPTION_USER = exports.OPTION_AGENT_TOKEN = exports.OPTION_AGENT_START = exports.OPTION_AGENT_ID = exports.OPTION_ID = exports.OPTION_NAME = exports.OPTION_TARGET = exports.OPTION_TLS_TERMINATE = void 0;
|
|
9
|
+
exports.LOG_TUNNEL_TLS_REGION_STREAM = exports.LOG_TUNNEL_TLS_TARGET_STREAM = exports.LOG_TUNNEL_HTTP2_STREAM = exports.LOG_TUNNEL_HTTP1_STREAM = exports.LOG_TUNNEL_TCP_STREAM = exports.LOG_TUNNEL_HTTP_WRONG_USER_AGENTS = exports.LOG_TUNNEL_HTTP_CIRCUIT_BREAKER_OPEN = exports.LOG_TUNNEL_HTTP_RATE_LIMIT = exports.LOG_TUNNEL_HTTP_WRON_AUTH = exports.LOG_TUNNEL_IDENTIFIED = exports.LOG_TUNNEL_DISCONNECTED = exports.LOG_TUNNEL_FAILED = exports.LOG_TUNNEL_CONNECTED = exports.LOG_AGENT_STARTED = exports.LOG_AGENT_SERVER_STARTED = exports.LOG_ERROR_STARTING_AGENT_SERVER = exports.LOG_SSH_CONNECTION = exports.LOG_WRONG_STREAM = exports.LOG_DETECTED_STREAM = exports.LOG_HTTP2_REQUEST = exports.LOG_HTTP2_CONNECTION = exports.LOG_HTTP1_REQUEST = exports.LOG_HTTP1_CONNECTION = exports.LOG_ERROR = exports.LOG_STOPPING_TUNNEL = exports.LOG_STARTING_TUNNEL = exports.LOG_ENABLING_AGENT_TARGET = exports.LOG_DISABLING_AGENT_TARGET = exports.LOG_REMOVING_TUNNEL = exports.LOG_TUNNEL_REGISTERED = exports.LOG_ERROR_WHILE_REFRESHING_AGENT = exports.LOG_REGISTERING_TUNNEL = exports.LOG_GETTING_AGENT = exports.LOG_UNREGISTERING_AGENT = exports.LOG_REGION_DETECTED = exports.LOG_AGENT_REGISTERED = exports.LOG_SOCKET_DISCONNECTED = exports.LOG_SOCKET_CONNECTED = exports.LOG_AGENT_NSSM_CLEARING = exports.LOG_AGENT_NSSM_EXTRACTING = exports.LOG_AGENT_NSSM_DOWNLOADING = exports.LOG_AGENT_ENABLED = exports.LOG_AGENT_STARTING_SYSTEM = exports.LOG_AGENT_STOPPING_SYSTEM = exports.LOG_AGENT_ENABLING_SYSTEM = exports.LOG_AGENT_SYSTEM_SERVICE_CONFIG = exports.LOG_AGENT_EXTRACTING_ARCHIVE = exports.LOG_AGENT_DOWNLOADING_ARCHIVE = exports.LOG_AGENT_SYSTEM_DIR = exports.LOG_ERROR_SAVING_AGENT_LOCAL_CONFIG = void 0;
|
|
10
|
+
exports.DEBUG_WAIT_FOR_IDLE_TIMEOUT = exports.DEBUG_WAIT_FOR_IDLE = exports.DEBUG_RESOURCE_DISCOVERY_TIMEOUT = exports.DEBUG_AUTO_WIDTH = exports.DEBUG_AUTO_SCROLL = exports.DEBUG_RESOURCE_SCRAPPING_URL = exports.DEBUG_SNAPSHOT_PROCESSING = exports.DEBUG_SNAPSHOTS_PROCESSING = exports.DEBUG_EXEC_COMMAND = exports.DEBUG_EXEC_TEST_COMMAND = exports.LOG_INSTALLED_BROWSER = exports.LOG_SESSION_LINK = exports.LOG_SENDING_DATA = exports.LOG_SENDING_REQUEST = exports.LOG_PROCESSING_SNAPSHOTS = exports.LOG_RUNNING_EXEC_COMMAND = exports.LOG_TUNNEL_SSH_STREAM = exports.LOG_TUNNEL_TLS_AGENT_STREAM = void 0;
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
exports.ERR_REST_API_GENERAL_ERROR = 'Something went wrong';
|
|
12
13
|
exports.ERR_REST_API_WRONG_TOKEN = 'Valid token with proper scopes is required';
|
|
@@ -67,12 +68,12 @@ exports.ERR_WHITELIST_IS_NOT_VALID = ERR_WHITELIST_IS_NOT_VALID;
|
|
|
67
68
|
const ERR_TUNNEL_NOT_FOUND = (name) => `Tunnel '${name}' not found`;
|
|
68
69
|
exports.ERR_TUNNEL_NOT_FOUND = ERR_TUNNEL_NOT_FOUND;
|
|
69
70
|
exports.ERR_AGENT_NOT_ENABLED = 'Agent not installed';
|
|
71
|
+
exports.ERR_AGENT_STANDALONE_UPDATE = 'Standalone agent cannot be updated. Must be manually killed & started';
|
|
70
72
|
exports.ERR_AGENT_NOT_RUNNING = 'Agent not running';
|
|
73
|
+
exports.ERR_AGENT_STANDALONE_SERVICE_INSTALLED = 'Agent already installed as a service. Uninstall it first: bdy agent uninstall';
|
|
71
74
|
exports.ERR_AGENT_NOT_FOUND = 'Agent not found';
|
|
72
75
|
exports.ERR_SWW_AGENT_ENABLING = 'Failed installing agent';
|
|
73
|
-
exports.ERR_SWW_AGENT_DISABLING = 'Failed uninstalling agent';
|
|
74
76
|
exports.ERR_SWW_AGENT_UPDATING = 'Failed updating agent';
|
|
75
|
-
exports.ERR_AGENT_ENABLE = 'Agent disabled: install first';
|
|
76
77
|
exports.ERR_AGENT_ADMIN_RIGHTS = 'Command must be run with administrator rights';
|
|
77
78
|
exports.ERR_AGENT_NOT_SUPPORTED = 'Starting agent is not supported';
|
|
78
79
|
exports.ERR_TUNNEL_ALREADY_EXISTS = 'Tunnel name exists: change or use -f to overwrite';
|
|
@@ -154,6 +155,23 @@ exports.TXT_TIMEOUT_SAVED = 'Timeout saved';
|
|
|
154
155
|
exports.TXT_REGION_SAVED = 'Region saved';
|
|
155
156
|
exports.TXT_TUNNEL_REMOVED = 'Tunnel removed';
|
|
156
157
|
exports.TXT_TUNNEL_ADDED = 'Tunnel added';
|
|
158
|
+
exports.TXT_AGENT_STANDALONE_PROC_CHECKING = 'Checking existing process...';
|
|
159
|
+
exports.TXT_AGENT_STANDALONE_PROC_CHECKED = 'Done';
|
|
160
|
+
exports.TXT_AGENT_STANDALONE_PROC_ERROR = 'Error';
|
|
161
|
+
exports.TXT_AGENT_STANDALONE_CONFIG_CHECKING = 'Checking existing configuration...';
|
|
162
|
+
exports.TXT_AGENT_STANDALONE_CONFIG_FOUND = 'Found';
|
|
163
|
+
exports.TXT_AGENT_STANDALONE_CONFIG_NOT_FOUND = 'Not found';
|
|
164
|
+
exports.TXT_AGENT_STANDALONE_AGENT_FETCHING = 'Fetching existing agent...';
|
|
165
|
+
exports.TXT_AGENT_STANDALONE_AGENT_FETCHED = 'Done';
|
|
166
|
+
exports.TXT_AGENT_STANDALONE_AGENT_FETCH_ERROR = 'Error';
|
|
167
|
+
exports.TXT_AGENT_STANDALONE_AGENT_REGISTERING = 'Registering agent...';
|
|
168
|
+
exports.TXT_AGENT_STANDALONE_AGENT_REGISTERED = 'Done';
|
|
169
|
+
exports.TXT_AGENT_STANDALONE_AGENT_REGISTER_ERROR = 'Error';
|
|
170
|
+
exports.TXT_AGENT_STANDALONE_STARTED = 'Agent process started...';
|
|
171
|
+
exports.TXT_AGENT_STANDALONE_STOPPED = 'Agent process stopped';
|
|
172
|
+
exports.TXT_AGENT_STANDALONE_EXITING = 'Process exiting. Agent configuration remains...';
|
|
173
|
+
const TXT_AGENT_STANDALONE_USING_AGENT = (id) => `Using passed agent (${id})`;
|
|
174
|
+
exports.TXT_AGENT_STANDALONE_USING_AGENT = TXT_AGENT_STANDALONE_USING_AGENT;
|
|
157
175
|
exports.NO_TUNNELS_STARTED = 'No tunnels started';
|
|
158
176
|
exports.AGENT_FETCH_RETRY = 'Agent fetch failed. Retrying in 3s...';
|
|
159
177
|
exports.DESC_COMMAND_CONFIG_ADD_HTTP = 'Add a new HTTP tunnel';
|
|
@@ -179,6 +197,8 @@ exports.DESC_COMMAND_AGENT_TUNNEL_STATUS = "Manage agent's tunnels";
|
|
|
179
197
|
exports.DESC_COMMAND_AGENT_TUNNEL_REMOVE = "Manage agent's tunnels";
|
|
180
198
|
exports.DESC_COMMAND_AGENT_UNINSTALL = 'Uninstall bdy service';
|
|
181
199
|
exports.DESC_COMMAND_AGENT_INSTALL = 'Install bdy as operating system service on Windows, OS X and Linux systems';
|
|
200
|
+
exports.DESC_COMMAND_AGENT_STANDALONE = 'Starts bdy agent as standalone process';
|
|
201
|
+
exports.DESC_COMMAND_AGENT_STANDALONE_KILL = 'Stops bdy agent standalone process';
|
|
182
202
|
exports.DESC_COMMAND_AGENT_START = 'Starts agent and all tunnels from configuration file';
|
|
183
203
|
exports.DESC_COMMAND_AGENT_DISABLE = 'Disable agent and all tunnels';
|
|
184
204
|
exports.DESC_COMMAND_AGENT_DEBUG = 'Turn on/off debug mode for agent';
|
|
@@ -220,7 +240,6 @@ exports.TXT_NEW_CLI_DOCKER_VERSION = TXT_NEW_CLI_DOCKER_VERSION;
|
|
|
220
240
|
const TXT_NEW_CLI_VERSION = (version) => `A new version of bdy is available! (${version})\n\n`;
|
|
221
241
|
exports.TXT_NEW_CLI_VERSION = TXT_NEW_CLI_VERSION;
|
|
222
242
|
exports.TXT_NEW_AGENT_VERSION = 'Agent upgrade required. Update the agent by running:\n`bdy agent update`\n\n';
|
|
223
|
-
exports.TXT_DISABLING_AGENT = 'Uninstalling agent...';
|
|
224
243
|
exports.TXT_ENABLING_AGENT = 'Installing agent...';
|
|
225
244
|
exports.TXT_UPDATING_AGENT = 'Updating agent...';
|
|
226
245
|
exports.TXT_OPENING_TUNNEL = 'Opening tunnel...';
|
|
@@ -319,11 +338,13 @@ exports.OPTION_SCRAPE_DARK_MODE = 'Dark mode';
|
|
|
319
338
|
exports.OPTION_SCRAPE_DELAY = 'Delay in milliseconds';
|
|
320
339
|
exports.OPTION_SCRAPE_OUTPUT_DIR = 'Output directory';
|
|
321
340
|
exports.LOG_REGISTERING_AGENT = 'Registering agent...';
|
|
322
|
-
exports.LOG_SAVING_AGENT_CONFIG = 'Saving agent config...';
|
|
323
341
|
exports.LOG_SAVING_AGENT_SYSTEM_CONFIG = 'Saving agent system config...';
|
|
342
|
+
exports.LOG_SAVING_AGENT_PROC_ID = 'Saving agent process id in lock file...';
|
|
343
|
+
exports.LOG_REMOVING_AGENT_PROC_ID = 'Removing agent process lock file...';
|
|
324
344
|
exports.LOG_SAVING_AGENT_LOCAL_CONFIG = 'Saving agent local config...';
|
|
325
|
-
exports.LOG_ERROR_SAVING_AGENT_CONFIG = 'Error while saving agent config';
|
|
326
345
|
exports.LOG_ERROR_SAVING_AGENT_SYSTEM_CONFIG = 'Error while saving agent system config';
|
|
346
|
+
exports.LOG_ERROR_SAVING_AGENT_STANDALONE_CONFIG = 'Error while saving process id in lock file';
|
|
347
|
+
exports.LOG_ERROR_REMOVING_AGENT_STANDALONE_LOCK_FILE = 'Error while removing process lock file';
|
|
327
348
|
exports.LOG_ERROR_SAVING_AGENT_LOCAL_CONFIG = 'Error while saving agent local config';
|
|
328
349
|
exports.LOG_AGENT_SYSTEM_DIR = 'Creating agent system directory...';
|
|
329
350
|
exports.LOG_AGENT_DOWNLOADING_ARCHIVE = 'Downloading agent archive...';
|
|
@@ -161,8 +161,14 @@ class ServerSsh extends events_1.default {
|
|
|
161
161
|
localExec(stream, command, env) {
|
|
162
162
|
const s = process.hrtime();
|
|
163
163
|
const opts = {};
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
opts.env = process.env || {};
|
|
165
|
+
if (env) {
|
|
166
|
+
Object.keys(env).forEach((key) => {
|
|
167
|
+
if (!opts.env)
|
|
168
|
+
opts.env = {};
|
|
169
|
+
opts.env[key] = env[key];
|
|
170
|
+
});
|
|
171
|
+
}
|
|
166
172
|
if ((0, utils_1.isWindows)()) {
|
|
167
173
|
opts.shell = 'powershell.exe';
|
|
168
174
|
if (!opts.env)
|
|
@@ -172,6 +178,8 @@ class ServerSsh extends events_1.default {
|
|
|
172
178
|
else
|
|
173
179
|
opts.env.PATH = `${process.env.PATH};C:\\Windows\\System32\\WindowsPowerShell\\v1.0`;
|
|
174
180
|
}
|
|
181
|
+
logger_1.default.info(command);
|
|
182
|
+
logger_1.default.info(opts);
|
|
175
183
|
(0, child_process_1.exec)(command, opts, (err, stdout, stderr) => {
|
|
176
184
|
if (stream) {
|
|
177
185
|
stream.stderr.write(stderr);
|