bdy 1.17.24-dev → 1.17.26-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 +2 -1
- package/distTs/src/agent/agent.js +59 -21
- package/distTs/src/agent/manager.js +100 -8
- package/distTs/src/command/agent/install.js +6 -2
- package/distTs/src/command/agent/proxy/disable.js +27 -0
- package/distTs/src/command/agent/proxy/enable.js +27 -0
- package/distTs/src/command/agent/proxy/status.js +32 -0
- package/distTs/src/command/agent/proxy.js +15 -0
- package/distTs/src/command/agent/status.js +19 -5
- package/distTs/src/command/agent/tunnel/disable.js +27 -0
- package/distTs/src/command/agent/tunnel/enable.js +27 -0
- package/distTs/src/command/agent/tunnel/status.js +11 -1
- package/distTs/src/command/agent/tunnel.js +4 -0
- package/distTs/src/command/agent.js +2 -0
- package/distTs/src/command/login.js +3 -0
- package/distTs/src/command/project/link.js +2 -7
- package/distTs/src/command/tunnel/http.js +1 -1
- package/distTs/src/command/tunnel/start.js +1 -1
- package/distTs/src/command/tunnel/tcp.js +1 -1
- package/distTs/src/command/tunnel/tls.js +1 -1
- package/distTs/src/output.js +118 -89
- package/distTs/src/texts.js +30 -13
- package/distTs/src/tunnel/api/agent.js +18 -0
- package/distTs/src/tunnel/api/buddy.js +35 -3
- package/package.json +2 -1
package/distTs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.17.
|
|
4
|
+
"version": "1.17.26-dev",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@scalar/types": "0.5.10",
|
|
48
48
|
"@scalar/openapi-types": "0.5.3",
|
|
49
49
|
"fastify": "4.29.1",
|
|
50
|
+
"@inquirer/prompts": "8.2.0",
|
|
50
51
|
"fdir": "6.5.0",
|
|
51
52
|
"open": "11.0.0",
|
|
52
53
|
"fflate": "0.8.2",
|
|
@@ -17,6 +17,8 @@ class Agent extends events_1.default {
|
|
|
17
17
|
token;
|
|
18
18
|
service;
|
|
19
19
|
target;
|
|
20
|
+
tunneling;
|
|
21
|
+
proxy;
|
|
20
22
|
disabled;
|
|
21
23
|
tunnels;
|
|
22
24
|
tags;
|
|
@@ -25,13 +27,15 @@ class Agent extends events_1.default {
|
|
|
25
27
|
socket;
|
|
26
28
|
manager;
|
|
27
29
|
onRefresh;
|
|
28
|
-
constructor(id, host, token, service, target, tags, api, disabled) {
|
|
30
|
+
constructor(id, host, token, service, target, tunneling, proxy, tags, api, disabled) {
|
|
29
31
|
super();
|
|
30
32
|
this.id = id;
|
|
31
33
|
this.host = host;
|
|
32
34
|
this.token = token;
|
|
33
35
|
this.service = service;
|
|
34
36
|
this.target = target;
|
|
37
|
+
this.tunneling = tunneling;
|
|
38
|
+
this.proxy = proxy;
|
|
35
39
|
this.disabled = disabled;
|
|
36
40
|
this.tunnels = [];
|
|
37
41
|
this.tags = tags || [];
|
|
@@ -80,14 +84,29 @@ class Agent extends events_1.default {
|
|
|
80
84
|
output_1.default.exitError(texts_1.ERR_AGENT_REMOVED);
|
|
81
85
|
}
|
|
82
86
|
else {
|
|
83
|
-
const
|
|
84
|
-
|
|
87
|
+
const hasTunneling = typeof (data.tunneling) === 'boolean';
|
|
88
|
+
const hasProxy = typeof (data.proxy) === 'boolean';
|
|
89
|
+
let shouldFetch = false;
|
|
90
|
+
if (this.target !== data.target) {
|
|
91
|
+
shouldFetch = true;
|
|
92
|
+
this.target = !!data.target;
|
|
93
|
+
}
|
|
94
|
+
if (hasTunneling && this.tunneling !== data.tunneling) {
|
|
95
|
+
shouldFetch = true;
|
|
96
|
+
this.tunneling = data.tunneling;
|
|
97
|
+
}
|
|
98
|
+
if (hasProxy && this.proxy !== data.proxy) {
|
|
99
|
+
shouldFetch = true;
|
|
100
|
+
this.proxy = data.proxy;
|
|
101
|
+
}
|
|
102
|
+
if (shouldFetch)
|
|
103
|
+
this.startStopTunnels();
|
|
85
104
|
this.tags = data.tags || [];
|
|
86
105
|
if (!!data.disabled !== this.disabled) {
|
|
87
106
|
if (data.disabled)
|
|
88
|
-
|
|
107
|
+
this.disable();
|
|
89
108
|
else
|
|
90
|
-
|
|
109
|
+
this.enable();
|
|
91
110
|
}
|
|
92
111
|
if (data.action) {
|
|
93
112
|
try {
|
|
@@ -142,37 +161,49 @@ class Agent extends events_1.default {
|
|
|
142
161
|
this.refreshIn15();
|
|
143
162
|
}
|
|
144
163
|
async start() {
|
|
145
|
-
|
|
146
|
-
this.
|
|
164
|
+
this.tunnels.forEach((t) => {
|
|
165
|
+
if (this.canStartTunnel(t))
|
|
147
166
|
t.start();
|
|
148
|
-
|
|
149
|
-
}
|
|
167
|
+
});
|
|
150
168
|
if (this.socket) {
|
|
151
169
|
this.socket.fetch(!this.disabled, '', null, true, this.getTunnelsUpdate(), true);
|
|
152
170
|
}
|
|
153
171
|
}
|
|
154
|
-
|
|
155
|
-
this.disabled = false;
|
|
172
|
+
startStopTunnels(activate = null, disabled = null, resetFirstHeard = false) {
|
|
156
173
|
this.tunnels.forEach((t) => {
|
|
157
|
-
|
|
174
|
+
if (this.canStartTunnel(t))
|
|
175
|
+
t.start();
|
|
176
|
+
else
|
|
177
|
+
t.stop();
|
|
158
178
|
});
|
|
159
179
|
if (this.socket) {
|
|
160
|
-
this.socket.fetch(
|
|
180
|
+
this.socket.fetch(activate, '', disabled, resetFirstHeard, this.getTunnelsUpdate(), true);
|
|
161
181
|
}
|
|
162
182
|
}
|
|
183
|
+
enable() {
|
|
184
|
+
this.disabled = false;
|
|
185
|
+
this.startStopTunnels(true, false, true);
|
|
186
|
+
}
|
|
163
187
|
async markInactive() {
|
|
164
188
|
if (this.socket) {
|
|
165
189
|
this.socket.fetch(false, '', null, false, this.getTunnelsUpdate(true), true);
|
|
166
190
|
}
|
|
167
191
|
}
|
|
168
|
-
|
|
192
|
+
changeTarget(val) {
|
|
193
|
+
this.target = val;
|
|
194
|
+
this.startStopTunnels();
|
|
195
|
+
}
|
|
196
|
+
changeProxy(val) {
|
|
197
|
+
this.proxy = val;
|
|
198
|
+
this.startStopTunnels();
|
|
199
|
+
}
|
|
200
|
+
changeTunneling(val) {
|
|
201
|
+
this.tunneling = val;
|
|
202
|
+
this.startStopTunnels();
|
|
203
|
+
}
|
|
204
|
+
disable() {
|
|
169
205
|
this.disabled = true;
|
|
170
|
-
this.
|
|
171
|
-
t.stop();
|
|
172
|
-
});
|
|
173
|
-
if (this.socket) {
|
|
174
|
-
this.socket.fetch(!this.disabled, '', this.disabled, false, this.getTunnelsUpdate(), true);
|
|
175
|
-
}
|
|
206
|
+
this.startStopTunnels(false, true);
|
|
176
207
|
}
|
|
177
208
|
async delete() {
|
|
178
209
|
try {
|
|
@@ -277,9 +308,16 @@ class Agent extends events_1.default {
|
|
|
277
308
|
});
|
|
278
309
|
return update;
|
|
279
310
|
}
|
|
311
|
+
canStartTunnel(tunnel) {
|
|
312
|
+
if (this.disabled)
|
|
313
|
+
return false;
|
|
314
|
+
if (!this.proxy && !this.target && tunnel.type === tunnel_2.TUNNEL_TYPE.SSH)
|
|
315
|
+
return false;
|
|
316
|
+
return !(!this.tunneling && tunnel.type !== tunnel_2.TUNNEL_TYPE.SSH);
|
|
317
|
+
}
|
|
280
318
|
addTunnel(tunnel) {
|
|
281
319
|
this.tunnels.push(tunnel);
|
|
282
|
-
if (
|
|
320
|
+
if (this.canStartTunnel(tunnel))
|
|
283
321
|
tunnel.start();
|
|
284
322
|
tunnel.on(tunnel_2.TUNNEL_EVENT.OPEN, () => this.update(true));
|
|
285
323
|
tunnel.on(tunnel_2.TUNNEL_EVENT.CLOSED, () => this.update());
|
|
@@ -142,6 +142,24 @@ class AgentManagerClass {
|
|
|
142
142
|
target: this.agent.target,
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
+
async processAgentTunneling(res) {
|
|
146
|
+
if (!this.agent) {
|
|
147
|
+
this.serverError(res, 'Agent not enabled');
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this.serverOutput(res, {
|
|
151
|
+
tunneling: this.agent.tunneling,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
async processAgentProxy(res) {
|
|
155
|
+
if (!this.agent) {
|
|
156
|
+
this.serverError(res, 'Agent not enabled');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
this.serverOutput(res, {
|
|
160
|
+
proxy: this.agent.proxy,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
145
163
|
async processAgentTargetEnable(res) {
|
|
146
164
|
if (!this.agent) {
|
|
147
165
|
this.serverError(res, 'Agent not enabled');
|
|
@@ -149,7 +167,37 @@ class AgentManagerClass {
|
|
|
149
167
|
}
|
|
150
168
|
try {
|
|
151
169
|
await buddy_1.default.enableTarget(this.id || '', this.host || '', this.token || '');
|
|
152
|
-
this.agent.
|
|
170
|
+
this.agent.changeTarget(true);
|
|
171
|
+
}
|
|
172
|
+
catch (err) {
|
|
173
|
+
this.serverError(res, err.message);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.serverOutput(res, {});
|
|
177
|
+
}
|
|
178
|
+
async processAgentTunnelingEnable(res) {
|
|
179
|
+
if (!this.agent) {
|
|
180
|
+
this.serverError(res, 'Agent not enabled');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
await buddy_1.default.enableTunneling(this.id || '', this.host || '', this.token || '');
|
|
185
|
+
this.agent.changeTunneling(true);
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
this.serverError(res, err.message);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.serverOutput(res, {});
|
|
192
|
+
}
|
|
193
|
+
async processAgentProxyEnable(res) {
|
|
194
|
+
if (!this.agent) {
|
|
195
|
+
this.serverError(res, 'Agent not enabled');
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
await buddy_1.default.enableProxy(this.id || '', this.host || '', this.token || '');
|
|
200
|
+
this.agent.changeProxy(true);
|
|
153
201
|
}
|
|
154
202
|
catch (err) {
|
|
155
203
|
this.serverError(res, err.message);
|
|
@@ -164,7 +212,37 @@ class AgentManagerClass {
|
|
|
164
212
|
}
|
|
165
213
|
try {
|
|
166
214
|
await buddy_1.default.disableTarget(this.id || '', this.host || '', this.token || '');
|
|
167
|
-
this.agent.
|
|
215
|
+
this.agent.changeTarget(false);
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
this.serverError(res, err.message);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
this.serverOutput(res, {});
|
|
222
|
+
}
|
|
223
|
+
async processAgentTunnelingDisable(res) {
|
|
224
|
+
if (!this.agent) {
|
|
225
|
+
this.serverError(res, 'Agent not enabled');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
await buddy_1.default.disableTunneling(this.id || '', this.host || '', this.token || '');
|
|
230
|
+
this.agent.changeTunneling(false);
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
this.serverError(res, err.message);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this.serverOutput(res, {});
|
|
237
|
+
}
|
|
238
|
+
async processAgentProxyDisable(res) {
|
|
239
|
+
if (!this.agent) {
|
|
240
|
+
this.serverError(res, 'Agent not enabled');
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
await buddy_1.default.disableProxy(this.id || '', this.host || '', this.token || '');
|
|
245
|
+
this.agent.changeProxy(false);
|
|
168
246
|
}
|
|
169
247
|
catch (err) {
|
|
170
248
|
this.serverError(res, err.message);
|
|
@@ -178,7 +256,9 @@ class AgentManagerClass {
|
|
|
178
256
|
status: this.status,
|
|
179
257
|
version: (0, utils_1.getVersion)(),
|
|
180
258
|
enabled: !this.agent?.disabled,
|
|
181
|
-
target: !!this.agent?.target
|
|
259
|
+
target: !!this.agent?.target,
|
|
260
|
+
tunneling: !!this.agent?.tunneling,
|
|
261
|
+
proxy: !!this.agent?.proxy
|
|
182
262
|
});
|
|
183
263
|
}
|
|
184
264
|
processBody(req) {
|
|
@@ -302,16 +382,16 @@ class AgentManagerClass {
|
|
|
302
382
|
}
|
|
303
383
|
output_1.default.exitError(txt);
|
|
304
384
|
}
|
|
305
|
-
|
|
385
|
+
agentDisable() {
|
|
306
386
|
if (!this.agent)
|
|
307
387
|
return false;
|
|
308
|
-
|
|
388
|
+
this.agent.disable();
|
|
309
389
|
return true;
|
|
310
390
|
}
|
|
311
|
-
|
|
391
|
+
agentEnable() {
|
|
312
392
|
if (!this.agent)
|
|
313
393
|
return false;
|
|
314
|
-
|
|
394
|
+
this.agent.enable();
|
|
315
395
|
return true;
|
|
316
396
|
}
|
|
317
397
|
async processAgentEnable(res) {
|
|
@@ -343,7 +423,7 @@ class AgentManagerClass {
|
|
|
343
423
|
this.serverError(res, 'Agent not enabled');
|
|
344
424
|
return;
|
|
345
425
|
}
|
|
346
|
-
const saved =
|
|
426
|
+
const saved = this.agentDisable();
|
|
347
427
|
if (!saved) {
|
|
348
428
|
this.serverError(res, 'Something went wrong');
|
|
349
429
|
return;
|
|
@@ -385,6 +465,10 @@ class AgentManagerClass {
|
|
|
385
465
|
return this.processStatus(res);
|
|
386
466
|
if (req.url === '/target')
|
|
387
467
|
return this.processAgentTarget(res);
|
|
468
|
+
if (req.url === '/tunneling')
|
|
469
|
+
return this.processAgentTunneling(res);
|
|
470
|
+
if (req.url === '/proxy')
|
|
471
|
+
return this.processAgentProxy(res);
|
|
388
472
|
if (req.url === '/agent/tags')
|
|
389
473
|
return this.processAgentTags(res);
|
|
390
474
|
if (req.url === '/agent/tags/set')
|
|
@@ -393,6 +477,14 @@ class AgentManagerClass {
|
|
|
393
477
|
return this.processAgentTargetEnable(res);
|
|
394
478
|
if (req.url === '/target/disable')
|
|
395
479
|
return this.processAgentTargetDisable(res);
|
|
480
|
+
if (req.url === '/tunneling/enable')
|
|
481
|
+
return this.processAgentTunnelingEnable(res);
|
|
482
|
+
if (req.url === '/tunneling/disable')
|
|
483
|
+
return this.processAgentTunnelingDisable(res);
|
|
484
|
+
if (req.url === '/proxy/enable')
|
|
485
|
+
return this.processAgentProxyEnable(res);
|
|
486
|
+
if (req.url === '/proxy/disable')
|
|
487
|
+
return this.processAgentProxyDisable(res);
|
|
396
488
|
if (req.url === '/tunnels')
|
|
397
489
|
return this.processTunnels(res);
|
|
398
490
|
if (req.url === '/tunnel/add')
|
|
@@ -75,6 +75,8 @@ const installService = async (options) => {
|
|
|
75
75
|
const { token, host } = await input_1.default.tunnelToken(addToken);
|
|
76
76
|
const port = input_1.default.port(options.port);
|
|
77
77
|
const target = !!options.target;
|
|
78
|
+
const tunneling = !!options.tunneling;
|
|
79
|
+
const proxy = !!options.proxy;
|
|
78
80
|
let agent;
|
|
79
81
|
if (id) {
|
|
80
82
|
try {
|
|
@@ -86,7 +88,7 @@ const installService = async (options) => {
|
|
|
86
88
|
}
|
|
87
89
|
if (!agent) {
|
|
88
90
|
const tags = prepareTags(options.tag);
|
|
89
|
-
agent = await buddy_1.default.register(true, target, host, token, tags, (region) => {
|
|
91
|
+
agent = await buddy_1.default.register(true, target, tunneling, proxy, host, token, tags, (region) => {
|
|
90
92
|
cfg_1.default.setRegionIfNotSet(region);
|
|
91
93
|
});
|
|
92
94
|
id = agent.id;
|
|
@@ -153,7 +155,7 @@ const installApp = async (options) => {
|
|
|
153
155
|
const tags = prepareTags(options.tag);
|
|
154
156
|
try {
|
|
155
157
|
output_1.default.normal(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERING, false);
|
|
156
|
-
const agent = await buddy_1.default.register(true, !!options.target, host, token, tags, (region) => {
|
|
158
|
+
const agent = await buddy_1.default.register(true, !!options.target, !!options.tunneling, !!options.proxy, host, token, tags, (region) => {
|
|
157
159
|
cfg_1.default.setRegionIfNotSet(region);
|
|
158
160
|
});
|
|
159
161
|
logger_1.default.info(texts_1.TXT_AGENT_STANDALONE_AGENT_REGISTERED);
|
|
@@ -211,6 +213,8 @@ commandAgentInstall.option('-u, --user <user>', texts_1.OPTION_USER);
|
|
|
211
213
|
commandAgentInstall.option('-a,--app', texts_1.OPTION_APP);
|
|
212
214
|
commandAgentInstall.option('--pass <password>', texts_1.OPTION_PASS);
|
|
213
215
|
commandAgentInstall.option('--target', texts_1.OPTION_AGENT_TARGET);
|
|
216
|
+
commandAgentInstall.option('--proxy', texts_1.OPTION_AGENT_PROXY);
|
|
217
|
+
commandAgentInstall.option('--tunneling', texts_1.OPTION_AGENT_TUNNELING, true);
|
|
214
218
|
commandAgentInstall.option('--tag <tag...>', texts_1.OPTION_AGENT_TAG);
|
|
215
219
|
commandAgentInstall.option('-d, --debug', texts_1.OPTION_AGENT_DEBUG);
|
|
216
220
|
commandAgentInstall.action(async (options) => {
|
|
@@ -0,0 +1,27 @@
|
|
|
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 output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentProxyDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_PROXY_DISABLE);
|
|
11
|
+
commandAgentProxyDisable.action(async () => {
|
|
12
|
+
if (!commandAgentProxyDisable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentProxyDisable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentProxyDisable.agentPort || 0);
|
|
20
|
+
await api.disableAgentProxy();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_PROXY_DISABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentProxyDisable;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentProxyEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_PROXY_ENABLE);
|
|
11
|
+
commandAgentProxyEnable.action(async () => {
|
|
12
|
+
if (!commandAgentProxyEnable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentProxyEnable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentProxyEnable.agentPort || 0);
|
|
20
|
+
await api.enableAgentProxy();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_TARGET_ENABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentProxyEnable;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentProxyStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_PROXY_STATUS);
|
|
11
|
+
commandAgentProxyStatus.action(async () => {
|
|
12
|
+
if (!commandAgentProxyStatus.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentProxyStatus.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentProxyStatus.agentPort || 0);
|
|
20
|
+
const data = await api.fetchAgentProxy();
|
|
21
|
+
if (data.proxy) {
|
|
22
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_PROXY_ENABLED);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
output_1.default.exitError(texts_1.TXT_AGENT_PROXY_DISABLED);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
output_1.default.exitError(err);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
exports.default = commandAgentProxyStatus;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 status_1 = __importDefault(require("./proxy/status"));
|
|
9
|
+
const disable_1 = __importDefault(require("./proxy/disable"));
|
|
10
|
+
const enable_1 = __importDefault(require("./proxy/enable"));
|
|
11
|
+
const commandAgentProxy = (0, utils_1.newCommand)('proxy', texts_1.DESC_COMMAND_AGENT_PROXY);
|
|
12
|
+
commandAgentProxy.addCommand(status_1.default);
|
|
13
|
+
commandAgentProxy.addCommand(enable_1.default);
|
|
14
|
+
commandAgentProxy.addCommand(disable_1.default);
|
|
15
|
+
exports.default = commandAgentProxy;
|
|
@@ -8,7 +8,7 @@ const texts_1 = require("../../texts");
|
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
9
|
const tunnel_1 = require("../../types/tunnel");
|
|
10
10
|
const commandAgentStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_STATUS);
|
|
11
|
-
const outputStatus = (installed, standalone, version, id, running, enabled, target, status) => {
|
|
11
|
+
const outputStatus = (installed, standalone, version, id, running, enabled, target, tunneling, proxy, status) => {
|
|
12
12
|
if (!installed) {
|
|
13
13
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
14
|
}
|
|
@@ -29,9 +29,19 @@ const outputStatus = (installed, standalone, version, id, running, enabled, targ
|
|
|
29
29
|
output_1.default.normal(', ', false);
|
|
30
30
|
if (enabled) {
|
|
31
31
|
output_1.default.green('enabled');
|
|
32
|
-
let msg = 'Enabled:
|
|
33
|
-
if (target)
|
|
34
|
-
msg += '
|
|
32
|
+
let msg = 'Enabled: ';
|
|
33
|
+
if (!target && !tunneling && !proxy)
|
|
34
|
+
msg += 'Nothing';
|
|
35
|
+
else {
|
|
36
|
+
const opts = [];
|
|
37
|
+
if (tunneling)
|
|
38
|
+
opts.push('Tunnels');
|
|
39
|
+
if (target)
|
|
40
|
+
opts.push('Target');
|
|
41
|
+
if (proxy)
|
|
42
|
+
opts.push('Proxy for targets');
|
|
43
|
+
msg += opts.join(', ');
|
|
44
|
+
}
|
|
35
45
|
output_1.default.normal(msg);
|
|
36
46
|
}
|
|
37
47
|
else {
|
|
@@ -49,13 +59,17 @@ commandAgentStatus.action(async () => {
|
|
|
49
59
|
const running = !!commandAgentStatus.agentStatus;
|
|
50
60
|
let enabled = true;
|
|
51
61
|
let target = false;
|
|
62
|
+
let tunneling = true;
|
|
63
|
+
let proxy = false;
|
|
52
64
|
let status = tunnel_1.TUNNEL_AGENT_STATUS.DISABLED;
|
|
53
65
|
if (commandAgentStatus.agentStatus) {
|
|
54
66
|
version = commandAgentStatus.agentStatus.version;
|
|
55
67
|
enabled = commandAgentStatus.agentStatus.enabled;
|
|
56
68
|
status = commandAgentStatus.agentStatus.status;
|
|
57
69
|
target = commandAgentStatus.agentStatus.target;
|
|
70
|
+
tunneling = commandAgentStatus.agentStatus.tunneling;
|
|
71
|
+
proxy = commandAgentStatus.agentStatus.proxy;
|
|
58
72
|
}
|
|
59
|
-
outputStatus(!!commandAgentStatus.agentInstalled, !!commandAgentStatus.agentStandalone, version, id, running, enabled, target, status);
|
|
73
|
+
outputStatus(!!commandAgentStatus.agentInstalled, !!commandAgentStatus.agentStandalone, version, id, running, enabled, target, tunneling, proxy, status);
|
|
60
74
|
});
|
|
61
75
|
exports.default = commandAgentStatus;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentTunnelDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_TUNNELING_DISABLE);
|
|
11
|
+
commandAgentTunnelDisable.action(async () => {
|
|
12
|
+
if (!commandAgentTunnelDisable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTunnelDisable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentTunnelDisable.agentPort || 0);
|
|
20
|
+
await api.disableAgentTunneling();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_TUNNELING_DISABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentTunnelDisable;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
+
const commandAgentTunnelEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_TUNNELING_ENABLE);
|
|
11
|
+
commandAgentTunnelEnable.action(async () => {
|
|
12
|
+
if (!commandAgentTunnelEnable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTunnelEnable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const api = new agent_1.default(commandAgentTunnelEnable.agentPort || 0);
|
|
20
|
+
await api.enableAgentTunneling();
|
|
21
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_TUNNELING_ENABLED);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
output_1.default.exitError(err);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.default = commandAgentTunnelEnable;
|
|
@@ -10,7 +10,7 @@ const tunnel_1 = __importDefault(require("../../../agent/socket/tunnel"));
|
|
|
10
10
|
const utils_1 = require("../../../utils");
|
|
11
11
|
const commandAgentTunnelStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TUNNEL_STATUS);
|
|
12
12
|
commandAgentTunnelStatus.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_AGENT_TUNNEL_STATUS}`);
|
|
13
|
-
commandAgentTunnelStatus.argument('
|
|
13
|
+
commandAgentTunnelStatus.argument('[id]', texts_1.OPTION_ID);
|
|
14
14
|
commandAgentTunnelStatus.action(async (id) => {
|
|
15
15
|
if (!commandAgentTunnelStatus.agentInstalled) {
|
|
16
16
|
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
@@ -20,6 +20,16 @@ commandAgentTunnelStatus.action(async (id) => {
|
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
22
|
const api = new agent_1.default(commandAgentTunnelStatus.agentPort || 0);
|
|
23
|
+
if (!id) {
|
|
24
|
+
const data = await api.fetchAgentTunneling();
|
|
25
|
+
if (data.tunneling) {
|
|
26
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_TUNNELING_ENABLED);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
output_1.default.exitError(texts_1.TXT_AGENT_TUNNELING_DISABLED);
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
23
33
|
const ws = await api.socketTunnel(id);
|
|
24
34
|
const tunnel = new tunnel_1.default(ws, id);
|
|
25
35
|
await tunnel.waitForReady();
|
|
@@ -12,6 +12,8 @@ const start_1 = __importDefault(require("./tunnel/start"));
|
|
|
12
12
|
const texts_1 = require("../../texts");
|
|
13
13
|
const status_1 = __importDefault(require("./tunnel/status"));
|
|
14
14
|
const utils_1 = require("../../utils");
|
|
15
|
+
const enable_1 = __importDefault(require("./tunnel/enable"));
|
|
16
|
+
const disable_1 = __importDefault(require("./tunnel/disable"));
|
|
15
17
|
const commandAgentTunnel = (0, utils_1.newCommand)('tunnel', texts_1.DESC_COMMAND_AGENT_TUNNEL);
|
|
16
18
|
commandAgentTunnel.addCommand(tcp_1.default);
|
|
17
19
|
commandAgentTunnel.addCommand(tls_1.default);
|
|
@@ -20,6 +22,8 @@ commandAgentTunnel.addCommand(start_1.default);
|
|
|
20
22
|
commandAgentTunnel.addCommand(remove_1.default);
|
|
21
23
|
commandAgentTunnel.addCommand(list_1.default);
|
|
22
24
|
commandAgentTunnel.addCommand(status_1.default);
|
|
25
|
+
commandAgentTunnel.addCommand(enable_1.default);
|
|
26
|
+
commandAgentTunnel.addCommand(disable_1.default);
|
|
23
27
|
commandAgentTunnel.addHelpText('after', `\nEXAMPLES:${(0, texts_1.EXAMPLE_TUNNEL_HTTP)(true)}
|
|
24
28
|
${(0, texts_1.EXAMPLE_TUNNEL_TLS)(true)}
|
|
25
29
|
${(0, texts_1.EXAMPLE_TUNNEL_TCP)(true)}
|
|
@@ -20,6 +20,7 @@ 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
22
|
const tags_1 = __importDefault(require("./agent/tags"));
|
|
23
|
+
const proxy_1 = __importDefault(require("./agent/proxy"));
|
|
23
24
|
const commandAgent = (0, utils_1.newCommand)('agent', texts_1.DESC_COMMAND_AGENT);
|
|
24
25
|
commandAgent.addCommand(install_1.default);
|
|
25
26
|
commandAgent.addCommand(enable_1.default);
|
|
@@ -31,6 +32,7 @@ commandAgent.addCommand(uninstall_1.default);
|
|
|
31
32
|
commandAgent.addCommand(status_1.default);
|
|
32
33
|
commandAgent.addCommand(tunnel_1.default);
|
|
33
34
|
commandAgent.addCommand(target_1.default);
|
|
35
|
+
commandAgent.addCommand(proxy_1.default);
|
|
34
36
|
commandAgent.addCommand(tags_1.default);
|
|
35
37
|
commandAgent.addCommand(update_1.default);
|
|
36
38
|
commandAgent.addCommand(version_1.default);
|
|
@@ -169,6 +169,9 @@ commandLogin.action(async (options) => {
|
|
|
169
169
|
}
|
|
170
170
|
cfg_1.default.setBaseUrl(api);
|
|
171
171
|
if (!token) {
|
|
172
|
+
if (!output_1.default.isStdInTTY()) {
|
|
173
|
+
output_1.default.exitError(texts_1.ERR_TOKEN_NOT_PROVIDED);
|
|
174
|
+
}
|
|
172
175
|
output_1.default.normal(texts_1.TXT_LOGIN_OAUTH);
|
|
173
176
|
const { token, refreshToken, clientId, clientSecret, clientToken } = await authorizeOAuth(api);
|
|
174
177
|
await authorizeToken(api, token, refreshToken, clientId, clientSecret, clientToken, workspace);
|