bdy 1.14.1-dev → 1.14.2-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/package.json +1 -1
- package/distTs/src/agent.js +0 -302
- package/distTs/src/api/agent.js +0 -99
- package/distTs/src/api/buddy.js +0 -139
- package/distTs/src/api/socket.js +0 -159
- package/distTs/src/cfg.js +0 -234
- package/distTs/src/command/config.js +0 -17
- package/distTs/src/command/http.js +0 -30
- package/distTs/src/command/start.js +0 -28
- package/distTs/src/command/tcp.js +0 -30
- package/distTs/src/command/tls.js +0 -30
- package/distTs/src/output/interactive/tunnel.js +0 -860
- package/distTs/src/output/noninteractive/agent/tunnels.js +0 -43
- package/distTs/src/output/noninteractive/config/tunnel.js +0 -65
- package/distTs/src/output/noninteractive/config/tunnels.js +0 -18
- package/distTs/src/output/noninteractive/tunnel.js +0 -59
- package/distTs/src/server/cert.js +0 -52
- package/distTs/src/server/http1.js +0 -75
- package/distTs/src/server/http2.js +0 -78
- package/distTs/src/server/sftp.js +0 -497
- package/distTs/src/server/ssh.js +0 -446
- package/distTs/src/server/tls.js +0 -41
- package/distTs/src/ssh/client.js +0 -197
- package/distTs/src/tunnel/html/503.html +0 -338
- package/distTs/src/tunnel.js +0 -656
- package/distTs/src/types/ciInfo.js +0 -10
- package/distTs/src/visualTest/ci.js +0 -241
package/distTs/src/api/socket.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
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 https_1 = require("https");
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
const logger_js_1 = __importDefault(require("../logger.js"));
|
|
9
|
-
const texts_1 = require("../texts");
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const socket_io_client_1 = require("socket.io-client");
|
|
12
|
-
const MAX_REQUESTS_SYNC_WINDOW = 30000;
|
|
13
|
-
const MAX_REQUESTS_SYNC_IN_WINDOW = 100;
|
|
14
|
-
class ApiSocketClass extends events_1.default {
|
|
15
|
-
fetch(activate = true, action = null, disabled = null, resetFirstHeard = false, tunnels) {
|
|
16
|
-
this.socket.emit('fetchTunnelAgent', {
|
|
17
|
-
id: this.id,
|
|
18
|
-
token: this.token,
|
|
19
|
-
hostname: this.hostname,
|
|
20
|
-
platform: this.platform,
|
|
21
|
-
version: this.version,
|
|
22
|
-
activate,
|
|
23
|
-
action,
|
|
24
|
-
disabled,
|
|
25
|
-
resetFirstHeard,
|
|
26
|
-
tunnels,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
update(activate, tunnels, force = false) {
|
|
30
|
-
const now = Date.now();
|
|
31
|
-
// nie robimy update jak byl mniej niz 5s temu
|
|
32
|
-
if (!force && this.lastUpdate && now - this.lastUpdate < 5000)
|
|
33
|
-
return;
|
|
34
|
-
this.lastUpdate = now;
|
|
35
|
-
this.socket.emit('updateTunnelAgent', {
|
|
36
|
-
id: this.id,
|
|
37
|
-
token: this.token,
|
|
38
|
-
hostname: this.hostname,
|
|
39
|
-
platform: this.platform,
|
|
40
|
-
version: this.version,
|
|
41
|
-
activate,
|
|
42
|
-
tunnels,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
emitRequest(tunnelId, logRequest) {
|
|
46
|
-
this.socket.emit('tunnelRequest', {
|
|
47
|
-
id: this.id,
|
|
48
|
-
token: this.token,
|
|
49
|
-
tunnelId,
|
|
50
|
-
request: logRequest.toSocket(),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
request(tunnelId, logRequest) {
|
|
54
|
-
if (this.tunnelRequests > MAX_REQUESTS_SYNC_IN_WINDOW)
|
|
55
|
-
return;
|
|
56
|
-
this.tunnelRequests += 1;
|
|
57
|
-
logRequest.once(utils_1.EVENT_TUNNEL_HTTP_NEW_RESPONSE_END, () => {
|
|
58
|
-
this.emitRequest(tunnelId, logRequest);
|
|
59
|
-
});
|
|
60
|
-
this.emitRequest(tunnelId, logRequest);
|
|
61
|
-
}
|
|
62
|
-
onSyncAgent(data, action) {
|
|
63
|
-
this.emit(utils_1.SOCKET_IO_EVENT_AGENT, data, action);
|
|
64
|
-
}
|
|
65
|
-
onSyncTunnel(data, action) {
|
|
66
|
-
this.emit(utils_1.SOCKET_IO_EVENT_TUNNEL, data, action);
|
|
67
|
-
}
|
|
68
|
-
onSync(data) {
|
|
69
|
-
try {
|
|
70
|
-
const json = JSON.parse(data);
|
|
71
|
-
if (json.payloadType === 'TunnelAgentFront')
|
|
72
|
-
this.onSyncAgent(json.payload, json.action);
|
|
73
|
-
else if (json.payloadType === 'TunnelFront')
|
|
74
|
-
this.onSyncTunnel(json.payload, json.action);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// do nothing
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
connect(atOnce) {
|
|
81
|
-
logger_js_1.default.debug('socket connect');
|
|
82
|
-
if (atOnce && this.socket && !this.socket.connected) {
|
|
83
|
-
this.socket.connect();
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
if (this.socket && !this.socket.connected)
|
|
88
|
-
this.socket.connect();
|
|
89
|
-
}, 3000);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
destroy() {
|
|
93
|
-
if (this.socket) {
|
|
94
|
-
this.socket.removeAllListeners();
|
|
95
|
-
this.socket.disconnect();
|
|
96
|
-
this.socket = null;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
constructor(host, id, token) {
|
|
100
|
-
super();
|
|
101
|
-
this.id = id;
|
|
102
|
-
this.token = token;
|
|
103
|
-
this.connected = false;
|
|
104
|
-
this.hostname = (0, utils_1.getHostname)();
|
|
105
|
-
this.platform = (0, utils_1.getPlatform)();
|
|
106
|
-
this.version = (0, utils_1.getVersion)();
|
|
107
|
-
this.lastUpdate = null;
|
|
108
|
-
this.tunnelRequests = 0;
|
|
109
|
-
setInterval(() => {
|
|
110
|
-
this.tunnelRequests = 0;
|
|
111
|
-
}, MAX_REQUESTS_SYNC_WINDOW);
|
|
112
|
-
this.socket = (0, socket_io_client_1.io)(host, {
|
|
113
|
-
forceNew: true,
|
|
114
|
-
autoConnect: false,
|
|
115
|
-
autoUnref: true,
|
|
116
|
-
forceBase64: true,
|
|
117
|
-
transports: ['websocket'],
|
|
118
|
-
reconnection: false,
|
|
119
|
-
rejectUnauthorized: false,
|
|
120
|
-
agent: new https_1.Agent({
|
|
121
|
-
rejectUnauthorized: false,
|
|
122
|
-
}),
|
|
123
|
-
maxHttpBufferSize: 3e6,
|
|
124
|
-
extraHeaders: {
|
|
125
|
-
cookie: 'a=b',
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
this.socket.on('connect', () => {
|
|
129
|
-
this.connected = true;
|
|
130
|
-
logger_js_1.default.info(texts_1.LOG_SOCKET_CONNECTED);
|
|
131
|
-
this.emit(utils_1.SOCKET_IO_EVENT_CONNECTED);
|
|
132
|
-
this.socket.emit('joinTunnelAgent', {
|
|
133
|
-
id: this.id,
|
|
134
|
-
token: this.token,
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
this.socket.on('disconnect', () => {
|
|
138
|
-
this.connected = false;
|
|
139
|
-
logger_js_1.default.info(texts_1.LOG_SOCKET_DISCONNECTED);
|
|
140
|
-
this.emit(utils_1.SOCKET_IO_EVENT_DISCONNECTED);
|
|
141
|
-
this.connect();
|
|
142
|
-
});
|
|
143
|
-
this.socket.on('connect_error', () => {
|
|
144
|
-
logger_js_1.default.debug('socket error');
|
|
145
|
-
this.connect();
|
|
146
|
-
});
|
|
147
|
-
this.socket.on('fetchTunnelAgentSuccess', (data) => {
|
|
148
|
-
logger_js_1.default.debug('Socket fetch success');
|
|
149
|
-
this.emit(utils_1.SOCKET_IO_EVENT_FETCH_SUCCESS, data);
|
|
150
|
-
});
|
|
151
|
-
this.socket.on('fetchTunnelAgentFailed', (code) => {
|
|
152
|
-
logger_js_1.default.debug('Socket fetch failed');
|
|
153
|
-
this.emit(utils_1.SOCKET_IO_EVENT_FETCH_FAILED, (0, utils_1.apiErrorCodeToClass)(code, host));
|
|
154
|
-
});
|
|
155
|
-
this.socket.on('sync', (data) => this.onSync(data));
|
|
156
|
-
this.connect(true);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
exports.default = ApiSocketClass;
|
package/distTs/src/cfg.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
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 path_1 = require("path");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
9
|
-
const utils_js_1 = require("./utils.js");
|
|
10
|
-
const input_js_1 = __importDefault(require("./input.js"));
|
|
11
|
-
const texts_js_1 = require("./texts.js");
|
|
12
|
-
class Cfg {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.dir = (0, utils_js_1.getHomeDirectory)();
|
|
15
|
-
this.file = (0, path_1.resolve)(this.dir, 'cfg.json');
|
|
16
|
-
this.json = {};
|
|
17
|
-
this.load();
|
|
18
|
-
}
|
|
19
|
-
createDir() {
|
|
20
|
-
try {
|
|
21
|
-
(0, fs_1.mkdirSync)(this.dir, {
|
|
22
|
-
recursive: true,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
throw new Error((0, texts_js_1.ERR_CANT_CREATE_DIR_IN_HOME)('.bdy'));
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
(0, fs_1.chmodSync)(this.dir, 0o777);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
// do nothing
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
createEmptyFile() {
|
|
36
|
-
try {
|
|
37
|
-
(0, fs_1.writeFileSync)(this.file, '{}', 'utf-8');
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
throw new Error((0, texts_js_1.ERR_CANT_CREATE_DIR_IN_HOME)('.bdy/cfg.json'));
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
(0, fs_1.chmodSync)(this.file, 0o666);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// do nothing
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
ensureDir() {
|
|
50
|
-
try {
|
|
51
|
-
(0, fs_1.statSync)(this.dir);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
this.createDir();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
ensureFile() {
|
|
58
|
-
this.ensureDir();
|
|
59
|
-
try {
|
|
60
|
-
(0, fs_1.statSync)(this.file);
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
this.createEmptyFile();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
ensureTunnels() {
|
|
67
|
-
if (!this.json.tunnels)
|
|
68
|
-
this.json.tunnels = {};
|
|
69
|
-
}
|
|
70
|
-
async prepareTunnel(tunnelType, target, options, useDefaults) {
|
|
71
|
-
const type = input_js_1.default.type(tunnelType);
|
|
72
|
-
const tunnel = {
|
|
73
|
-
type,
|
|
74
|
-
target: input_js_1.default.target(target, type),
|
|
75
|
-
};
|
|
76
|
-
if (options.region !== undefined)
|
|
77
|
-
tunnel.region = input_js_1.default.region(options.region);
|
|
78
|
-
else if (useDefaults)
|
|
79
|
-
tunnel.region = this.getRegion();
|
|
80
|
-
if (options.whitelist !== undefined)
|
|
81
|
-
tunnel.whitelist = input_js_1.default.whitelist(options.whitelist);
|
|
82
|
-
else if (useDefaults)
|
|
83
|
-
tunnel.whitelist = this.getWhitelist();
|
|
84
|
-
if (options.timeout !== undefined)
|
|
85
|
-
tunnel.timeout = input_js_1.default.timeout(options.timeout);
|
|
86
|
-
else if (useDefaults)
|
|
87
|
-
tunnel.timeout = this.getTimeout();
|
|
88
|
-
if (type === utils_js_1.TUNNEL_HTTP) {
|
|
89
|
-
if (options.host !== undefined)
|
|
90
|
-
tunnel.host = options.host;
|
|
91
|
-
if (options.auth !== undefined) {
|
|
92
|
-
const { password, login } = input_js_1.default.auth(options.auth);
|
|
93
|
-
tunnel.login = login;
|
|
94
|
-
tunnel.password = password;
|
|
95
|
-
}
|
|
96
|
-
if (options.ca !== undefined)
|
|
97
|
-
tunnel.ca = input_js_1.default.ca(options.ca);
|
|
98
|
-
if (options.serve !== undefined)
|
|
99
|
-
tunnel.serve = input_js_1.default.serve(options.serve);
|
|
100
|
-
if (options.useragent !== undefined)
|
|
101
|
-
tunnel.useragents = input_js_1.default.useragents(options.useragent);
|
|
102
|
-
if (options.header !== undefined)
|
|
103
|
-
tunnel.headers = input_js_1.default.headers(options.header);
|
|
104
|
-
if (options.responseHeader !== undefined)
|
|
105
|
-
tunnel.responseHeaders = input_js_1.default.headers(options.responseHeader);
|
|
106
|
-
if (options.circuitBreaker !== undefined)
|
|
107
|
-
tunnel.circuitBreaker = input_js_1.default.circuitBreaker(options.circuitBreaker);
|
|
108
|
-
tunnel.log = !!options.log;
|
|
109
|
-
tunnel.verify = !!options.verify;
|
|
110
|
-
tunnel.http2 = !!options.http2;
|
|
111
|
-
tunnel.compression = !!options.compression;
|
|
112
|
-
}
|
|
113
|
-
else if (type === utils_js_1.TUNNEL_TLS) {
|
|
114
|
-
tunnel.terminate = input_js_1.default.terminate(options.terminate);
|
|
115
|
-
if (options.key !== undefined || options.cert !== undefined) {
|
|
116
|
-
const { key, cert } = input_js_1.default.keyCert(options.key, options.cert);
|
|
117
|
-
tunnel.key = key;
|
|
118
|
-
tunnel.cert = cert;
|
|
119
|
-
}
|
|
120
|
-
if (options.ca !== undefined)
|
|
121
|
-
tunnel.ca = input_js_1.default.ca(options.ca);
|
|
122
|
-
}
|
|
123
|
-
if (options.name !== undefined)
|
|
124
|
-
tunnel.name = input_js_1.default.name(options.name);
|
|
125
|
-
return tunnel;
|
|
126
|
-
}
|
|
127
|
-
async addTunnel(name, type, target, options) {
|
|
128
|
-
this.ensureTunnels();
|
|
129
|
-
this.json.tunnels[name] = await this.prepareTunnel(type, target, {
|
|
130
|
-
name,
|
|
131
|
-
...options,
|
|
132
|
-
}, false);
|
|
133
|
-
this.save();
|
|
134
|
-
}
|
|
135
|
-
removeTunnel(name) {
|
|
136
|
-
this.ensureTunnels();
|
|
137
|
-
delete this.json.tunnels[name];
|
|
138
|
-
this.save();
|
|
139
|
-
}
|
|
140
|
-
getTunnels() {
|
|
141
|
-
this.ensureTunnels();
|
|
142
|
-
return this.json.tunnels;
|
|
143
|
-
}
|
|
144
|
-
hasTunnel(name) {
|
|
145
|
-
this.ensureTunnels();
|
|
146
|
-
return !!this.json.tunnels[name];
|
|
147
|
-
}
|
|
148
|
-
getTunnel(name) {
|
|
149
|
-
this.ensureTunnels();
|
|
150
|
-
return this.json.tunnels[name];
|
|
151
|
-
}
|
|
152
|
-
setToken(token) {
|
|
153
|
-
if (!token)
|
|
154
|
-
delete this.json.token;
|
|
155
|
-
else
|
|
156
|
-
this.json.token = token;
|
|
157
|
-
this.save();
|
|
158
|
-
}
|
|
159
|
-
setWhitelist(whitelist) {
|
|
160
|
-
if (!whitelist || !whitelist.length)
|
|
161
|
-
delete this.json.whitelist;
|
|
162
|
-
else
|
|
163
|
-
this.json.whitelist = whitelist;
|
|
164
|
-
this.save();
|
|
165
|
-
}
|
|
166
|
-
setTimeout(timeout) {
|
|
167
|
-
if (!timeout)
|
|
168
|
-
delete this.json.timeout;
|
|
169
|
-
else
|
|
170
|
-
this.json.timeout = timeout;
|
|
171
|
-
this.save();
|
|
172
|
-
}
|
|
173
|
-
getToken() {
|
|
174
|
-
return this.json.token || '';
|
|
175
|
-
}
|
|
176
|
-
getTokenHost() {
|
|
177
|
-
const token = this.getToken();
|
|
178
|
-
if (!token) {
|
|
179
|
-
throw new Error(texts_js_1.ERR_TOKEN_NOT_PROVIDED);
|
|
180
|
-
}
|
|
181
|
-
const d = (0, jsonwebtoken_1.decode)(token);
|
|
182
|
-
if (d === null) {
|
|
183
|
-
throw new Error(texts_js_1.ERR_WRONG_TOKEN);
|
|
184
|
-
}
|
|
185
|
-
if (!d.host) {
|
|
186
|
-
throw new Error(texts_js_1.ERR_WRONG_TOKEN);
|
|
187
|
-
}
|
|
188
|
-
return d.host;
|
|
189
|
-
}
|
|
190
|
-
getRegion() {
|
|
191
|
-
return (this.json.region || '').toUpperCase();
|
|
192
|
-
}
|
|
193
|
-
getTimeout() {
|
|
194
|
-
return this.json.timeout || utils_js_1.DEFAULT_TIMEOUT;
|
|
195
|
-
}
|
|
196
|
-
getWhitelist() {
|
|
197
|
-
return this.json.whitelist || [];
|
|
198
|
-
}
|
|
199
|
-
setRegion(region) {
|
|
200
|
-
this.json.region = region;
|
|
201
|
-
this.save();
|
|
202
|
-
}
|
|
203
|
-
setRegionIfNotSet(region) {
|
|
204
|
-
if (!this.json.region && region)
|
|
205
|
-
this.json.region = region.toUpperCase();
|
|
206
|
-
this.save();
|
|
207
|
-
}
|
|
208
|
-
load() {
|
|
209
|
-
this.ensureFile();
|
|
210
|
-
try {
|
|
211
|
-
const txt = (0, fs_1.readFileSync)(this.file, 'utf-8');
|
|
212
|
-
this.json = JSON.parse(txt);
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
throw new Error(texts_js_1.ERR_CONFIG_CORRUPTED);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
save() {
|
|
219
|
-
this.ensureDir();
|
|
220
|
-
try {
|
|
221
|
-
(0, fs_1.writeFileSync)(this.file, JSON.stringify(this.json, null, 4), 'utf-8');
|
|
222
|
-
}
|
|
223
|
-
catch {
|
|
224
|
-
throw new Error((0, texts_js_1.ERR_CANT_CREATE_DIR_IN_HOME)('.bdy/cfg.json'));
|
|
225
|
-
}
|
|
226
|
-
try {
|
|
227
|
-
(0, fs_1.chmodSync)(this.file, 0o666);
|
|
228
|
-
}
|
|
229
|
-
catch {
|
|
230
|
-
// do nothing
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
exports.default = new Cfg();
|
|
@@ -1,17 +0,0 @@
|
|
|
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 set_js_1 = __importDefault(require("./config/set.js"));
|
|
7
|
-
const get_js_1 = __importDefault(require("./config/get.js"));
|
|
8
|
-
const add_js_1 = __importDefault(require("./config/add.js"));
|
|
9
|
-
const remove_js_1 = __importDefault(require("./config/remove.js"));
|
|
10
|
-
const texts_js_1 = require("../texts.js");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
const commandConfig = (0, utils_1.newCommand)('config', texts_js_1.DESC_COMMAND_CONFIG);
|
|
13
|
-
commandConfig.addCommand(set_js_1.default);
|
|
14
|
-
commandConfig.addCommand(add_js_1.default);
|
|
15
|
-
commandConfig.addCommand(get_js_1.default);
|
|
16
|
-
commandConfig.addCommand(remove_js_1.default);
|
|
17
|
-
exports.default = commandConfig;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_js_1 = require("../utils.js");
|
|
7
|
-
const cfg_js_1 = __importDefault(require("../cfg.js"));
|
|
8
|
-
const output_js_1 = __importDefault(require("../output.js"));
|
|
9
|
-
const texts_js_1 = require("../texts.js");
|
|
10
|
-
const buddy_js_1 = __importDefault(require("../api/buddy.js"));
|
|
11
|
-
const commandHttp = (0, utils_js_1.getBasicCommandHttp)();
|
|
12
|
-
commandHttp.description(texts_js_1.DESC_COMMAND_HTTP);
|
|
13
|
-
commandHttp.option('-s, --serve <directory>', texts_js_1.OPTION_SERVE);
|
|
14
|
-
commandHttp.option('--token <token>', texts_js_1.OPTION_TOKEN);
|
|
15
|
-
commandHttp.argument('[protocol://host:port]', texts_js_1.OPTION_TARGET);
|
|
16
|
-
commandHttp.action(async (target, options) => {
|
|
17
|
-
if (options.token)
|
|
18
|
-
cfg_js_1.default.setToken(options.token);
|
|
19
|
-
const prepared = await cfg_js_1.default.prepareTunnel(utils_js_1.TUNNEL_HTTP, target, options, true);
|
|
20
|
-
await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
|
|
21
|
-
const agent = await buddy_js_1.default.register(false, false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
|
|
22
|
-
cfg_js_1.default.setRegionIfNotSet(region);
|
|
23
|
-
});
|
|
24
|
-
await agent.start();
|
|
25
|
-
agent.startRefreshingConfiguration();
|
|
26
|
-
const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
27
|
-
agent.addTunnel(tunnel);
|
|
28
|
-
output_js_1.default.tunnel(tunnel);
|
|
29
|
-
});
|
|
30
|
-
exports.default = commandHttp;
|
|
@@ -1,28 +0,0 @@
|
|
|
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 cfg_js_1 = __importDefault(require("../cfg.js"));
|
|
7
|
-
const output_js_1 = __importDefault(require("../output.js"));
|
|
8
|
-
const texts_js_1 = require("../texts.js");
|
|
9
|
-
const buddy_js_1 = __importDefault(require("../api/buddy.js"));
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const commandStart = (0, utils_1.newCommand)('start', texts_js_1.DESC_COMMAND_START);
|
|
12
|
-
commandStart.argument('<name>', texts_js_1.OPTION_NAME);
|
|
13
|
-
commandStart.action(async (name) => {
|
|
14
|
-
if (!cfg_js_1.default.hasTunnel(name)) {
|
|
15
|
-
output_js_1.default.exitError((0, texts_js_1.ERR_TUNNEL_NOT_FOUND)(name));
|
|
16
|
-
}
|
|
17
|
-
const prepared = cfg_js_1.default.getTunnel(name);
|
|
18
|
-
await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
|
|
19
|
-
const agent = await buddy_js_1.default.register(false, false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
|
|
20
|
-
cfg_js_1.default.setRegionIfNotSet(region);
|
|
21
|
-
});
|
|
22
|
-
await agent.start();
|
|
23
|
-
agent.startRefreshingConfiguration();
|
|
24
|
-
const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
25
|
-
agent.addTunnel(tunnel);
|
|
26
|
-
output_js_1.default.tunnel(tunnel);
|
|
27
|
-
});
|
|
28
|
-
exports.default = commandStart;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_js_1 = require("../utils.js");
|
|
7
|
-
const cfg_js_1 = __importDefault(require("../cfg.js"));
|
|
8
|
-
const output_js_1 = __importDefault(require("../output.js"));
|
|
9
|
-
const texts_js_1 = require("../texts.js");
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const buddy_js_1 = __importDefault(require("../api/buddy.js"));
|
|
12
|
-
const commandTcp = (0, utils_1.getBasicCommandTcp)();
|
|
13
|
-
commandTcp.description(texts_js_1.DESC_COMMAND_TCP);
|
|
14
|
-
commandTcp.option('--token <token>', texts_js_1.OPTION_TOKEN);
|
|
15
|
-
commandTcp.argument('[host:port]', texts_js_1.OPTION_TARGET);
|
|
16
|
-
commandTcp.action(async (target, options) => {
|
|
17
|
-
if (options.token)
|
|
18
|
-
cfg_js_1.default.setToken(options.token);
|
|
19
|
-
const prepared = await cfg_js_1.default.prepareTunnel(utils_js_1.TUNNEL_TCP, target, options, true);
|
|
20
|
-
await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
|
|
21
|
-
const agent = await buddy_js_1.default.register(false, false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
|
|
22
|
-
cfg_js_1.default.setRegionIfNotSet(region);
|
|
23
|
-
});
|
|
24
|
-
await agent.start();
|
|
25
|
-
agent.startRefreshingConfiguration();
|
|
26
|
-
const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
27
|
-
agent.addTunnel(tunnel);
|
|
28
|
-
output_js_1.default.tunnel(tunnel);
|
|
29
|
-
});
|
|
30
|
-
exports.default = commandTcp;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const utils_js_1 = require("../utils.js");
|
|
7
|
-
const cfg_js_1 = __importDefault(require("../cfg.js"));
|
|
8
|
-
const output_js_1 = __importDefault(require("../output.js"));
|
|
9
|
-
const texts_js_1 = require("../texts.js");
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const buddy_js_1 = __importDefault(require("../api/buddy.js"));
|
|
12
|
-
const commandTls = (0, utils_1.getBasicCommandTls)();
|
|
13
|
-
commandTls.description(texts_js_1.DESC_COMMAND_TLS);
|
|
14
|
-
commandTls.option('--token <token>', texts_js_1.OPTION_TOKEN);
|
|
15
|
-
commandTls.argument('[host:port]', texts_js_1.OPTION_TARGET);
|
|
16
|
-
commandTls.action(async (target, options) => {
|
|
17
|
-
if (options.token)
|
|
18
|
-
cfg_js_1.default.setToken(options.token);
|
|
19
|
-
const prepared = await cfg_js_1.default.prepareTunnel(utils_js_1.TUNNEL_TLS, target, options, true);
|
|
20
|
-
await output_js_1.default.spinner(texts_js_1.TXT_OPENING_TUNNEL);
|
|
21
|
-
const agent = await buddy_js_1.default.register(false, cfg_js_1.default.getTokenHost(), cfg_js_1.default.getToken(), (region) => {
|
|
22
|
-
cfg_js_1.default.setRegionIfNotSet(region);
|
|
23
|
-
});
|
|
24
|
-
await agent.start();
|
|
25
|
-
agent.startRefreshingConfiguration();
|
|
26
|
-
const tunnel = await buddy_js_1.default.addTunnel(agent.id, agent.host, agent.token, prepared);
|
|
27
|
-
agent.addTunnel(tunnel);
|
|
28
|
-
output_js_1.default.tunnel(tunnel);
|
|
29
|
-
});
|
|
30
|
-
exports.default = commandTls;
|