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,191 @@
|
|
|
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 ssh2_1 = require("ssh2");
|
|
7
|
+
const events_1 = __importDefault(require("events"));
|
|
8
|
+
const logger_js_1 = __importDefault(require("../logger.js"));
|
|
9
|
+
const texts_js_1 = require("../texts.js");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
class SshClient extends events_1.default {
|
|
12
|
+
constructor(ip, port, username, password) {
|
|
13
|
+
super();
|
|
14
|
+
this.ip = ip;
|
|
15
|
+
this.port = port;
|
|
16
|
+
this.username = username;
|
|
17
|
+
this.password = password;
|
|
18
|
+
this.keepalive = false;
|
|
19
|
+
}
|
|
20
|
+
async open() {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
this.close();
|
|
23
|
+
this.client = new ssh2_1.Client();
|
|
24
|
+
this.client.setNoDelay();
|
|
25
|
+
this.client.on('ready', () => {
|
|
26
|
+
this.client.removeAllListeners();
|
|
27
|
+
this.client.on('error', () => { });
|
|
28
|
+
resolve();
|
|
29
|
+
});
|
|
30
|
+
this.client.once('error', (err) => {
|
|
31
|
+
this.client.removeAllListeners();
|
|
32
|
+
reject(err);
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
this.client.connect({
|
|
36
|
+
algorithms: {
|
|
37
|
+
cipher: ['aes256-gcm@openssh.com'],
|
|
38
|
+
compress: ['none'],
|
|
39
|
+
hmac: ['hmac-sha2-256-etm@openssh.com'],
|
|
40
|
+
kex: ['ecdh-sha2-nistp256'],
|
|
41
|
+
},
|
|
42
|
+
keepaliveInterval: 60000,
|
|
43
|
+
host: this.ip,
|
|
44
|
+
port: this.port,
|
|
45
|
+
username: this.username,
|
|
46
|
+
password: this.password,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
reject(err);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
waitForStreamReadable(s) {
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
s.once('readable', resolve);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async readStreamBytes(s, toRead) {
|
|
60
|
+
await this.waitForStreamReadable(s);
|
|
61
|
+
const data = s.read(toRead) ?? s.read();
|
|
62
|
+
if (data === null) {
|
|
63
|
+
return this.readStreamBytes(s, toRead);
|
|
64
|
+
}
|
|
65
|
+
const newToRead = toRead - data.length;
|
|
66
|
+
if (newToRead <= 0)
|
|
67
|
+
return data;
|
|
68
|
+
const newData = await this.readStreamBytes(s, newToRead);
|
|
69
|
+
return Buffer.concat([data, newData]);
|
|
70
|
+
}
|
|
71
|
+
async processStream(stream, info) {
|
|
72
|
+
if (stream.readableFlowing)
|
|
73
|
+
stream.pause();
|
|
74
|
+
stream.on('error', () => {
|
|
75
|
+
try {
|
|
76
|
+
stream.removeAllListeners();
|
|
77
|
+
stream.once('error', () => { });
|
|
78
|
+
stream.end();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// do nothing
|
|
82
|
+
}
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
try {
|
|
85
|
+
stream.destroy();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// do nothing
|
|
89
|
+
}
|
|
90
|
+
}, 1000);
|
|
91
|
+
});
|
|
92
|
+
stream.on('close', () => {
|
|
93
|
+
stream.removeAllListeners();
|
|
94
|
+
});
|
|
95
|
+
const triggerStream = (type, ip) => {
|
|
96
|
+
stream.removeAllListeners();
|
|
97
|
+
this.emit(type, stream, info, ip);
|
|
98
|
+
};
|
|
99
|
+
let type;
|
|
100
|
+
let ip;
|
|
101
|
+
try {
|
|
102
|
+
const b = await this.readStreamBytes(stream, 50);
|
|
103
|
+
const s = b.toString('utf8').replace(/\s+/, ' ').split(' ');
|
|
104
|
+
if (s.length !== 2)
|
|
105
|
+
throw new Error(texts_js_1.ERR_WRONG_HANDSHAKE);
|
|
106
|
+
type = parseInt(s[0]);
|
|
107
|
+
ip = s[1];
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
stream.emit('error', err);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (type === utils_1.SOCKET_TYPE_TLS) {
|
|
114
|
+
logger_js_1.default.debug((0, texts_js_1.LOG_DETECTED_STREAM)('TLS'));
|
|
115
|
+
triggerStream(utils_1.SSH_CLIENT_EVENT_STREAM_TLS, ip);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (type === utils_1.SOCKET_TYPE_HTTP1) {
|
|
119
|
+
logger_js_1.default.debug((0, texts_js_1.LOG_DETECTED_STREAM)('HTTP1'));
|
|
120
|
+
triggerStream(utils_1.SSH_CLIENT_EVENT_STREAM_HTTP1, ip);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (type === utils_1.SOCKET_TYPE_HTTP2) {
|
|
124
|
+
logger_js_1.default.debug((0, texts_js_1.LOG_DETECTED_STREAM)('HTTP2'));
|
|
125
|
+
triggerStream(utils_1.SSH_CLIENT_EVENT_STREAM_HTTP2, ip);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (type === utils_1.SOCKET_TYPE_TCP) {
|
|
129
|
+
logger_js_1.default.debug((0, texts_js_1.LOG_DETECTED_STREAM)('TCP'));
|
|
130
|
+
triggerStream(utils_1.SSH_CLIENT_EVENT_STREAM_TCP, ip);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (type === utils_1.SOCKET_TYPE_SSH) {
|
|
134
|
+
logger_js_1.default.debug((0, texts_js_1.LOG_DETECTED_STREAM)('SSH'));
|
|
135
|
+
triggerStream(utils_1.SSH_CLIENT_EVENT_STREAM_SSH, ip);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
logger_js_1.default.debug(texts_js_1.LOG_WRONG_STREAM);
|
|
139
|
+
stream.emit('error', new Error(texts_js_1.ERR_WRONG_STREAM));
|
|
140
|
+
}
|
|
141
|
+
forwardIn(port) {
|
|
142
|
+
return new Promise((resolve, reject) => {
|
|
143
|
+
this.client.on('tcp connection', async (info, accept) => {
|
|
144
|
+
logger_js_1.default.debug(texts_js_1.LOG_SSH_CONNECTION);
|
|
145
|
+
return this.processStream(accept(), info);
|
|
146
|
+
});
|
|
147
|
+
this.client.forwardIn('0.0.0.0', port, (err) => {
|
|
148
|
+
if (err)
|
|
149
|
+
reject(err);
|
|
150
|
+
else
|
|
151
|
+
resolve(err);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
closeKeepAlive() {
|
|
156
|
+
this.keepalive = false;
|
|
157
|
+
this.close();
|
|
158
|
+
}
|
|
159
|
+
openKeepAlive() {
|
|
160
|
+
this.keepalive = true;
|
|
161
|
+
this.open()
|
|
162
|
+
.then(() => {
|
|
163
|
+
this.emit(utils_1.SSH_CLIENT_EVENT_CONNECTED);
|
|
164
|
+
this.client.on('close', () => {
|
|
165
|
+
if (this.keepalive)
|
|
166
|
+
this.openKeepAlive();
|
|
167
|
+
});
|
|
168
|
+
})
|
|
169
|
+
.catch(() => {
|
|
170
|
+
this.emit(utils_1.SSH_CLIENT_EVENT_DISCONNECTED);
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
if (this.keepalive)
|
|
173
|
+
this.openKeepAlive();
|
|
174
|
+
}, 3000);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
close() {
|
|
178
|
+
if (this.client) {
|
|
179
|
+
try {
|
|
180
|
+
this.client.removeAllListeners();
|
|
181
|
+
this.client.on('error', () => { });
|
|
182
|
+
this.client.end();
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
// nic nie rob
|
|
186
|
+
}
|
|
187
|
+
this.client = null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.default = SshClient;
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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_LIMIT_REACHED = exports.ERR_SUBDOMAIN_TAKEN = exports.ERR_AGENT_REMOVED = exports.ERR_FAILED_TO_CONNECT = exports.ERR_TUNNEL_ALREADY_EXISTS = exports.ERR_AGENT_NOT_SUPPORTED = exports.ERR_AGENT_ADMIN_RIGHTS = exports.ERR_AGENT_ENABLE = exports.ERR_SWW_AGENT_UPDATING = exports.ERR_SWW_AGENT_DISABLING = exports.ERR_SWW_AGENT_ENABLING = exports.ERR_AGENT_NOT_FOUND = exports.ERR_AGENT_NOT_RUNNING = 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_DOMAIN_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_SUBDOMAIN_IS_TOO_LONG = exports.ERR_SUBDOMAIN_IS_TOO_SHORT = exports.ERR_SUBDOMAIN_IS_NOT_VALID = 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 = void 0;
|
|
4
|
+
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_IS_DISABLED = exports.TXT_AGENT_IS_ENABLED_AND_HAVE_TROUBLES = exports.TXT_AGENT_IS_ENABLED_AND_INITIALIZING = exports.TXT_AGENT_IS_ENABLED_AND_STOPPED = exports.TXT_AGENT_IS_ENABLED_AND_STARTED = exports.TXT_AGENT_RESTARTED = exports.TXT_AGENT_STARTED = exports.TXT_AGENT_STOPPED = exports.ERR_GETTING_COMMIT_DETAILS = exports.ERR_GETTING_BASE_COMMIT = exports.ERR_HEAD_BRANCH_NOT_DEFINED = exports.ERR_BASE_BRANCH_NOT_DEFINED = exports.ERR_INVALID_COMMIT_HASH = exports.ERR_GETTING_COMMIT_HASH = exports.ERR_INVALID_BRANCH_NAME = exports.ERR_GETTING_BRANCH_NAME = exports.ERR_MISSING_HEAD_COMMIT_IN_FILE = exports.ERR_READING_FILE_WITH_HEAD_COMMIT = exports.ERR_MISSING_FILE_WITH_HEAD_COMMIT = exports.ERR_GITHUB_EVENT_PATH_NOT_FOUND = exports.ERR_TEST_EXECUTION = exports.ERR_INVALID_JSON = 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_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_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 = void 0;
|
|
5
|
+
exports.DESC_COMMAND_VT_STORYBOOK = exports.DESC_COMMAND_VT_CLOSE = exports.DESC_COMMAND_VT = exports.DESC_PROGRAM = exports.DESC_COMMAND_TLS = exports.DESC_COMMAND_TCP = exports.DESC_COMMAND_START = 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_TUNNEL = exports.DESC_COMMAND_AGENT_STOP = exports.DESC_COMMAND_AGENT_STATUS = exports.DESC_COMMAND_AGENT_RESTART = exports.DESC_COMMAND_AGENT_START = exports.DESC_COMMAND_AGENT_INSTALL = exports.DESC_COMMAND_AGENT_UNINSTALL = exports.DESC_COMMAND_AGENT_TUNNEL_TLS = exports.DESC_COMMAND_AGENT_TUNNEL_TCP = exports.DESC_COMMAND_AGENT_TUNNEL_REMOVE = exports.DESC_COMMAND_AGENT_TUNNEL_STATUS = exports.DESC_COMMAND_AGENT_TUNNEL_START = exports.DESC_COMMAND_AGENT_TUNNEL_LIST = exports.DESC_COMMAND_AGENT_TUNNEL_HTTP = 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 = 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_TUNNEL_ADDED = exports.TXT_TUNNEL_REMOVED = exports.TXT_REGION_SAVED = exports.TXT_TIMEOUT_SAVED = void 0;
|
|
6
|
+
exports.LOG_SAVING_AGENT_CONFIG = exports.LOG_REGISTERING_AGENT = 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_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 = 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 = exports.OPTION_HTTP_HOST = exports.OPTION_FORCE = exports.OPTION_TOKEN = exports.OPTION_TIMEOUT = exports.OPTION_DOMAIN = exports.OPTION_FOLLOW = exports.OPTION_SUBDOMAIN = exports.OPTION_SERVE = exports.OPTION_HEADER_USER_AGENT = exports.OPTION_RESPONSE_HEADER = exports.OPTION_HEADER = exports.OPTION_WHITELIST = exports.OPTION_DEFAULT_REGION = exports.OPTION_REGION = exports.TXT_CI_INFO = exports.TXT_STORIES_AMOUNT = exports.TXT_OPENING_TUNNEL = exports.TXT_UPDATING_AGENT = exports.TXT_ENABLING_AGENT = exports.TXT_DISABLING_AGENT = exports.TXT_NEW_AGENT_VERSION = exports.TXT_NEW_CLI_VERSION = exports.TXT_NEW_CLI_DOCKER_VERSION = exports.DESC_COMMAND_VT_EXEC = void 0;
|
|
7
|
+
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_REQUEST = 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_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 = exports.LOG_ERROR_SAVING_AGENT_SYSTEM_CONFIG = exports.LOG_ERROR_SAVING_AGENT_CONFIG = exports.LOG_SAVING_AGENT_LOCAL_CONFIG = exports.LOG_SAVING_AGENT_SYSTEM_CONFIG = void 0;
|
|
8
|
+
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_SENDING_REQUEST = exports.LOG_PROCESSING_SNAPSHOTS = exports.LOG_INSTALLED_BROWSER = exports.LOG_RUNNING_EXEC_COMMAND = exports.LOG_TUNNEL_SSH_STREAM = exports.LOG_TUNNEL_TLS_AGENT_STREAM = exports.LOG_TUNNEL_TLS_REGION_STREAM = exports.LOG_TUNNEL_TLS_TARGET_STREAM = exports.LOG_TUNNEL_HTTP2_STREAM = void 0;
|
|
9
|
+
exports.ERR_AGENT_NOT_REGISTERED = 'Agent not registered. Exiting.';
|
|
10
|
+
exports.ERR_SAVING_AGENT_CONFIG = 'Failed saving agent config. Exiting.';
|
|
11
|
+
const ERR_TARGET_IS_NOT_VALID = (target) => `Target '${target}' invalid`;
|
|
12
|
+
exports.ERR_TARGET_IS_NOT_VALID = ERR_TARGET_IS_NOT_VALID;
|
|
13
|
+
const ERR_TYPE_IS_NOT_VALID = (type) => `Type '${type}' invalid`;
|
|
14
|
+
exports.ERR_TYPE_IS_NOT_VALID = ERR_TYPE_IS_NOT_VALID;
|
|
15
|
+
const ERR_TIMEOUT_IS_NOT_VALID = (timeout) => `Timeout '${timeout}' invalid`;
|
|
16
|
+
exports.ERR_TIMEOUT_IS_NOT_VALID = ERR_TIMEOUT_IS_NOT_VALID;
|
|
17
|
+
const ERR_TERMINATE_IS_NOT_VALID = (terminate) => `Terminate '${terminate}' invalid`;
|
|
18
|
+
exports.ERR_TERMINATE_IS_NOT_VALID = ERR_TERMINATE_IS_NOT_VALID;
|
|
19
|
+
const ERR_SUBDOMAIN_IS_NOT_VALID = (subdomain) => `Subdomain '${subdomain}' invalid`;
|
|
20
|
+
exports.ERR_SUBDOMAIN_IS_NOT_VALID = ERR_SUBDOMAIN_IS_NOT_VALID;
|
|
21
|
+
const ERR_SUBDOMAIN_IS_TOO_SHORT = (subdomain) => `Subdomain '${subdomain}' is too short`;
|
|
22
|
+
exports.ERR_SUBDOMAIN_IS_TOO_SHORT = ERR_SUBDOMAIN_IS_TOO_SHORT;
|
|
23
|
+
const ERR_SUBDOMAIN_IS_TOO_LONG = (subdomain) => `Subdomain '${subdomain}' is too long`;
|
|
24
|
+
exports.ERR_SUBDOMAIN_IS_TOO_LONG = ERR_SUBDOMAIN_IS_TOO_LONG;
|
|
25
|
+
const ERR_DIRECTORY_DOES_NOT_EXISTS = (dir) => `Directory '${dir}' does not exists`;
|
|
26
|
+
exports.ERR_DIRECTORY_DOES_NOT_EXISTS = ERR_DIRECTORY_DOES_NOT_EXISTS;
|
|
27
|
+
const ERR_PATH_IS_NOT_DIRECTORY = (path) => `Path '${path}' is not a directory`;
|
|
28
|
+
exports.ERR_PATH_IS_NOT_DIRECTORY = ERR_PATH_IS_NOT_DIRECTORY;
|
|
29
|
+
const ERR_REGION_IS_NOT_VALID = (region) => `Region '${region}' invalid`;
|
|
30
|
+
exports.ERR_REGION_IS_NOT_VALID = ERR_REGION_IS_NOT_VALID;
|
|
31
|
+
const ERR_PORT_IS_NOT_VALID = (port) => `Port '${port}' invalid`;
|
|
32
|
+
exports.ERR_PORT_IS_NOT_VALID = ERR_PORT_IS_NOT_VALID;
|
|
33
|
+
exports.ERR_NAME_WITHOUT_ASTERISK = "Name: no '*' allowed";
|
|
34
|
+
exports.ERR_WRONG_KEY_CERT = 'Invalid TLS key or cert';
|
|
35
|
+
const ERR_WRONG_CA = (path) => `TLS CA certificate '${path}'invalid`;
|
|
36
|
+
exports.ERR_WRONG_CA = ERR_WRONG_CA;
|
|
37
|
+
const ERR_CA_PATH_IS_NOT_VALID = (path) => `Invalid TLS CA cert path: '${path}'`;
|
|
38
|
+
exports.ERR_CA_PATH_IS_NOT_VALID = ERR_CA_PATH_IS_NOT_VALID;
|
|
39
|
+
const ERR_KEY_PATH_IS_NOT_VALID = (path) => `Invalid TLS key path: '${path}'`;
|
|
40
|
+
exports.ERR_KEY_PATH_IS_NOT_VALID = ERR_KEY_PATH_IS_NOT_VALID;
|
|
41
|
+
const ERR_CERT_PATH_IS_NOT_VALID = (path) => `Invalid TLS cert path: '${path}'`;
|
|
42
|
+
exports.ERR_CERT_PATH_IS_NOT_VALID = ERR_CERT_PATH_IS_NOT_VALID;
|
|
43
|
+
const ERR_DOMAIN_IS_NOT_VALID = (domain) => `Domain '${domain}' invalid`;
|
|
44
|
+
exports.ERR_DOMAIN_IS_NOT_VALID = ERR_DOMAIN_IS_NOT_VALID;
|
|
45
|
+
const ERR_CB_THRESHOLD_IS_NOT_VALID = (val) => `Circuit breaker threshold '${val}' invalid`;
|
|
46
|
+
exports.ERR_CB_THRESHOLD_IS_NOT_VALID = ERR_CB_THRESHOLD_IS_NOT_VALID;
|
|
47
|
+
exports.ERR_BA_PASSWORD_NOT_PROVIDED = 'HTTP BA password not provided';
|
|
48
|
+
exports.ERR_BA_LOGIN_NOT_PROVIDED = 'HTTP BA username not provided';
|
|
49
|
+
const ERR_BA_IS_NOT_VALID = (auth) => `HTTP BA '${auth}' invalid`;
|
|
50
|
+
exports.ERR_BA_IS_NOT_VALID = ERR_BA_IS_NOT_VALID;
|
|
51
|
+
const ERR_USER_AGENT_IS_NOT_VALID = (ua) => `Invalid User-Agent regex: '${ua}'`;
|
|
52
|
+
exports.ERR_USER_AGENT_IS_NOT_VALID = ERR_USER_AGENT_IS_NOT_VALID;
|
|
53
|
+
const ERR_WHITELIST_IS_NOT_VALID = (wh) => `Invalid CIDR: '${wh}'`;
|
|
54
|
+
exports.ERR_WHITELIST_IS_NOT_VALID = ERR_WHITELIST_IS_NOT_VALID;
|
|
55
|
+
const ERR_TUNNEL_NOT_FOUND = (name) => `Tunnel '${name}' not found`;
|
|
56
|
+
exports.ERR_TUNNEL_NOT_FOUND = ERR_TUNNEL_NOT_FOUND;
|
|
57
|
+
exports.ERR_AGENT_NOT_ENABLED = 'Agent not installed';
|
|
58
|
+
exports.ERR_AGENT_NOT_RUNNING = 'Agent not running';
|
|
59
|
+
exports.ERR_AGENT_NOT_FOUND = 'Agent not found';
|
|
60
|
+
exports.ERR_SWW_AGENT_ENABLING = 'Failed installing agent';
|
|
61
|
+
exports.ERR_SWW_AGENT_DISABLING = 'Failed uninstalling agent';
|
|
62
|
+
exports.ERR_SWW_AGENT_UPDATING = 'Failed updating agent';
|
|
63
|
+
exports.ERR_AGENT_ENABLE = 'Agent disabled: install first';
|
|
64
|
+
exports.ERR_AGENT_ADMIN_RIGHTS = 'Command must be run with administrator rights';
|
|
65
|
+
exports.ERR_AGENT_NOT_SUPPORTED = 'Starting agent is not supported';
|
|
66
|
+
exports.ERR_TUNNEL_ALREADY_EXISTS = 'Tunnel name exists: change or use -f to overwrite';
|
|
67
|
+
const ERR_FAILED_TO_CONNECT = (host) => `Failed to connect to '${host}'`;
|
|
68
|
+
exports.ERR_FAILED_TO_CONNECT = ERR_FAILED_TO_CONNECT;
|
|
69
|
+
exports.ERR_AGENT_REMOVED = 'Agent has been removed';
|
|
70
|
+
exports.ERR_SUBDOMAIN_TAKEN = 'Subdomain name unavailable';
|
|
71
|
+
exports.ERR_TUNNEL_LIMIT_REACHED = 'Tunnels limit reached';
|
|
72
|
+
exports.ERR_AGENT_LIMIT_REACHED = 'Agents limit reached';
|
|
73
|
+
exports.ERR_TUNNELS_DISABLED = 'Tunnels disabled';
|
|
74
|
+
exports.ERR_TUNNEL_REMOVED = 'Tunnel removed';
|
|
75
|
+
exports.ERR_FAILED_TO_CONNECT_TO_AGENT = 'Failed connecting to agent';
|
|
76
|
+
exports.ERR_NOT_FOUND = 'Not found';
|
|
77
|
+
exports.ERR_SWW = 'Something went wrong';
|
|
78
|
+
exports.ERR_FETCH_VERSION = 'Failed to fetch version';
|
|
79
|
+
exports.ERR_WRONG_HANDSHAKE = 'Wrong handshake data';
|
|
80
|
+
exports.ERR_WRONG_STREAM = 'Wrong stream type';
|
|
81
|
+
exports.ERR_CONNECTION_TIMEOUT = 'Connection timeout';
|
|
82
|
+
exports.ERR_CONNECTION_ERROR = 'Connection error';
|
|
83
|
+
const ERR_CANT_CREATE_DIR_IN_HOME = (dir) => `Can't create '${dir}' in home directory`;
|
|
84
|
+
exports.ERR_CANT_CREATE_DIR_IN_HOME = ERR_CANT_CREATE_DIR_IN_HOME;
|
|
85
|
+
exports.ERR_TOKEN_NOT_PROVIDED = 'Token not provided';
|
|
86
|
+
exports.ERR_WRONG_TOKEN = 'Wrong token';
|
|
87
|
+
exports.ERR_CONFIG_CORRUPTED = 'Config file is corrupted';
|
|
88
|
+
exports.ERR_MISSING_TOKEN = 'No token provided. Please provide a token with the SNAPSHOTS_TOKEN environment variable.';
|
|
89
|
+
exports.ERR_MISSING_BUILD_ID = 'No buildId provided. Please provide a buildId with the SNAPSHOTS_BUILD_ID environment variable.';
|
|
90
|
+
exports.ERR_WRONG_STORYBOOK_DIRECTORY = 'Current directory is not a storybook directory';
|
|
91
|
+
exports.ERR_MISSING_STORYBOOK_INDEX_FILE = 'Storybook index.json not found';
|
|
92
|
+
exports.ERR_UNSUPPORTED_STORYBOOK = 'Unsupported storybook version';
|
|
93
|
+
exports.ERR_PARSING_STORIES = 'Error parsing stories list';
|
|
94
|
+
const ERR_MISSING_EXEC_COMMAND = (command) => `Command not fund ${command}`;
|
|
95
|
+
exports.ERR_MISSING_EXEC_COMMAND = ERR_MISSING_EXEC_COMMAND;
|
|
96
|
+
const ERR_RESOURCE_NOT_FOUND = (resourceUrl) => `Resource ${resourceUrl} not found`;
|
|
97
|
+
exports.ERR_RESOURCE_NOT_FOUND = ERR_RESOURCE_NOT_FOUND;
|
|
98
|
+
exports.ERR_INVALID_SNAPSHOT_RESPONSE = `Invalid send snapshot response`;
|
|
99
|
+
exports.ERR_INVALID_SNAPSHOTS_RESPONSE = `Invalid send snapshots response`;
|
|
100
|
+
exports.ERR_INVALID_CLOSE_SESSION_RESPONSE = `Invalid close session response`;
|
|
101
|
+
exports.ERR_INVALID_DEFAULT_SETTINGS_RESPONSE = `Invalid default settings response`;
|
|
102
|
+
exports.ERR_INVALID_STORYBOOK_RESPONSE = `Invalid send storybook response`;
|
|
103
|
+
exports.ERR_INVALID_JSON = `Invalid JSON`;
|
|
104
|
+
exports.ERR_TEST_EXECUTION = `Test process exited with error`;
|
|
105
|
+
exports.ERR_GITHUB_EVENT_PATH_NOT_FOUND = `GITHUB_EVENT_PATH is not defined`;
|
|
106
|
+
const ERR_MISSING_FILE_WITH_HEAD_COMMIT = (payloadPath, error) => `File ${payloadPath} with correct head commit does not exist: ${error}`;
|
|
107
|
+
exports.ERR_MISSING_FILE_WITH_HEAD_COMMIT = ERR_MISSING_FILE_WITH_HEAD_COMMIT;
|
|
108
|
+
const ERR_READING_FILE_WITH_HEAD_COMMIT = (payloadPath, error) => `Error while reading ${payloadPath} file: ${error}`;
|
|
109
|
+
exports.ERR_READING_FILE_WITH_HEAD_COMMIT = ERR_READING_FILE_WITH_HEAD_COMMIT;
|
|
110
|
+
exports.ERR_MISSING_HEAD_COMMIT_IN_FILE = `Payload does not contain pull_request`;
|
|
111
|
+
const ERR_GETTING_BRANCH_NAME = (error) => `Error while getting branch name: ${error}`;
|
|
112
|
+
exports.ERR_GETTING_BRANCH_NAME = ERR_GETTING_BRANCH_NAME;
|
|
113
|
+
exports.ERR_INVALID_BRANCH_NAME = `Invalid branch name`;
|
|
114
|
+
const ERR_GETTING_COMMIT_HASH = (error) => `Error while getting commit hash: ${error}`;
|
|
115
|
+
exports.ERR_GETTING_COMMIT_HASH = ERR_GETTING_COMMIT_HASH;
|
|
116
|
+
const ERR_INVALID_COMMIT_HASH = (commit) => `Invalid commit hash: ${commit}`;
|
|
117
|
+
exports.ERR_INVALID_COMMIT_HASH = ERR_INVALID_COMMIT_HASH;
|
|
118
|
+
exports.ERR_BASE_BRANCH_NOT_DEFINED = `Base branch is not defined`;
|
|
119
|
+
exports.ERR_HEAD_BRANCH_NOT_DEFINED = `Head branch is not defined`;
|
|
120
|
+
const ERR_GETTING_BASE_COMMIT = (baseBranch, headBranch, error) => `Error while getting base commit with command 'git merge-base ${baseBranch} ${headBranch}': ${error}`;
|
|
121
|
+
exports.ERR_GETTING_BASE_COMMIT = ERR_GETTING_BASE_COMMIT;
|
|
122
|
+
const ERR_GETTING_COMMIT_DETAILS = (error) => `Error while getting commit details: ${error}`;
|
|
123
|
+
exports.ERR_GETTING_COMMIT_DETAILS = ERR_GETTING_COMMIT_DETAILS;
|
|
124
|
+
exports.TXT_AGENT_STOPPED = 'Agent stopped';
|
|
125
|
+
exports.TXT_AGENT_STARTED = 'Agent started';
|
|
126
|
+
exports.TXT_AGENT_RESTARTED = 'Agent restarted';
|
|
127
|
+
exports.TXT_AGENT_IS_ENABLED_AND_STARTED = 'Agent is installed & started';
|
|
128
|
+
exports.TXT_AGENT_IS_ENABLED_AND_STOPPED = 'Agent is installed & stopped';
|
|
129
|
+
exports.TXT_AGENT_IS_ENABLED_AND_INITIALIZING = 'Agent is installed & initializing';
|
|
130
|
+
exports.TXT_AGENT_IS_ENABLED_AND_HAVE_TROUBLES = 'Agent is installed [connection issues detected]';
|
|
131
|
+
exports.TXT_AGENT_IS_DISABLED = 'Agent is not installed';
|
|
132
|
+
exports.TXT_AGENT_ENABLED = 'Agent installed';
|
|
133
|
+
exports.TXT_AGENT_UPDATED = 'Agent updated';
|
|
134
|
+
exports.TXT_AGENT_ALREADY_ENABLED = 'Agent already installed';
|
|
135
|
+
exports.TXT_AGENT_DISABLED = 'Agent uninstalled';
|
|
136
|
+
const TXT_TUNNEL_STARTED = (type) => `${type} tunnel started`;
|
|
137
|
+
exports.TXT_TUNNEL_STARTED = TXT_TUNNEL_STARTED;
|
|
138
|
+
exports.TXT_TUNNEL_STOPPED = 'Tunnel stopped';
|
|
139
|
+
exports.TXT_WHITELIST_SAVED = 'Whitelist saved';
|
|
140
|
+
exports.TXT_TOKEN_SAVED = 'Token saved';
|
|
141
|
+
exports.TXT_TOKEN_REMOVED = 'Token cleared';
|
|
142
|
+
exports.TXT_TIMEOUT_SAVED = 'Timeout saved';
|
|
143
|
+
exports.TXT_REGION_SAVED = 'Region saved';
|
|
144
|
+
exports.TXT_TUNNEL_REMOVED = 'Tunnel removed';
|
|
145
|
+
exports.TXT_TUNNEL_ADDED = 'Tunnel added';
|
|
146
|
+
exports.NO_TUNNELS_STARTED = 'No tunnels started';
|
|
147
|
+
exports.AGENT_FETCH_RETRY = 'Agent fetch failed. Retrying in 3s...';
|
|
148
|
+
exports.DESC_COMMAND_CONFIG_ADD_HTTP = 'Add a new HTTP tunnel';
|
|
149
|
+
exports.DESC_COMMAND_CONFIG_ADD_TCP = 'Add a new TCP tunnel';
|
|
150
|
+
exports.DESC_COMMAND_CONFIG_ADD_TLS = 'Add a new TLS tunnel';
|
|
151
|
+
exports.DESC_COMMAND_CONFIG_GET_REGION = 'Get region configuration';
|
|
152
|
+
exports.DESC_COMMAND_CONFIG_GET_TIMEOUT = 'Get timeout configuration';
|
|
153
|
+
exports.DESC_COMMAND_CONFIG_GET_TOKEN = 'Get token configuration';
|
|
154
|
+
exports.DESC_COMMAND_CONFIG_GET_TUNNEL = 'Get tunnel configuration';
|
|
155
|
+
exports.DESC_COMMAND_CONFIG_GET_TUNNELS = 'Get tunnels configuration';
|
|
156
|
+
exports.DESC_COMMAND_CONFIG_GET_WHITELIST = 'Get IP access restrictions';
|
|
157
|
+
exports.DESC_COMMAND_CONFIG_REMOVE_TUNNEL = 'Remove tunnel configuration';
|
|
158
|
+
exports.DESC_COMMAND_CONFIG_SET_REGION = 'Set region';
|
|
159
|
+
exports.DESC_COMMAND_CONFIG_SET_TIMEOUT = 'Set timeout';
|
|
160
|
+
exports.DESC_COMMAND_CONFIG_SET_TOKEN = 'Set token';
|
|
161
|
+
exports.DESC_COMMAND_CONFIG_SET_WHITELIST = 'Set IP access restrictions';
|
|
162
|
+
exports.DESC_COMMAND_CONFIG_ADD = 'Add a new HTTP/TCP/TLS tunnel';
|
|
163
|
+
exports.DESC_COMMAND_CONFIG_GET = 'Get configuration tunnel/token/region/whitelist/timeout';
|
|
164
|
+
exports.DESC_COMMAND_CONFIG_REMOVE = 'Remove tunnels configuration';
|
|
165
|
+
exports.DESC_COMMAND_CONFIG_SET = 'Set configuration token/region/whitelist/timeout';
|
|
166
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_HTTP = "Manage agent's tunnels";
|
|
167
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_LIST = "Manage agent's tunnels";
|
|
168
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_START = "Manage agent's tunnels";
|
|
169
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_STATUS = "Manage agent's tunnels";
|
|
170
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_REMOVE = "Manage agent's tunnels";
|
|
171
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_TCP = "Manage agent's tunnels";
|
|
172
|
+
exports.DESC_COMMAND_AGENT_TUNNEL_TLS = "Manage agent's tunnels";
|
|
173
|
+
exports.DESC_COMMAND_AGENT_UNINSTALL = 'Uninstall bdy service';
|
|
174
|
+
exports.DESC_COMMAND_AGENT_INSTALL = 'Install bdy as operating system service on Windows, OS X and Linux systems';
|
|
175
|
+
exports.DESC_COMMAND_AGENT_START = 'Starts agent and all tunnels from configuration file';
|
|
176
|
+
exports.DESC_COMMAND_AGENT_RESTART = 'Restarts agent and all tunnels';
|
|
177
|
+
exports.DESC_COMMAND_AGENT_STATUS = 'Show the status of Buddy agent';
|
|
178
|
+
exports.DESC_COMMAND_AGENT_STOP = 'Stops agent and all tunnels';
|
|
179
|
+
exports.DESC_COMMAND_AGENT_TUNNEL = "Manage agent's tunnels";
|
|
180
|
+
exports.DESC_COMMAND_AGENT_UPDATE = 'Install a new version of Buddy agent';
|
|
181
|
+
exports.DESC_COMMAND_AGENT_VERSION = 'Show the currently installed version';
|
|
182
|
+
exports.DESC_COMMAND_CONFIG = 'The config command gives a quick way to create or update configuration file.';
|
|
183
|
+
exports.DESC_COMMAND_HTTP = 'Starts a tunnel listening for HTTP/HTTPS traffic with a specific hostname.';
|
|
184
|
+
exports.DESC_COMMAND_AGENT = 'The agent command manages installation and execution of bdy as an operating system service on Windows, OS X and Linux systems';
|
|
185
|
+
exports.DESC_COMMAND_START = 'Starts tunnel from the configuration file.';
|
|
186
|
+
exports.DESC_COMMAND_TCP = 'Starts a tunnel which forwards all TCP traffic on a public port to a local address. This is extremely useful for exposing services that run non-HTTP traffic (ssh, sip, rdp, game servers, etc).';
|
|
187
|
+
exports.DESC_COMMAND_TLS = 'Starts a tunnel listening for TLS traffic on port 443 with a specific hostname.';
|
|
188
|
+
exports.DESC_PROGRAM = 'Buddy exposes local networked services behinds NATs and firewalls to the public internet over a secure tunnel. Share local websites, build/test webhook consumers, and self-host personal services.';
|
|
189
|
+
exports.DESC_COMMAND_VT = 'Commands to interact with the visual test service';
|
|
190
|
+
exports.DESC_COMMAND_VT_CLOSE = 'Close visual test session.';
|
|
191
|
+
exports.DESC_COMMAND_VT_STORYBOOK = 'Create visual test session from storybook';
|
|
192
|
+
exports.DESC_COMMAND_VT_EXEC = 'Run tests which use visual service plugin';
|
|
193
|
+
const TXT_NEW_CLI_DOCKER_VERSION = (version) => `A new version of bdy Docker image is available! (${version})\n\n`;
|
|
194
|
+
exports.TXT_NEW_CLI_DOCKER_VERSION = TXT_NEW_CLI_DOCKER_VERSION;
|
|
195
|
+
const TXT_NEW_CLI_VERSION = (version) => `A new version of bdy is available! (${version})\n\n`;
|
|
196
|
+
exports.TXT_NEW_CLI_VERSION = TXT_NEW_CLI_VERSION;
|
|
197
|
+
const TXT_NEW_AGENT_VERSION = () => 'Agent upgrade required. Update the agent by running:\n`bdy agent update`\n\n';
|
|
198
|
+
exports.TXT_NEW_AGENT_VERSION = TXT_NEW_AGENT_VERSION;
|
|
199
|
+
exports.TXT_DISABLING_AGENT = 'Uninstalling agent...';
|
|
200
|
+
exports.TXT_ENABLING_AGENT = 'Installing agent...';
|
|
201
|
+
exports.TXT_UPDATING_AGENT = 'Updating agent...';
|
|
202
|
+
exports.TXT_OPENING_TUNNEL = 'Opening tunnel...';
|
|
203
|
+
const TXT_STORIES_AMOUNT = (amount) => `Found ${amount} stories`;
|
|
204
|
+
exports.TXT_STORIES_AMOUNT = TXT_STORIES_AMOUNT;
|
|
205
|
+
const TXT_CI_INFO = (ciInfo) => `CI: ${ciInfo.ci}\nBranch: ${ciInfo.branch}\nCommit: ${ciInfo.commit}\nBase commit: ${ciInfo.baseCommit}`;
|
|
206
|
+
exports.TXT_CI_INFO = TXT_CI_INFO;
|
|
207
|
+
exports.OPTION_REGION = 'override default region ("eu", "us")';
|
|
208
|
+
exports.OPTION_DEFAULT_REGION = 'default region ("eu", "us")';
|
|
209
|
+
exports.OPTION_WHITELIST = 'whitelist provided IP CIDRs. Use "*" to allow all';
|
|
210
|
+
exports.OPTION_HEADER = 'header key:value to add to the request';
|
|
211
|
+
exports.OPTION_RESPONSE_HEADER = 'header key:value to add to the response';
|
|
212
|
+
exports.OPTION_HEADER_USER_AGENT = 'whitelist browser user-agent by contained text or regular expressions (e.g. /my-user-agent/). By Default all are allowed';
|
|
213
|
+
exports.OPTION_SERVE = 'serve files from a directory';
|
|
214
|
+
exports.OPTION_SUBDOMAIN = 'provide custom subdomain';
|
|
215
|
+
exports.OPTION_FOLLOW = 'follow tunnel details';
|
|
216
|
+
exports.OPTION_DOMAIN = 'provide custom domain';
|
|
217
|
+
exports.OPTION_TIMEOUT = 'enforce connection timeout in seconds';
|
|
218
|
+
exports.OPTION_TOKEN = 'token to authorize agent';
|
|
219
|
+
exports.OPTION_FORCE = 'overwrite tunnel if it already exist';
|
|
220
|
+
exports.OPTION_HTTP_HOST = 'provide custom HTTP host header';
|
|
221
|
+
exports.OPTION_HTTP_AUTH = 'enforce HTTP basic authorization';
|
|
222
|
+
exports.OPTION_HTTP_LOG = 'log HTTP requests';
|
|
223
|
+
exports.OPTION_HTTP_VERIFY = 'enforce TLS verify';
|
|
224
|
+
exports.OPTION_HTTP_2 = 'enforce HTTP/2';
|
|
225
|
+
exports.OPTION_HTTP_COMPRESSION = 'turn on HTTP response compression';
|
|
226
|
+
exports.OPTION_HTTP_CIRCUIT_BREAKER = 'turn on circuit breaker. Provide decimal value between 0 to 1';
|
|
227
|
+
exports.OPTION_TLS_KEY = 'path to a TLS key';
|
|
228
|
+
exports.OPTION_TLS_CERT = 'path to a TLS PEM certificate';
|
|
229
|
+
exports.OPTION_TLS_CA = 'path to a TLS PEM CA certificate for TLS auth';
|
|
230
|
+
exports.OPTION_TLS_TERMINATE = 'terminate TLS at "target", "agent", "region". By default TLS is terminated at "region"';
|
|
231
|
+
exports.OPTION_TARGET = 'target address to redirect traffic to. Host is optional and by default local machine. Port is by default 80';
|
|
232
|
+
exports.OPTION_NAME = 'name of the tunnel';
|
|
233
|
+
exports.OPTION_ID = 'id of the tunnel';
|
|
234
|
+
exports.OPTION_AGENT_ID = 'start existing agent';
|
|
235
|
+
exports.OPTION_AGENT_START = 'start agent right away';
|
|
236
|
+
exports.OPTION_AGENT_TOKEN = 'token to authorize existing agent agent or token to add a new agent';
|
|
237
|
+
exports.OPTION_USER = 'OS user name. Default: root (macOS/Linux), LocalSystem (Windows. Provide as DOMAIN\\USER (use `whoami` to get full username)';
|
|
238
|
+
exports.OPTION_PASS = 'password of the user. Only set for Windows';
|
|
239
|
+
exports.OPTION_AGENT_PORT = 'agent API port';
|
|
240
|
+
exports.OPTION_AGENT_DEBUG = 'turns on debug mode';
|
|
241
|
+
exports.OPTION_EXEC_COMMAND = 'Test runner command';
|
|
242
|
+
exports.OPTION_EXEC_SKIP_DISCOVERY = 'Skip resource discovery';
|
|
243
|
+
exports.OPTION_EXEC_ONE_BY_ONE = 'Send snapshots one by one';
|
|
244
|
+
exports.OPTION_EXEC_PARALLEL = 'Send parts of session from different processes';
|
|
245
|
+
exports.LOG_REGISTERING_AGENT = 'Registering agent...';
|
|
246
|
+
exports.LOG_SAVING_AGENT_CONFIG = 'Saving agent config...';
|
|
247
|
+
exports.LOG_SAVING_AGENT_SYSTEM_CONFIG = 'Saving agent system config...';
|
|
248
|
+
exports.LOG_SAVING_AGENT_LOCAL_CONFIG = 'Saving agent local config...';
|
|
249
|
+
exports.LOG_ERROR_SAVING_AGENT_CONFIG = 'Error while saving agent config';
|
|
250
|
+
exports.LOG_ERROR_SAVING_AGENT_SYSTEM_CONFIG = 'Error while saving agent system config';
|
|
251
|
+
exports.LOG_ERROR_SAVING_AGENT_LOCAL_CONFIG = 'Error while saving agent local config';
|
|
252
|
+
exports.LOG_AGENT_SYSTEM_DIR = 'Creating agent system directory...';
|
|
253
|
+
exports.LOG_AGENT_DOWNLOADING_ARCHIVE = 'Downloading agent archive...';
|
|
254
|
+
exports.LOG_AGENT_EXTRACTING_ARCHIVE = 'Extracting agent archive...';
|
|
255
|
+
exports.LOG_AGENT_SYSTEM_SERVICE_CONFIG = 'Saving agent system service config...';
|
|
256
|
+
exports.LOG_AGENT_ENABLING_SYSTEM = 'Installing agent in system...';
|
|
257
|
+
exports.LOG_AGENT_STOPPING_SYSTEM = 'Stopping agent in system...';
|
|
258
|
+
exports.LOG_AGENT_STARTING_SYSTEM = 'Starting agent in system...';
|
|
259
|
+
exports.LOG_AGENT_ENABLED = 'Agent installed in system';
|
|
260
|
+
exports.LOG_AGENT_NSSM_DOWNLOADING = 'Agent nssm downloading...';
|
|
261
|
+
exports.LOG_AGENT_NSSM_EXTRACTING = 'Agent nssm extracting...';
|
|
262
|
+
exports.LOG_AGENT_NSSM_CLEARING = 'Agent nssm clearing...';
|
|
263
|
+
exports.LOG_SOCKET_CONNECTED = 'Socket connected';
|
|
264
|
+
exports.LOG_SOCKET_DISCONNECTED = 'Socket disconnected';
|
|
265
|
+
const LOG_AGENT_REGISTERED = (id) => `Agent registered with id '${id}'`;
|
|
266
|
+
exports.LOG_AGENT_REGISTERED = LOG_AGENT_REGISTERED;
|
|
267
|
+
const LOG_REGION_DETECTED = (region) => `Detected region '${region}'`;
|
|
268
|
+
exports.LOG_REGION_DETECTED = LOG_REGION_DETECTED;
|
|
269
|
+
exports.LOG_UNREGISTERING_AGENT = 'Unregistering agent...';
|
|
270
|
+
exports.LOG_GETTING_AGENT = 'Getting agent...';
|
|
271
|
+
exports.LOG_REGISTERING_TUNNEL = 'Registering tunnel...';
|
|
272
|
+
exports.LOG_ERROR_WHILE_REFRESHING_AGENT = 'Error while refreshing agent';
|
|
273
|
+
const LOG_TUNNEL_REGISTERED = (id) => `Tunnel registered with id '${id}'`;
|
|
274
|
+
exports.LOG_TUNNEL_REGISTERED = LOG_TUNNEL_REGISTERED;
|
|
275
|
+
exports.LOG_REMOVING_TUNNEL = 'Removing tunnel...';
|
|
276
|
+
const LOG_STARTING_TUNNEL = (id) => `Starting tunnel '${id}'`;
|
|
277
|
+
exports.LOG_STARTING_TUNNEL = LOG_STARTING_TUNNEL;
|
|
278
|
+
const LOG_STOPPING_TUNNEL = (id) => `Stopping tunnel '${id}'`;
|
|
279
|
+
exports.LOG_STOPPING_TUNNEL = LOG_STOPPING_TUNNEL;
|
|
280
|
+
exports.LOG_ERROR = 'error';
|
|
281
|
+
const LOG_HTTP1_CONNECTION = (ip) => `HTTP/1.1 server: New tunnel connection from ${ip}`;
|
|
282
|
+
exports.LOG_HTTP1_CONNECTION = LOG_HTTP1_CONNECTION;
|
|
283
|
+
const LOG_HTTP1_REQUEST = (method, url) => `HTTP/1.1 server: New request ${method} ${url}`;
|
|
284
|
+
exports.LOG_HTTP1_REQUEST = LOG_HTTP1_REQUEST;
|
|
285
|
+
const LOG_HTTP2_CONNECTION = (ip) => `HTTP/2 server: New tunnel connection from ${ip}`;
|
|
286
|
+
exports.LOG_HTTP2_CONNECTION = LOG_HTTP2_CONNECTION;
|
|
287
|
+
const LOG_HTTP2_REQUEST = (method, url) => `HTTP/2 server: New request ${method} ${url}`;
|
|
288
|
+
exports.LOG_HTTP2_REQUEST = LOG_HTTP2_REQUEST;
|
|
289
|
+
const LOG_DETECTED_STREAM = (type) => `Detected stream '${type}'`;
|
|
290
|
+
exports.LOG_DETECTED_STREAM = LOG_DETECTED_STREAM;
|
|
291
|
+
exports.LOG_WRONG_STREAM = 'Wrong stream type';
|
|
292
|
+
exports.LOG_SSH_CONNECTION = 'New SSH TCP connection';
|
|
293
|
+
const LOG_REQUEST = (url) => `request: ${url}`;
|
|
294
|
+
exports.LOG_REQUEST = LOG_REQUEST;
|
|
295
|
+
exports.LOG_ERROR_STARTING_AGENT_SERVER = 'Error while starting agent API server';
|
|
296
|
+
exports.LOG_AGENT_SERVER_STARTED = 'Agent server started';
|
|
297
|
+
exports.LOG_AGENT_STARTED = 'Agent started';
|
|
298
|
+
const LOG_TUNNEL_CONNECTED = (id, port) => `Tunnel '${id}' connected. Forwarding port '${port}'`;
|
|
299
|
+
exports.LOG_TUNNEL_CONNECTED = LOG_TUNNEL_CONNECTED;
|
|
300
|
+
const LOG_TUNNEL_FAILED = (id) => `Tunnel '${id}' forwarding failed`;
|
|
301
|
+
exports.LOG_TUNNEL_FAILED = LOG_TUNNEL_FAILED;
|
|
302
|
+
const LOG_TUNNEL_DISCONNECTED = (id) => `Tunnel '${id}' disconnected`;
|
|
303
|
+
exports.LOG_TUNNEL_DISCONNECTED = LOG_TUNNEL_DISCONNECTED;
|
|
304
|
+
const LOG_TUNNEL_IDENTIFIED = (id, type) => `Tunnel ${id} identified as ${type}`;
|
|
305
|
+
exports.LOG_TUNNEL_IDENTIFIED = LOG_TUNNEL_IDENTIFIED;
|
|
306
|
+
exports.LOG_TUNNEL_HTTP_WRON_AUTH = 'HTTP request: HTTP BA failed';
|
|
307
|
+
exports.LOG_TUNNEL_HTTP_RATE_LIMIT = 'HTTP request: rate limited';
|
|
308
|
+
exports.LOG_TUNNEL_HTTP_CIRCUIT_BREAKER_OPEN = 'HTTP request circuit breaker open';
|
|
309
|
+
exports.LOG_TUNNEL_HTTP_WRONG_USER_AGENTS = 'HTTP request wrong user-agents';
|
|
310
|
+
const LOG_TUNNEL_TCP_STREAM = (id) => `New TCP connection on tunnel '${id}' [streamed to target]`;
|
|
311
|
+
exports.LOG_TUNNEL_TCP_STREAM = LOG_TUNNEL_TCP_STREAM;
|
|
312
|
+
const LOG_TUNNEL_HTTP1_STREAM = (id) => `New HTTP/1.1 connection to '${id}'`;
|
|
313
|
+
exports.LOG_TUNNEL_HTTP1_STREAM = LOG_TUNNEL_HTTP1_STREAM;
|
|
314
|
+
const LOG_TUNNEL_HTTP2_STREAM = (id) => `New HTTP/2 connection to '${id}'`;
|
|
315
|
+
exports.LOG_TUNNEL_HTTP2_STREAM = LOG_TUNNEL_HTTP2_STREAM;
|
|
316
|
+
const LOG_TUNNEL_TLS_TARGET_STREAM = (id) => `New TLS connection to '${id}' [Terminated at target, streamed to target]`;
|
|
317
|
+
exports.LOG_TUNNEL_TLS_TARGET_STREAM = LOG_TUNNEL_TLS_TARGET_STREAM;
|
|
318
|
+
const LOG_TUNNEL_TLS_REGION_STREAM = (id) => `New TLS connection to '${id}' [Terminated at region, streamed to target]`;
|
|
319
|
+
exports.LOG_TUNNEL_TLS_REGION_STREAM = LOG_TUNNEL_TLS_REGION_STREAM;
|
|
320
|
+
const LOG_TUNNEL_TLS_AGENT_STREAM = (id) => `New TLS connection to '${id}' [Terminated at agent]`;
|
|
321
|
+
exports.LOG_TUNNEL_TLS_AGENT_STREAM = LOG_TUNNEL_TLS_AGENT_STREAM;
|
|
322
|
+
const LOG_TUNNEL_SSH_STREAM = (id) => `New SSH connection to '${id}' [Streamed to localhost]`;
|
|
323
|
+
exports.LOG_TUNNEL_SSH_STREAM = LOG_TUNNEL_SSH_STREAM;
|
|
324
|
+
const LOG_RUNNING_EXEC_COMMAND = (command) => `Running ${command}`;
|
|
325
|
+
exports.LOG_RUNNING_EXEC_COMMAND = LOG_RUNNING_EXEC_COMMAND;
|
|
326
|
+
exports.LOG_INSTALLED_BROWSER = `Installed browser`;
|
|
327
|
+
const LOG_PROCESSING_SNAPSHOTS = (amount) => `Processing ${amount} snapshots`;
|
|
328
|
+
exports.LOG_PROCESSING_SNAPSHOTS = LOG_PROCESSING_SNAPSHOTS;
|
|
329
|
+
const LOG_SENDING_REQUEST = (url) => `Sending request to ${url}`;
|
|
330
|
+
exports.LOG_SENDING_REQUEST = LOG_SENDING_REQUEST;
|
|
331
|
+
const DEBUG_EXEC_TEST_COMMAND = (time) => `Test process execution time: ${time}`;
|
|
332
|
+
exports.DEBUG_EXEC_TEST_COMMAND = DEBUG_EXEC_TEST_COMMAND;
|
|
333
|
+
const DEBUG_EXEC_COMMAND = (time) => `Execution time: ${time}`;
|
|
334
|
+
exports.DEBUG_EXEC_COMMAND = DEBUG_EXEC_COMMAND;
|
|
335
|
+
const DEBUG_SNAPSHOTS_PROCESSING = (time) => `Snapshots processing time: ${time}`;
|
|
336
|
+
exports.DEBUG_SNAPSHOTS_PROCESSING = DEBUG_SNAPSHOTS_PROCESSING;
|
|
337
|
+
const DEBUG_SNAPSHOT_PROCESSING = (snapshotName, time) => `Snapshot: ${snapshotName} processing time: ${time}`;
|
|
338
|
+
exports.DEBUG_SNAPSHOT_PROCESSING = DEBUG_SNAPSHOT_PROCESSING;
|
|
339
|
+
const DEBUG_RESOURCE_SCRAPPING_URL = (url) => `Scraping resources from ${url}`;
|
|
340
|
+
exports.DEBUG_RESOURCE_SCRAPPING_URL = DEBUG_RESOURCE_SCRAPPING_URL;
|
|
341
|
+
exports.DEBUG_AUTO_SCROLL = 'Auto scroll';
|
|
342
|
+
exports.DEBUG_AUTO_WIDTH = 'Auto width';
|
|
343
|
+
const DEBUG_RESOURCE_DISCOVERY_TIMEOUT = (timeout) => `Additional resource discovery timeout: ${timeout}`;
|
|
344
|
+
exports.DEBUG_RESOURCE_DISCOVERY_TIMEOUT = DEBUG_RESOURCE_DISCOVERY_TIMEOUT;
|
|
345
|
+
exports.DEBUG_WAIT_FOR_IDLE = 'Wait for network idle';
|
|
@@ -0,0 +1,100 @@
|
|
|
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 http_1 = __importDefault(require("http"));
|
|
7
|
+
const https_1 = __importDefault(require("https"));
|
|
8
|
+
const http2_1 = __importDefault(require("http2"));
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
const texts_js_1 = require("../texts.js");
|
|
11
|
+
const CONNECTION_TIMEOUT = 5000;
|
|
12
|
+
const STREAM_LIMIT = 100;
|
|
13
|
+
class TunnelAgent {
|
|
14
|
+
static getHttp1() {
|
|
15
|
+
if (!this.httpAgent1) {
|
|
16
|
+
this.httpAgent1 = new http_1.default.Agent({
|
|
17
|
+
noDelay: true,
|
|
18
|
+
keepAlive: true,
|
|
19
|
+
maxSockets: 200,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return this.httpAgent1;
|
|
23
|
+
}
|
|
24
|
+
static getHttps1() {
|
|
25
|
+
if (!this.httpsAgent1) {
|
|
26
|
+
this.httpsAgent1 = new https_1.default.Agent({
|
|
27
|
+
noDelay: true,
|
|
28
|
+
keepAlive: true,
|
|
29
|
+
maxSockets: 200,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return this.httpsAgent1;
|
|
33
|
+
}
|
|
34
|
+
static createHttp2Client(authority, servername, verify, id) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const ts = setTimeout(() => {
|
|
37
|
+
TunnelAgent.deleteClient(authority, client, id);
|
|
38
|
+
reject(new Error(texts_js_1.ERR_CONNECTION_TIMEOUT));
|
|
39
|
+
}, CONNECTION_TIMEOUT);
|
|
40
|
+
const client = http2_1.default.connect(authority, {
|
|
41
|
+
rejectUnauthorized: verify,
|
|
42
|
+
noDelay: true,
|
|
43
|
+
servername,
|
|
44
|
+
});
|
|
45
|
+
client.once('close', () => {
|
|
46
|
+
TunnelAgent.deleteClient(authority, client, id);
|
|
47
|
+
});
|
|
48
|
+
client.once('timeout', () => {
|
|
49
|
+
TunnelAgent.deleteClient(authority, client, id);
|
|
50
|
+
});
|
|
51
|
+
client.once('error', () => {
|
|
52
|
+
clearTimeout(ts);
|
|
53
|
+
TunnelAgent.deleteClient(authority, client, id);
|
|
54
|
+
reject(new Error(texts_js_1.ERR_CONNECTION_ERROR));
|
|
55
|
+
});
|
|
56
|
+
client.once('connect', () => {
|
|
57
|
+
clearTimeout(ts);
|
|
58
|
+
resolve(client);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
static deleteClient(authority, client, id) {
|
|
63
|
+
if (this.http2Clients && this.http2Clients[authority]) {
|
|
64
|
+
if (this.http2Clients[authority][id])
|
|
65
|
+
delete this.http2Clients[authority][id];
|
|
66
|
+
if (!Object.keys(this.http2Clients[authority]).length)
|
|
67
|
+
delete this.http2Clients[authority];
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
client.removeAllListeners();
|
|
71
|
+
client.close();
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// do nothing
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
static getHttp2Client(authority, servername, verify) {
|
|
78
|
+
if (!this.http2Clients)
|
|
79
|
+
this.http2Clients = {};
|
|
80
|
+
if (!this.http2Clients[authority])
|
|
81
|
+
this.http2Clients[authority] = {};
|
|
82
|
+
const keys = Object.keys(this.http2Clients[authority]);
|
|
83
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
84
|
+
const id = keys[i];
|
|
85
|
+
const { promise, streamCount } = this.http2Clients[authority][id];
|
|
86
|
+
if (streamCount < STREAM_LIMIT) {
|
|
87
|
+
this.http2Clients[authority][id].streamCount += 1;
|
|
88
|
+
return promise;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const id = (0, uuid_1.v4)();
|
|
92
|
+
const promise = this.createHttp2Client(authority, servername, verify, id);
|
|
93
|
+
this.http2Clients[authority][id] = {
|
|
94
|
+
promise,
|
|
95
|
+
streamCount: 1,
|
|
96
|
+
};
|
|
97
|
+
return promise;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.default = TunnelAgent;
|