bdy 1.8.3-dev → 1.8.4-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/bin/cli.js +5 -0
- package/distTs/src/agent/linux.js +119 -0
- package/distTs/src/agent/manager.js +395 -0
- package/distTs/src/agent/osx.js +139 -0
- package/distTs/src/agent/socket/tunnel.js +212 -0
- package/distTs/src/agent/socket.js +220 -0
- package/distTs/src/agent/system.js +177 -0
- package/distTs/src/agent/wait.js +23 -0
- package/distTs/src/agent/windows.js +159 -0
- package/distTs/src/agent.js +237 -0
- package/distTs/src/api/agent.js +84 -0
- package/distTs/src/api/buddy.js +117 -0
- package/distTs/src/api/socket.js +133 -0
- package/distTs/src/cfg.js +238 -0
- package/distTs/src/command/agent/install.js +106 -0
- package/distTs/src/command/agent/restart.js +27 -0
- package/distTs/src/command/agent/run.js +19 -0
- package/distTs/src/command/agent/start.js +28 -0
- package/distTs/src/command/agent/status.js +35 -0
- package/distTs/src/command/agent/stop.js +28 -0
- package/distTs/src/command/agent/tunnel/http.js +44 -0
- package/distTs/src/command/agent/tunnel/list.js +27 -0
- package/distTs/src/command/agent/tunnel/remove.js +28 -0
- package/distTs/src/command/agent/tunnel/start.js +34 -0
- package/distTs/src/command/agent/tunnel/status.js +31 -0
- package/distTs/src/command/agent/tunnel/tcp.js +43 -0
- package/distTs/src/command/agent/tunnel/tls.js +43 -0
- package/distTs/src/command/agent/tunnel.js +23 -0
- package/distTs/src/command/agent/uninstall.js +38 -0
- package/distTs/src/command/agent/update.js +38 -0
- package/distTs/src/command/agent/version.js +21 -0
- package/distTs/src/command/agent.js +29 -0
- package/distTs/src/command/config/add/http.js +25 -0
- package/distTs/src/command/config/add/tcp.js +25 -0
- package/distTs/src/command/config/add/tls.js +25 -0
- package/distTs/src/command/config/add.js +15 -0
- package/distTs/src/command/config/get/region.js +15 -0
- package/distTs/src/command/config/get/timeout.js +15 -0
- package/distTs/src/command/config/get/token.js +15 -0
- package/distTs/src/command/config/get/tunnel.js +19 -0
- package/distTs/src/command/config/get/tunnels.js +15 -0
- package/distTs/src/command/config/get/whitelist.js +15 -0
- package/distTs/src/command/config/get.js +21 -0
- package/distTs/src/command/config/remove/tunnel.js +19 -0
- package/distTs/src/command/config/remove.js +11 -0
- package/distTs/src/command/config/set/region.js +17 -0
- package/distTs/src/command/config/set/timeout.js +17 -0
- package/distTs/src/command/config/set/token.js +16 -0
- package/distTs/src/command/config/set/whitelist.js +17 -0
- package/distTs/src/command/config/set.js +17 -0
- package/distTs/src/command/config.js +17 -0
- package/distTs/src/command/http.js +30 -0
- package/distTs/src/command/pre.js +49 -0
- package/distTs/src/command/start.js +28 -0
- package/distTs/src/command/tcp.js +30 -0
- package/distTs/src/command/tls.js +30 -0
- package/distTs/src/command/version.js +13 -0
- package/distTs/src/command/vt/close.js +28 -0
- package/distTs/src/command/vt/exec.js +79 -0
- package/distTs/src/command/vt/storybook.js +90 -0
- package/distTs/src/command/vt.js +15 -0
- package/distTs/src/format.js +172 -0
- package/distTs/src/index.js +40 -0
- package/distTs/src/input.js +286 -0
- package/distTs/src/logger.js +93 -0
- package/distTs/src/output/interactive/tunnel.js +860 -0
- package/distTs/src/output/noninteractive/agent/tunnels.js +43 -0
- package/distTs/src/output/noninteractive/config/tunnel.js +67 -0
- package/distTs/src/output/noninteractive/config/tunnels.js +18 -0
- package/distTs/src/output/noninteractive/tunnel.js +59 -0
- package/distTs/src/output.js +138 -0
- package/distTs/src/server/cert.js +52 -0
- package/distTs/src/server/http1.js +74 -0
- package/distTs/src/server/http2.js +74 -0
- package/distTs/src/server/sftp.js +487 -0
- package/distTs/src/server/ssh.js +112 -0
- package/distTs/src/server/tls.js +41 -0
- package/distTs/src/ssh/client.js +191 -0
- package/distTs/src/texts.js +345 -0
- package/distTs/src/tunnel/agent.js +100 -0
- package/distTs/src/tunnel/compression.js +41 -0
- package/distTs/src/tunnel/dns.js +54 -0
- package/distTs/src/tunnel/html.js +30 -0
- package/distTs/src/tunnel/http/log.js +196 -0
- package/distTs/src/tunnel/http/serve.js +132 -0
- package/distTs/src/tunnel/http/stream.js +45 -0
- package/distTs/src/tunnel/http.js +405 -0
- package/distTs/src/tunnel/identification.js +96 -0
- package/distTs/src/tunnel/latency.js +71 -0
- package/distTs/src/tunnel/tcp.js +92 -0
- package/distTs/src/tunnel.js +647 -0
- package/distTs/src/types/ciInfo.js +10 -0
- package/distTs/src/types/options.js +2 -0
- package/distTs/src/types/plugin.js +2 -0
- package/distTs/src/types/queue.js +2 -0
- package/distTs/src/types/requests.js +2 -0
- package/distTs/src/types/resources.js +2 -0
- package/distTs/src/types/snapshots.js +2 -0
- package/distTs/src/types/storybook.js +2 -0
- package/distTs/src/utils.js +437 -0
- package/distTs/src/visualTest/browser.js +32 -0
- package/distTs/src/visualTest/ci.js +206 -0
- package/distTs/src/visualTest/context.js +44 -0
- package/distTs/src/visualTest/exec.js +51 -0
- package/distTs/src/visualTest/queue.js +43 -0
- package/distTs/src/visualTest/requests.js +197 -0
- package/distTs/src/visualTest/resources.js +195 -0
- package/distTs/src/visualTest/server.js +33 -0
- package/distTs/src/visualTest/snapshots.js +109 -0
- package/distTs/src/visualTest/utils/parseDom.js +238 -0
- package/distTs/src/visualTest/validation.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
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 config_js_1 = __importDefault(require("./command/config.js"));
|
|
7
|
+
const output_js_1 = __importDefault(require("./output.js"));
|
|
8
|
+
const tcp_js_1 = __importDefault(require("./command/tcp.js"));
|
|
9
|
+
const tls_js_1 = __importDefault(require("./command/tls.js"));
|
|
10
|
+
const http_js_1 = __importDefault(require("./command/http.js"));
|
|
11
|
+
const start_js_1 = __importDefault(require("./command/start.js"));
|
|
12
|
+
const agent_js_1 = __importDefault(require("./command/agent.js"));
|
|
13
|
+
const logger_js_1 = __importDefault(require("./logger.js"));
|
|
14
|
+
const version_js_1 = __importDefault(require("./command/version.js"));
|
|
15
|
+
const pre_js_1 = __importDefault(require("./command/pre.js"));
|
|
16
|
+
const stream_1 = __importDefault(require("stream"));
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
const texts_1 = require("./texts");
|
|
19
|
+
const vt_1 = __importDefault(require("./command/vt"));
|
|
20
|
+
stream_1.default.setDefaultHighWaterMark(false, 67108864);
|
|
21
|
+
process.title = 'bdy';
|
|
22
|
+
process.on('uncaughtException', (err) => {
|
|
23
|
+
logger_js_1.default.fatal(err);
|
|
24
|
+
output_js_1.default.exitError(err);
|
|
25
|
+
});
|
|
26
|
+
const program = (0, utils_1.newCommand)(null, texts_1.DESC_PROGRAM);
|
|
27
|
+
program.hook('preAction', pre_js_1.default);
|
|
28
|
+
program.configureHelp({
|
|
29
|
+
formatHelp: utils_1.formatHelp,
|
|
30
|
+
});
|
|
31
|
+
program.addCommand(config_js_1.default);
|
|
32
|
+
program.addCommand(tcp_js_1.default);
|
|
33
|
+
program.addCommand(tls_js_1.default);
|
|
34
|
+
program.addCommand(http_js_1.default);
|
|
35
|
+
program.addCommand(start_js_1.default);
|
|
36
|
+
if (!(0, utils_1.isDocker)())
|
|
37
|
+
program.addCommand(agent_js_1.default);
|
|
38
|
+
program.addCommand(version_js_1.default);
|
|
39
|
+
program.addCommand(vt_1.default);
|
|
40
|
+
program.parse();
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const output_js_1 = __importDefault(require("./output.js"));
|
|
30
|
+
const netmask_1 = __importDefault(require("netmask"));
|
|
31
|
+
const fs_1 = __importStar(require("fs"));
|
|
32
|
+
const tls_1 = __importDefault(require("tls"));
|
|
33
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
34
|
+
const utils_js_1 = require("./utils.js");
|
|
35
|
+
const texts_js_1 = require("./texts.js");
|
|
36
|
+
class Input {
|
|
37
|
+
static timeout(timeout) {
|
|
38
|
+
const t = parseInt(timeout, 10);
|
|
39
|
+
if (isNaN(t) || t <= 0 || t > 999) {
|
|
40
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_TIMEOUT_IS_NOT_VALID)(timeout));
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
static serve(serve) {
|
|
45
|
+
if (!serve)
|
|
46
|
+
return serve;
|
|
47
|
+
try {
|
|
48
|
+
const info = (0, fs_1.statSync)(serve);
|
|
49
|
+
if (!info.isDirectory()) {
|
|
50
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_PATH_IS_NOT_DIRECTORY)(serve));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_DIRECTORY_DOES_NOT_EXISTS)(serve));
|
|
55
|
+
}
|
|
56
|
+
return serve;
|
|
57
|
+
}
|
|
58
|
+
static circuitBreaker(threshold) {
|
|
59
|
+
if (threshold === undefined)
|
|
60
|
+
return null;
|
|
61
|
+
const n = parseFloat(threshold);
|
|
62
|
+
if (isNaN(n) || n < 0 || n > 1) {
|
|
63
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_CB_THRESHOLD_IS_NOT_VALID)(n));
|
|
64
|
+
}
|
|
65
|
+
return n;
|
|
66
|
+
}
|
|
67
|
+
static headers(headers) {
|
|
68
|
+
const r = [];
|
|
69
|
+
(headers || []).forEach((h) => {
|
|
70
|
+
if (!h)
|
|
71
|
+
return;
|
|
72
|
+
const s = h.split(':');
|
|
73
|
+
if (s.length !== 2)
|
|
74
|
+
return;
|
|
75
|
+
r.push({
|
|
76
|
+
name: s[0],
|
|
77
|
+
value: s[1],
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return r;
|
|
81
|
+
}
|
|
82
|
+
static subdomain(subdomain) {
|
|
83
|
+
if (!/^[a-z0-9-]+$/i.test(subdomain)) {
|
|
84
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_SUBDOMAIN_IS_NOT_VALID)(subdomain));
|
|
85
|
+
}
|
|
86
|
+
if (subdomain.length < 5) {
|
|
87
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_SUBDOMAIN_IS_TOO_SHORT)(subdomain));
|
|
88
|
+
}
|
|
89
|
+
if (subdomain.length > 63) {
|
|
90
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_SUBDOMAIN_IS_TOO_LONG)(subdomain));
|
|
91
|
+
}
|
|
92
|
+
return subdomain;
|
|
93
|
+
}
|
|
94
|
+
static domain(domain) {
|
|
95
|
+
if (!/^(?:[A-z0-9](?:[A-z0-9-]{0,61}[A-z0-9])?\.)+[A-z0-9][A-z0-9-]{0,61}[A-z0-9]$/i.test(domain)) {
|
|
96
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_DOMAIN_IS_NOT_VALID)(domain));
|
|
97
|
+
}
|
|
98
|
+
return domain;
|
|
99
|
+
}
|
|
100
|
+
static auth(auth) {
|
|
101
|
+
const s = auth.split(':');
|
|
102
|
+
if (s.length !== 2) {
|
|
103
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_BA_IS_NOT_VALID)(auth));
|
|
104
|
+
}
|
|
105
|
+
if (!s[0]) {
|
|
106
|
+
output_js_1.default.exitError(texts_js_1.ERR_BA_LOGIN_NOT_PROVIDED);
|
|
107
|
+
}
|
|
108
|
+
if (!s[1]) {
|
|
109
|
+
output_js_1.default.exitError(texts_js_1.ERR_BA_PASSWORD_NOT_PROVIDED);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
login: s[0],
|
|
113
|
+
password: s[1],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
static useragents(useragents) {
|
|
117
|
+
if (!useragents || !useragents.length)
|
|
118
|
+
return [];
|
|
119
|
+
useragents.forEach((ua) => {
|
|
120
|
+
if ((0, utils_js_1.isStringRegExp)(ua)) {
|
|
121
|
+
try {
|
|
122
|
+
new RegExp(ua);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_USER_AGENT_IS_NOT_VALID)(ua));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return useragents;
|
|
130
|
+
}
|
|
131
|
+
static whitelist(whitelist) {
|
|
132
|
+
if (!whitelist || !whitelist.length)
|
|
133
|
+
return [];
|
|
134
|
+
for (let i = 0; i < whitelist.length; i += 1) {
|
|
135
|
+
const wh = whitelist[i];
|
|
136
|
+
if (wh === '*')
|
|
137
|
+
return ['*'];
|
|
138
|
+
try {
|
|
139
|
+
new netmask_1.default.Netmask(wh);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_WHITELIST_IS_NOT_VALID)(wh));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return whitelist;
|
|
146
|
+
}
|
|
147
|
+
static region(region) {
|
|
148
|
+
if (!region)
|
|
149
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_REGION_IS_NOT_VALID)(''));
|
|
150
|
+
region = region.toUpperCase();
|
|
151
|
+
if (![utils_js_1.REGION_EU, utils_js_1.REGION_US].includes(region)) {
|
|
152
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_REGION_IS_NOT_VALID)(region));
|
|
153
|
+
}
|
|
154
|
+
return region;
|
|
155
|
+
}
|
|
156
|
+
static terminate(terminate) {
|
|
157
|
+
if (!terminate)
|
|
158
|
+
return utils_js_1.TLS_TERMINATE_AT_REGION;
|
|
159
|
+
terminate = terminate.toUpperCase();
|
|
160
|
+
if (![
|
|
161
|
+
utils_js_1.TLS_TERMINATE_AT_AGENT,
|
|
162
|
+
utils_js_1.TLS_TERMINATE_AT_REGION,
|
|
163
|
+
utils_js_1.TLS_TERMINATE_AT_TARGET,
|
|
164
|
+
].includes(terminate)) {
|
|
165
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_TERMINATE_IS_NOT_VALID)(terminate));
|
|
166
|
+
}
|
|
167
|
+
return terminate;
|
|
168
|
+
}
|
|
169
|
+
static target(target, type) {
|
|
170
|
+
if (!target)
|
|
171
|
+
return '80';
|
|
172
|
+
if (target.length > 200) {
|
|
173
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_TARGET_IS_NOT_VALID)(target));
|
|
174
|
+
}
|
|
175
|
+
target = target.toLowerCase();
|
|
176
|
+
// 80
|
|
177
|
+
// localhost
|
|
178
|
+
// localhost:80
|
|
179
|
+
// http://localhost:80
|
|
180
|
+
// http://localhost
|
|
181
|
+
// http://user:pass@localhost
|
|
182
|
+
// http://user:pass@localhost:80
|
|
183
|
+
let port;
|
|
184
|
+
if ([utils_js_1.TUNNEL_TCP, utils_js_1.TUNNEL_TLS].includes(type)) {
|
|
185
|
+
const m = target.match(utils_js_1.TARGET_TCP_TLS_REGEX);
|
|
186
|
+
if (!m) {
|
|
187
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_TARGET_IS_NOT_VALID)(target));
|
|
188
|
+
}
|
|
189
|
+
port = m[3];
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
let m = target.match(utils_js_1.TARGET_ONLY_PORT_REGEX);
|
|
193
|
+
if (m) {
|
|
194
|
+
port = m[0];
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
m = target.match(utils_js_1.TARGET_HTTP_REGEX);
|
|
198
|
+
if (!m) {
|
|
199
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_TARGET_IS_NOT_VALID)(target));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
let proto;
|
|
203
|
+
if (m[2])
|
|
204
|
+
proto = m[2];
|
|
205
|
+
else
|
|
206
|
+
proto = 'http';
|
|
207
|
+
if (m[6])
|
|
208
|
+
port = m[6];
|
|
209
|
+
else if (proto === 'https')
|
|
210
|
+
port = '443';
|
|
211
|
+
else
|
|
212
|
+
port = '80';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
Input.port(port);
|
|
217
|
+
return target;
|
|
218
|
+
}
|
|
219
|
+
static port(port) {
|
|
220
|
+
const p = parseInt(port, 10);
|
|
221
|
+
if (isNaN(p) || p <= 0 || p > 65535)
|
|
222
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_PORT_IS_NOT_VALID)(port));
|
|
223
|
+
return p;
|
|
224
|
+
}
|
|
225
|
+
static type(type) {
|
|
226
|
+
if (!type)
|
|
227
|
+
return utils_js_1.TUNNEL_TCP;
|
|
228
|
+
type = type.toUpperCase();
|
|
229
|
+
if (![utils_js_1.TUNNEL_TCP, utils_js_1.TUNNEL_TLS, utils_js_1.TUNNEL_HTTP].includes(type)) {
|
|
230
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_TYPE_IS_NOT_VALID)(type));
|
|
231
|
+
}
|
|
232
|
+
return type;
|
|
233
|
+
}
|
|
234
|
+
static name(name) {
|
|
235
|
+
if (name.includes('*')) {
|
|
236
|
+
output_js_1.default.exitError(texts_js_1.ERR_NAME_WITHOUT_ASTERISK);
|
|
237
|
+
}
|
|
238
|
+
return name;
|
|
239
|
+
}
|
|
240
|
+
static ca(caPath) {
|
|
241
|
+
let cert;
|
|
242
|
+
try {
|
|
243
|
+
cert = fs_1.default.readFileSync(caPath, 'utf8');
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_CA_PATH_IS_NOT_VALID)(caPath));
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
new crypto_1.default.X509Certificate(cert);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_WRONG_CA)(caPath));
|
|
253
|
+
}
|
|
254
|
+
return cert;
|
|
255
|
+
}
|
|
256
|
+
static keyCert(keyPath, certPath) {
|
|
257
|
+
let key;
|
|
258
|
+
let cert;
|
|
259
|
+
try {
|
|
260
|
+
key = fs_1.default.readFileSync(keyPath, 'utf8');
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_KEY_PATH_IS_NOT_VALID)(keyPath));
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
cert = fs_1.default.readFileSync(certPath, 'utf8');
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
output_js_1.default.exitError((0, texts_js_1.ERR_CERT_PATH_IS_NOT_VALID)(certPath));
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
tls_1.default.createSecureContext({
|
|
273
|
+
cert,
|
|
274
|
+
key,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
output_js_1.default.exitError(texts_js_1.ERR_WRONG_KEY_CERT);
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
cert,
|
|
282
|
+
key,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
exports.default = Input;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 pino_1 = __importDefault(require("pino"));
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const utils_js_1 = require("./utils.js");
|
|
10
|
+
class Logger {
|
|
11
|
+
rootPath = null;
|
|
12
|
+
logPath = null;
|
|
13
|
+
log1Path = null;
|
|
14
|
+
logStream = null;
|
|
15
|
+
p = null;
|
|
16
|
+
ts = null;
|
|
17
|
+
constructor() {
|
|
18
|
+
this.rootPath = (0, utils_js_1.getHomeDirectory)();
|
|
19
|
+
}
|
|
20
|
+
checkLogSize() {
|
|
21
|
+
try {
|
|
22
|
+
const s = fs_1.default.statSync(this.logPath);
|
|
23
|
+
if (s.size > 5242880) {
|
|
24
|
+
fs_1.default.copyFileSync(this.logPath, this.log1Path);
|
|
25
|
+
fs_1.default.truncateSync(this.logPath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// do nothing
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
getPino() {
|
|
33
|
+
if (!this.p) {
|
|
34
|
+
this.logPath = (0, path_1.resolve)(this.rootPath, 'cli.log');
|
|
35
|
+
this.log1Path = (0, path_1.resolve)(this.rootPath, 'cli.1.log');
|
|
36
|
+
this.logStream = fs_1.default.openSync(this.logPath, 'w');
|
|
37
|
+
try {
|
|
38
|
+
fs_1.default.chmodSync(this.logPath, 0o666);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// do nothing
|
|
42
|
+
}
|
|
43
|
+
this.p = (0, pino_1.default)({
|
|
44
|
+
level: process.env.DEBUG === '1' ? 'debug' : 'info',
|
|
45
|
+
timestamp: () => `, "time": "${new Date().toISOString()}"`,
|
|
46
|
+
formatters: {
|
|
47
|
+
bindings: () => ({}),
|
|
48
|
+
level: (label) => ({
|
|
49
|
+
level: label.toUpperCase(),
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
}, pino_1.default.destination(this.logStream));
|
|
53
|
+
this.checkLogSize();
|
|
54
|
+
this.ts = setInterval(() => {
|
|
55
|
+
this.checkLogSize();
|
|
56
|
+
}, 30000);
|
|
57
|
+
}
|
|
58
|
+
return this.p;
|
|
59
|
+
}
|
|
60
|
+
error(...args) {
|
|
61
|
+
this.getPino().error(...args);
|
|
62
|
+
}
|
|
63
|
+
info(...args) {
|
|
64
|
+
this.getPino().info(...args);
|
|
65
|
+
}
|
|
66
|
+
debug(...args) {
|
|
67
|
+
this.getPino().debug(...args);
|
|
68
|
+
}
|
|
69
|
+
fatal(...args) {
|
|
70
|
+
this.getPino().fatal(...args);
|
|
71
|
+
}
|
|
72
|
+
stack() {
|
|
73
|
+
this.getPino().info(new Error().stack);
|
|
74
|
+
}
|
|
75
|
+
changeRootPath(path) {
|
|
76
|
+
if (this.ts) {
|
|
77
|
+
clearInterval(this.ts);
|
|
78
|
+
this.ts = null;
|
|
79
|
+
}
|
|
80
|
+
if (this.logStream) {
|
|
81
|
+
try {
|
|
82
|
+
this.logStream.close();
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// do nothing
|
|
86
|
+
}
|
|
87
|
+
this.logStream = null;
|
|
88
|
+
}
|
|
89
|
+
this.p = null;
|
|
90
|
+
this.rootPath = path;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.default = new Logger();
|