bdy 1.15.6 → 1.16.0-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/agent.js +28 -56
- package/distTs/src/agent/linux.js +22 -23
- package/distTs/src/agent/manager.js +12 -105
- package/distTs/src/agent/osx.js +22 -27
- package/distTs/src/agent/socket/client.js +4 -4
- package/distTs/src/agent/system.js +89 -21
- package/distTs/src/agent/windows.js +21 -32
- package/distTs/src/command/agent/debug.js +10 -3
- package/distTs/src/command/agent/disable.js +6 -6
- package/distTs/src/command/agent/enable.js +6 -6
- package/distTs/src/command/agent/install.js +106 -27
- package/distTs/src/command/agent/restart.js +21 -11
- package/distTs/src/command/agent/run.js +1 -1
- package/distTs/src/command/agent/start.js +19 -12
- package/distTs/src/command/agent/status.js +44 -17
- package/distTs/src/command/agent/stop.js +20 -13
- package/distTs/src/command/agent/target/disable.js +6 -6
- package/distTs/src/command/agent/target/enable.js +6 -6
- package/distTs/src/command/agent/target/status.js +6 -6
- package/distTs/src/command/agent/tunnel/http.js +6 -6
- package/distTs/src/command/agent/tunnel/list.js +6 -6
- package/distTs/src/command/agent/tunnel/remove.js +6 -6
- package/distTs/src/command/agent/tunnel/start.js +7 -7
- package/distTs/src/command/agent/tunnel/status.js +6 -6
- package/distTs/src/command/agent/tunnel/tcp.js +6 -6
- package/distTs/src/command/agent/tunnel/tls.js +6 -6
- package/distTs/src/command/agent/uninstall.js +2 -2
- package/distTs/src/command/agent/update.js +19 -17
- package/distTs/src/command/agent/version.js +3 -5
- package/distTs/src/command/agent.js +0 -4
- package/distTs/src/command/pre.js +10 -2
- package/distTs/src/output.js +16 -4
- package/distTs/src/texts.js +17 -34
- package/distTs/src/tunnel/api/agent.js +0 -9
- package/distTs/src/types/tunnel.js +0 -3
- package/package.json +1 -1
|
@@ -6,29 +6,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const output_1 = __importDefault(require("../../output"));
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
|
-
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
10
9
|
const tunnel_1 = require("../../types/tunnel");
|
|
11
10
|
const commandAgentStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_STATUS);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
output_1.default.exitError(texts_1.ERR_AGENT_NOT_ENABLED);
|
|
16
|
-
}
|
|
17
|
-
if (!commandAgentStatus.agentStatus) {
|
|
18
|
-
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
11
|
+
const outputStatus = (installed, standalone, version, id, running, enabled, target, status) => {
|
|
12
|
+
if (!installed) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
let txt = 'Installation: ';
|
|
16
|
+
if (standalone)
|
|
17
|
+
txt += 'App @ ';
|
|
18
|
+
else
|
|
19
|
+
txt += 'Service @ ';
|
|
20
|
+
if (version)
|
|
21
|
+
txt += `${version} / `;
|
|
22
|
+
txt += `${id}`;
|
|
23
|
+
output_1.default.normal(txt);
|
|
24
|
+
output_1.default.normal('Status: ', false);
|
|
25
|
+
if (running)
|
|
26
|
+
output_1.default.green('Running', false);
|
|
27
|
+
else
|
|
28
|
+
output_1.default.error('Stopped', false);
|
|
29
|
+
output_1.default.normal(', ', false);
|
|
30
|
+
if (enabled) {
|
|
31
|
+
output_1.default.green('enabled');
|
|
32
|
+
let msg = 'Enabled: Tunnels';
|
|
33
|
+
if (target)
|
|
34
|
+
msg += ', Target, Proxy for targets';
|
|
35
|
+
output_1.default.normal(msg);
|
|
22
36
|
}
|
|
23
|
-
|
|
24
|
-
output_1.default.
|
|
37
|
+
else {
|
|
38
|
+
output_1.default.error('disabled');
|
|
25
39
|
}
|
|
26
|
-
if (
|
|
27
|
-
output_1.default.
|
|
40
|
+
if (status === tunnel_1.TUNNEL_AGENT_STATUS.FETCH_FAILED) {
|
|
41
|
+
output_1.default.normal('Problems: ');
|
|
42
|
+
output_1.default.error(status);
|
|
28
43
|
}
|
|
29
|
-
|
|
30
|
-
|
|
44
|
+
process.exit(0);
|
|
45
|
+
};
|
|
46
|
+
commandAgentStatus.action(async () => {
|
|
47
|
+
let version = '';
|
|
48
|
+
const id = commandAgentStatus.agentId;
|
|
49
|
+
const running = !!commandAgentStatus.agentStatus;
|
|
50
|
+
let enabled = true;
|
|
51
|
+
let target = false;
|
|
52
|
+
let status = tunnel_1.TUNNEL_AGENT_STATUS.DISABLED;
|
|
53
|
+
if (commandAgentStatus.agentStatus) {
|
|
54
|
+
version = commandAgentStatus.agentStatus.version;
|
|
55
|
+
enabled = commandAgentStatus.agentStatus.enabled;
|
|
56
|
+
status = commandAgentStatus.agentStatus.status;
|
|
57
|
+
target = commandAgentStatus.agentStatus.target;
|
|
31
58
|
}
|
|
32
|
-
|
|
59
|
+
outputStatus(!!commandAgentStatus.agentInstalled, !!commandAgentStatus.agentStandalone, version, id, running, enabled, target, status);
|
|
33
60
|
});
|
|
34
61
|
exports.default = commandAgentStatus;
|
|
@@ -6,23 +6,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const manager_1 = __importDefault(require("../../agent/manager"));
|
|
9
|
-
const agent_1 = __importDefault(require("../../tunnel/api/agent"));
|
|
10
|
-
const texts_2 = require("../../texts");
|
|
11
9
|
const output_1 = __importDefault(require("../../output"));
|
|
12
|
-
const
|
|
10
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
11
|
+
const commandAgentStop = (0, utils_1.newCommand)('stop', texts_1.DESC_COMMAND_AGENT_STOP);
|
|
13
12
|
commandAgentStop.action(async () => {
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
output_1.default.exitError(texts_1.
|
|
13
|
+
const hasAdminRights = await manager_1.default.system.hasAdminRights();
|
|
14
|
+
if (!hasAdminRights) {
|
|
15
|
+
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const api = new agent_1.default(json.port);
|
|
21
|
-
await api.stopAgent();
|
|
22
|
-
output_1.default.exitSuccess(texts_2.TXT_AGENT_STOPPED);
|
|
17
|
+
if (!commandAgentStop.agentInstalled) {
|
|
18
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (commandAgentStop.agentStandalone) {
|
|
21
|
+
await manager_1.default.system.killStandaloneProc();
|
|
22
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_STOPPED);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
try {
|
|
26
|
+
await manager_1.default.system.stop();
|
|
27
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_STOPPED);
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
logger_1.default.error(err);
|
|
31
|
+
output_1.default.exitError(err);
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
34
|
});
|
|
28
35
|
exports.default = commandAgentStop;
|
|
@@ -5,18 +5,18 @@ 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 agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
11
10
|
const commandAgentTargetDisable = (0, utils_1.newCommand)('disable', texts_1.DESC_COMMAND_AGENT_TARGET_DISABLE);
|
|
12
11
|
commandAgentTargetDisable.action(async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (!commandAgentTargetDisable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTargetDisable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
|
-
const
|
|
19
|
-
const api = new agent_1.default(json.port);
|
|
19
|
+
const api = new agent_1.default(commandAgentTargetDisable.agentPort || 0);
|
|
20
20
|
await api.disableAgentTarget();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_TARGET_DISABLED);
|
|
22
22
|
}
|
|
@@ -5,18 +5,18 @@ 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 agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
11
10
|
const commandAgentTargetEnable = (0, utils_1.newCommand)('enable', texts_1.DESC_COMMAND_AGENT_TARGET_ENABLE);
|
|
12
11
|
commandAgentTargetEnable.action(async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (!commandAgentTargetEnable.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTargetEnable.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
|
-
const
|
|
19
|
-
const api = new agent_1.default(json.port);
|
|
19
|
+
const api = new agent_1.default(commandAgentTargetEnable.agentPort || 0);
|
|
20
20
|
await api.enableAgentTarget();
|
|
21
21
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_TARGET_ENABLED);
|
|
22
22
|
}
|
|
@@ -5,18 +5,18 @@ 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 agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
11
10
|
const commandAgentTargetStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TARGET_STATUS);
|
|
12
11
|
commandAgentTargetStatus.action(async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (!commandAgentTargetStatus.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTargetStatus.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
|
-
const
|
|
19
|
-
const api = new agent_1.default(json.port);
|
|
19
|
+
const api = new agent_1.default(commandAgentTargetStatus.agentPort || 0);
|
|
20
20
|
const data = await api.fetchAgentTarget();
|
|
21
21
|
if (data.target) {
|
|
22
22
|
output_1.default.exitSuccess(texts_1.TXT_AGENT_TARGET_ENABLED);
|
|
@@ -8,7 +8,6 @@ const output_1 = __importDefault(require("../../../output"));
|
|
|
8
8
|
const cfg_1 = __importDefault(require("../../../tunnel/cfg"));
|
|
9
9
|
const texts_1 = require("../../../texts");
|
|
10
10
|
const tunnel_1 = __importDefault(require("../../../agent/socket/tunnel"));
|
|
11
|
-
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
12
11
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
13
12
|
const tunnel_2 = require("../../../types/tunnel");
|
|
14
13
|
const commandAgentTunnelHttp = (0, utils_1.getBasicCommandHttp)();
|
|
@@ -16,15 +15,16 @@ commandAgentTunnelHttp.description(texts_1.DESC_COMMAND_HTTP);
|
|
|
16
15
|
commandAgentTunnelHttp.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
17
16
|
commandAgentTunnelHttp.argument('[protocol://host:port]', texts_1.OPTION_TARGET);
|
|
18
17
|
commandAgentTunnelHttp.action(async (target, options) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if (!commandAgentTunnelHttp.agentInstalled) {
|
|
19
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
20
|
+
}
|
|
21
|
+
if (!commandAgentTunnelHttp.agentStatus) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
22
23
|
}
|
|
23
24
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_2.TUNNEL_TYPE.HTTP, target, options, true);
|
|
24
25
|
try {
|
|
25
26
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
26
|
-
const
|
|
27
|
-
const api = new agent_1.default(json.port);
|
|
27
|
+
const api = new agent_1.default(commandAgentTunnelHttp.agentPort || 0);
|
|
28
28
|
const data = await api.addTunnel(prepared);
|
|
29
29
|
if (options.follow) {
|
|
30
30
|
const ws = await api.socketTunnel(data.id);
|
|
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const output_1 = __importDefault(require("../../../output"));
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
9
|
-
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
10
9
|
const utils_1 = require("../../../utils");
|
|
11
10
|
const commandAgentTunnelList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_AGENT_TUNNEL_LIST);
|
|
12
11
|
commandAgentTunnelList.action(async () => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (!commandAgentTunnelList.agentInstalled) {
|
|
13
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
14
|
+
}
|
|
15
|
+
if (!commandAgentTunnelList.agentStatus) {
|
|
16
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
16
17
|
}
|
|
17
18
|
try {
|
|
18
|
-
const
|
|
19
|
-
const api = new agent_1.default(json.port);
|
|
19
|
+
const api = new agent_1.default(commandAgentTunnelList.agentPort || 0);
|
|
20
20
|
const data = await api.fetchTunnels();
|
|
21
21
|
output_1.default.agentTunnels(data.tunnels);
|
|
22
22
|
}
|
|
@@ -6,18 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const output_1 = __importDefault(require("../../../output"));
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
9
|
-
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
10
9
|
const utils_1 = require("../../../utils");
|
|
11
10
|
const commandAgentTunnelRemove = (0, utils_1.newCommand)('rm', texts_1.DESC_COMMAND_AGENT_TUNNEL_REMOVE);
|
|
12
11
|
commandAgentTunnelRemove.argument('<id>', texts_1.OPTION_ID);
|
|
13
12
|
commandAgentTunnelRemove.action(async (id) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (!commandAgentTunnelRemove.agentInstalled) {
|
|
14
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
15
|
+
}
|
|
16
|
+
if (!commandAgentTunnelRemove.agentStatus) {
|
|
17
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
17
18
|
}
|
|
18
19
|
try {
|
|
19
|
-
const
|
|
20
|
-
const api = new agent_1.default(json.port);
|
|
20
|
+
const api = new agent_1.default(commandAgentTunnelRemove.agentPort || 0);
|
|
21
21
|
await api.stopTunnel(id);
|
|
22
22
|
output_1.default.exitSuccess(texts_1.TXT_TUNNEL_STOPPED);
|
|
23
23
|
}
|
|
@@ -7,23 +7,23 @@ const cfg_1 = __importDefault(require("../../../tunnel/cfg"));
|
|
|
7
7
|
const output_1 = __importDefault(require("../../../output"));
|
|
8
8
|
const texts_1 = require("../../../texts");
|
|
9
9
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
10
|
-
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
11
10
|
const utils_1 = require("../../../utils");
|
|
12
11
|
const commandAgentTunnelStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_START);
|
|
13
12
|
commandAgentTunnelStart.argument('<name>', texts_1.OPTION_NAME);
|
|
14
13
|
commandAgentTunnelStart.action(async (name) => {
|
|
14
|
+
if (!commandAgentTunnelStart.agentInstalled) {
|
|
15
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
16
|
+
}
|
|
17
|
+
if (!commandAgentTunnelStart.agentStatus) {
|
|
18
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
19
|
+
}
|
|
15
20
|
if (!cfg_1.default.hasTunnel(name)) {
|
|
16
21
|
output_1.default.exitError((0, texts_1.ERR_TUNNEL_NOT_FOUND)(name));
|
|
17
22
|
}
|
|
18
23
|
const prepared = cfg_1.default.getTunnel(name);
|
|
19
|
-
const isEnabled = await manager_1.default.system.isEnabled();
|
|
20
|
-
if (!isEnabled) {
|
|
21
|
-
output_1.default.exitError(texts_1.ERR_AGENT_NOT_ENABLED);
|
|
22
|
-
}
|
|
23
24
|
try {
|
|
24
25
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
25
|
-
const
|
|
26
|
-
const api = new agent_1.default(json.port);
|
|
26
|
+
const api = new agent_1.default(commandAgentTunnelStart.agentPort || 0);
|
|
27
27
|
const data = await api.addTunnel(prepared);
|
|
28
28
|
output_1.default.exitSuccess((0, texts_1.TXT_TUNNEL_STARTED)(data.type));
|
|
29
29
|
}
|
|
@@ -7,18 +7,18 @@ const texts_1 = require("../../../texts");
|
|
|
7
7
|
const output_1 = __importDefault(require("../../../output"));
|
|
8
8
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
9
9
|
const tunnel_1 = __importDefault(require("../../../agent/socket/tunnel"));
|
|
10
|
-
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
11
10
|
const utils_1 = require("../../../utils");
|
|
12
11
|
const commandAgentTunnelStatus = (0, utils_1.newCommand)('status', texts_1.DESC_COMMAND_AGENT_TUNNEL_STATUS);
|
|
13
12
|
commandAgentTunnelStatus.argument('<id>', texts_1.OPTION_ID);
|
|
14
13
|
commandAgentTunnelStatus.action(async (id) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (!commandAgentTunnelStatus.agentInstalled) {
|
|
15
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
16
|
+
}
|
|
17
|
+
if (!commandAgentTunnelStatus.agentStatus) {
|
|
18
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
18
19
|
}
|
|
19
20
|
try {
|
|
20
|
-
const
|
|
21
|
-
const api = new agent_1.default(json.port);
|
|
21
|
+
const api = new agent_1.default(commandAgentTunnelStatus.agentPort || 0);
|
|
22
22
|
const ws = await api.socketTunnel(id);
|
|
23
23
|
const tunnel = new tunnel_1.default(ws, id);
|
|
24
24
|
await tunnel.waitForReady();
|
|
@@ -7,7 +7,6 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const output_1 = __importDefault(require("../../../output"));
|
|
8
8
|
const cfg_1 = __importDefault(require("../../../tunnel/cfg"));
|
|
9
9
|
const texts_1 = require("../../../texts");
|
|
10
|
-
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
11
10
|
const tunnel_1 = __importDefault(require("../../../agent/socket/tunnel"));
|
|
12
11
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
13
12
|
const tunnel_2 = require("../../../types/tunnel");
|
|
@@ -16,15 +15,16 @@ commandAgentTunnelTcp.description(texts_1.DESC_COMMAND_TCP);
|
|
|
16
15
|
commandAgentTunnelTcp.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
17
16
|
commandAgentTunnelTcp.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
18
17
|
commandAgentTunnelTcp.action(async (target, options) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if (!commandAgentTunnelTcp.agentInstalled) {
|
|
19
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
20
|
+
}
|
|
21
|
+
if (!commandAgentTunnelTcp.agentStatus) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
22
23
|
}
|
|
23
24
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_2.TUNNEL_TYPE.TCP, target, options, true);
|
|
24
25
|
try {
|
|
25
26
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
26
|
-
const
|
|
27
|
-
const api = new agent_1.default(json.port);
|
|
27
|
+
const api = new agent_1.default(commandAgentTunnelTcp.agentPort || 0);
|
|
28
28
|
const data = await api.addTunnel(prepared);
|
|
29
29
|
if (options.follow) {
|
|
30
30
|
const ws = await api.socketTunnel(data.id);
|
|
@@ -8,7 +8,6 @@ const output_1 = __importDefault(require("../../../output"));
|
|
|
8
8
|
const cfg_1 = __importDefault(require("../../../tunnel/cfg"));
|
|
9
9
|
const texts_1 = require("../../../texts");
|
|
10
10
|
const tunnel_1 = __importDefault(require("../../../agent/socket/tunnel"));
|
|
11
|
-
const manager_1 = __importDefault(require("../../../agent/manager"));
|
|
12
11
|
const agent_1 = __importDefault(require("../../../tunnel/api/agent"));
|
|
13
12
|
const tunnel_2 = require("../../../types/tunnel");
|
|
14
13
|
const commandAgentTunnelTls = (0, utils_1.getBasicCommandTls)();
|
|
@@ -16,15 +15,16 @@ commandAgentTunnelTls.description(texts_1.DESC_COMMAND_TLS);
|
|
|
16
15
|
commandAgentTunnelTls.option('-f, --follow', texts_1.OPTION_FOLLOW);
|
|
17
16
|
commandAgentTunnelTls.argument('[host:port]', texts_1.OPTION_TARGET);
|
|
18
17
|
commandAgentTunnelTls.action(async (target, options) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if (!commandAgentTunnelTls.agentInstalled) {
|
|
19
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
20
|
+
}
|
|
21
|
+
if (!commandAgentTunnelTls.agentStatus) {
|
|
22
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
22
23
|
}
|
|
23
24
|
const prepared = await cfg_1.default.prepareTunnel(tunnel_2.TUNNEL_TYPE.TLS, target, options, true);
|
|
24
25
|
try {
|
|
25
26
|
await output_1.default.spinner(texts_1.TXT_OPENING_TUNNEL);
|
|
26
|
-
const
|
|
27
|
-
const api = new agent_1.default(json.port);
|
|
27
|
+
const api = new agent_1.default(commandAgentTunnelTls.agentPort || 0);
|
|
28
28
|
const data = await api.addTunnel(prepared);
|
|
29
29
|
if (options.follow) {
|
|
30
30
|
const ws = await api.socketTunnel(data.id);
|
|
@@ -15,13 +15,13 @@ commandAgentUninstall.action(async () => {
|
|
|
15
15
|
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
|
-
await manager_1.default.system.
|
|
18
|
+
await manager_1.default.system.uninstall();
|
|
19
19
|
}
|
|
20
20
|
catch {
|
|
21
21
|
// do nothing
|
|
22
22
|
}
|
|
23
23
|
try {
|
|
24
|
-
manager_1.default.system.killStandaloneProc();
|
|
24
|
+
await manager_1.default.system.killStandaloneProc();
|
|
25
25
|
}
|
|
26
26
|
catch {
|
|
27
27
|
// do nothing
|
|
@@ -16,26 +16,28 @@ commandAgentUpdate.action(async () => {
|
|
|
16
16
|
if (!hasAdminRights) {
|
|
17
17
|
output_1.default.exitError(texts_1.ERR_AGENT_ADMIN_RIGHTS);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
output_1.default.exitError(texts_1.ERR_AGENT_NOT_ENABLED);
|
|
22
|
-
}
|
|
23
|
-
if (manager_1.default.system.isStandaloneProcRunning()) {
|
|
24
|
-
output_1.default.exitError(texts_1.ERR_AGENT_STANDALONE_UPDATE);
|
|
19
|
+
if (!commandAgentUpdate.agentInstalled) {
|
|
20
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
25
21
|
}
|
|
26
22
|
output_1.default.normal(texts_1.TXT_UPDATING_AGENT);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await (0, wait_1.default)(api, 15000, () => {
|
|
32
|
-
output_1.default.exitError(texts_1.ERR_SWW_AGENT_UPDATING);
|
|
33
|
-
}, () => {
|
|
34
|
-
output_1.default.exitSuccess(texts_1.TXT_AGENT_UPDATED);
|
|
35
|
-
});
|
|
23
|
+
if (commandAgentUpdate.agentStandalone) {
|
|
24
|
+
// app
|
|
25
|
+
await manager_1.default.system.killStandaloneProc();
|
|
26
|
+
manager_1.default.system.startStandaloneProc();
|
|
36
27
|
}
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
else {
|
|
29
|
+
try {
|
|
30
|
+
await manager_1.default.system.update();
|
|
31
|
+
const api = new agent_1.default(commandAgentUpdate.agentPort || 0);
|
|
32
|
+
await (0, wait_1.default)(api, 15000, () => {
|
|
33
|
+
output_1.default.exitError(texts_1.ERR_SWW_AGENT_UPDATING);
|
|
34
|
+
}, () => {
|
|
35
|
+
output_1.default.exitSuccess(texts_1.TXT_AGENT_UPDATED);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
output_1.default.exitError(texts_1.ERR_SWW_AGENT_UPDATING);
|
|
40
|
+
}
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
43
|
exports.default = commandAgentUpdate;
|
|
@@ -5,16 +5,14 @@ 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 commandAgentVersion = (0, utils_1.newCommand)('version', texts_1.DESC_COMMAND_AGENT_VERSION);
|
|
11
10
|
commandAgentVersion.action(async () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
output_1.default.exitError(texts_1.ERR_AGENT_NOT_ENABLED);
|
|
11
|
+
if (!commandAgentVersion.agentInstalled) {
|
|
12
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_INSTALLED);
|
|
15
13
|
}
|
|
16
14
|
if (!commandAgentVersion.agentStatus) {
|
|
17
|
-
output_1.default.exitError(texts_1.
|
|
15
|
+
output_1.default.exitError(texts_1.ERR_AGENT_NOT_RUNNING);
|
|
18
16
|
}
|
|
19
17
|
output_1.default.exitNormal(commandAgentVersion.agentStatus.version);
|
|
20
18
|
});
|
|
@@ -19,12 +19,8 @@ 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 up_1 = __importDefault(require("./agent/up"));
|
|
23
|
-
const down_1 = __importDefault(require("./agent/down"));
|
|
24
22
|
const commandAgent = (0, utils_1.newCommand)('agent', texts_1.DESC_COMMAND_AGENT);
|
|
25
23
|
commandAgent.addCommand(install_1.default);
|
|
26
|
-
commandAgent.addCommand(up_1.default);
|
|
27
|
-
commandAgent.addCommand(down_1.default);
|
|
28
24
|
commandAgent.addCommand(enable_1.default);
|
|
29
25
|
commandAgent.addCommand(disable_1.default);
|
|
30
26
|
commandAgent.addCommand(start_1.default);
|
|
@@ -9,11 +9,19 @@ const manager_1 = __importDefault(require("../agent/manager"));
|
|
|
9
9
|
const agent_1 = __importDefault(require("../tunnel/api/agent"));
|
|
10
10
|
const commandPre = async (_, command) => {
|
|
11
11
|
command.agentStatus = null;
|
|
12
|
+
command.agentStandalone = false;
|
|
13
|
+
command.agentInstalled = false;
|
|
14
|
+
command.agentPort = 0;
|
|
15
|
+
command.agentId = '';
|
|
12
16
|
try {
|
|
13
17
|
if (!(0, utils_1.isDocker)()) {
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
18
|
+
const hasConfig = manager_1.default.system.hasSystemConfig();
|
|
19
|
+
if (hasConfig) {
|
|
20
|
+
command.agentInstalled = true;
|
|
16
21
|
const json = manager_1.default.system.loadSystemConfig();
|
|
22
|
+
command.agentStandalone = !!json.standalone; // nie zawsze to jest bool
|
|
23
|
+
command.agentId = json.id;
|
|
24
|
+
command.agentPort = json.port;
|
|
17
25
|
const api = new agent_1.default(json.port);
|
|
18
26
|
command.agentStatus = await api.fetchStatus();
|
|
19
27
|
}
|
package/distTs/src/output.js
CHANGED
|
@@ -35,11 +35,23 @@ class Output {
|
|
|
35
35
|
msg += '\n';
|
|
36
36
|
terminal(msg);
|
|
37
37
|
}
|
|
38
|
-
static warning(txt) {
|
|
39
|
-
|
|
38
|
+
static warning(txt, newLine = true) {
|
|
39
|
+
let msg = txt;
|
|
40
|
+
if (newLine)
|
|
41
|
+
msg += '\n';
|
|
42
|
+
terminal.yellow(msg);
|
|
43
|
+
}
|
|
44
|
+
static error(txt, newLine = true) {
|
|
45
|
+
let msg = txt;
|
|
46
|
+
if (newLine)
|
|
47
|
+
msg += '\n';
|
|
48
|
+
terminal.red(msg);
|
|
40
49
|
}
|
|
41
|
-
static
|
|
42
|
-
|
|
50
|
+
static green(txt, newLine = true) {
|
|
51
|
+
let msg = txt;
|
|
52
|
+
if (newLine)
|
|
53
|
+
msg += '\n';
|
|
54
|
+
terminal.green(msg);
|
|
43
55
|
}
|
|
44
56
|
static debug(txt) {
|
|
45
57
|
if (context_1.debug) {
|