bdy 1.8.19-dev → 1.8.21-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/distTs/package.json +2 -1
- package/distTs/src/agent/manager.js +1 -0
- package/distTs/src/agent/socket/tunnel.js +1 -0
- package/distTs/src/agent/socket.js +2 -0
- package/distTs/src/format.js +6 -5
- package/distTs/src/input.js +9 -3
- package/distTs/src/tunnel/dns.js +37 -21
- package/distTs/src/tunnel.js +7 -4
- package/package.json +2 -1
package/distTs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.21-dev",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"jsonwebtoken": "9.0.2",
|
|
32
32
|
"mime-db": "1.52.0",
|
|
33
33
|
"mime-types": "2.1.35",
|
|
34
|
+
"punycode": "2.3.1",
|
|
34
35
|
"netmask": "2.0.2",
|
|
35
36
|
"node-fetch": "3.3.2",
|
|
36
37
|
"node-forge": "1.3.1",
|
|
@@ -64,6 +64,7 @@ class AgentSocketTunnel extends events_1.default {
|
|
|
64
64
|
this.subdomain = data.subdomain;
|
|
65
65
|
this.sshId = data.sshId;
|
|
66
66
|
this.domain = data.domain;
|
|
67
|
+
this.customDomain = data.customDomain;
|
|
67
68
|
this.sshForwardPort = data.sshForwardPort;
|
|
68
69
|
}
|
|
69
70
|
upsertHttpLog(data) {
|
|
@@ -68,6 +68,7 @@ class AgentSocket {
|
|
|
68
68
|
target: t.target,
|
|
69
69
|
subdomain: t.subdomain,
|
|
70
70
|
domain: t.domain,
|
|
71
|
+
customDomain: t.customDomain,
|
|
71
72
|
sshId: t.sshId,
|
|
72
73
|
sshForwardPort: t.sshForwardPort,
|
|
73
74
|
...data,
|
|
@@ -189,6 +190,7 @@ class AgentSocket {
|
|
|
189
190
|
id: this.tunnel.id,
|
|
190
191
|
subdomain: this.tunnel.subdomain,
|
|
191
192
|
domain: this.tunnel.domain,
|
|
193
|
+
customDomain: this.tunnel.customDomain,
|
|
192
194
|
sshId: this.tunnel.sshId,
|
|
193
195
|
sshForwardPort: this.tunnel.sshForwardPort,
|
|
194
196
|
});
|
package/distTs/src/format.js
CHANGED
|
@@ -106,11 +106,12 @@ class Format {
|
|
|
106
106
|
static entryHost(tunnel) {
|
|
107
107
|
let host = '';
|
|
108
108
|
host += tunnel.subdomain;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
if (!tunnel.customDomain) {
|
|
110
|
+
host += '.';
|
|
111
|
+
host += tunnel.region.toLowerCase();
|
|
112
|
+
host += '-';
|
|
113
|
+
host += tunnel.sshId;
|
|
114
|
+
}
|
|
114
115
|
host += '.';
|
|
115
116
|
host += tunnel.domain;
|
|
116
117
|
return host;
|
package/distTs/src/input.js
CHANGED
|
@@ -38,11 +38,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const output_js_1 = __importDefault(require("./output.js"));
|
|
40
40
|
const netmask_1 = __importDefault(require("netmask"));
|
|
41
|
+
const punycode_1 = __importDefault(require("punycode/"));
|
|
41
42
|
const fs_1 = __importStar(require("fs"));
|
|
42
43
|
const tls_1 = __importDefault(require("tls"));
|
|
43
44
|
const crypto_1 = __importDefault(require("crypto"));
|
|
44
45
|
const utils_js_1 = require("./utils.js");
|
|
45
46
|
const texts_js_1 = require("./texts.js");
|
|
47
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
46
48
|
class Input {
|
|
47
49
|
static timeout(timeout) {
|
|
48
50
|
const t = parseInt(timeout, 10);
|
|
@@ -90,19 +92,23 @@ class Input {
|
|
|
90
92
|
return r;
|
|
91
93
|
}
|
|
92
94
|
static subdomain(subdomain) {
|
|
93
|
-
|
|
95
|
+
const encoded = punycode_1.default.toASCII(subdomain);
|
|
96
|
+
if (!/^[a-z0-9-]+$/i.test(encoded)) {
|
|
94
97
|
output_js_1.default.exitError((0, texts_js_1.ERR_SUBDOMAIN_IS_NOT_VALID)(subdomain));
|
|
95
98
|
}
|
|
96
99
|
if (subdomain.length < 5) {
|
|
97
100
|
output_js_1.default.exitError((0, texts_js_1.ERR_SUBDOMAIN_IS_TOO_SHORT)(subdomain));
|
|
98
101
|
}
|
|
99
|
-
if (
|
|
102
|
+
if (encoded.length > 63) {
|
|
100
103
|
output_js_1.default.exitError((0, texts_js_1.ERR_SUBDOMAIN_IS_TOO_LONG)(subdomain));
|
|
101
104
|
}
|
|
102
105
|
return subdomain;
|
|
103
106
|
}
|
|
104
107
|
static domain(domain) {
|
|
105
|
-
|
|
108
|
+
const encoded = punycode_1.default.toASCII(domain);
|
|
109
|
+
logger_1.default.info(domain);
|
|
110
|
+
logger_1.default.info(encoded);
|
|
111
|
+
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(encoded)) {
|
|
106
112
|
output_js_1.default.exitError((0, texts_js_1.ERR_DOMAIN_IS_NOT_VALID)(domain));
|
|
107
113
|
}
|
|
108
114
|
return domain;
|
package/distTs/src/tunnel/dns.js
CHANGED
|
@@ -2,38 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const dns_1 = require("dns");
|
|
4
4
|
class TunnelDns {
|
|
5
|
-
constructor(sshIp, domain, subdomain, region, sshId) {
|
|
5
|
+
constructor(sshIp, domain, customDomain, subdomain, region, sshId) {
|
|
6
6
|
this.region = region;
|
|
7
7
|
this.sshId = sshId;
|
|
8
8
|
this.sshIp = sshIp;
|
|
9
9
|
this.domain = domain;
|
|
10
10
|
this.subdomain = subdomain;
|
|
11
|
+
this.customDomain = customDomain;
|
|
11
12
|
this.valid = false;
|
|
12
13
|
this.checking = true;
|
|
13
14
|
this.ts = null;
|
|
14
15
|
}
|
|
15
16
|
check() {
|
|
16
17
|
const r = new dns_1.Resolver();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
let hostname;
|
|
19
|
+
if (this.customDomain) {
|
|
20
|
+
hostname = `${this.subdomain}.${this.domain}`;
|
|
21
|
+
r.resolve4(hostname, (err, a1) => {
|
|
22
|
+
if (err || !a1 || a1.length !== 1) {
|
|
23
|
+
this.valid = false;
|
|
24
|
+
this.checking = false;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.valid = a1[0] === this.sshIp;
|
|
28
|
+
this.checking = false;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
hostname = `${this.subdomain}.${this.region.toLowerCase()}-${this.sshId}.${this.domain}`;
|
|
34
|
+
r.resolveCname(hostname, (err, a1) => {
|
|
35
|
+
if (err || !a1 || a1.length !== 1) {
|
|
36
|
+
this.valid = false;
|
|
37
|
+
this.checking = false;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
r.resolve4(a1[0], (err, a2) => {
|
|
41
|
+
if (err || !a2 || a2.length !== 1) {
|
|
42
|
+
this.valid = false;
|
|
43
|
+
this.checking = false;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.valid = a2[0] === this.sshIp;
|
|
47
|
+
this.checking = false;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
37
53
|
}
|
|
38
54
|
startChecking() {
|
|
39
55
|
this.stopChecking();
|
package/distTs/src/tunnel.js
CHANGED
|
@@ -21,7 +21,7 @@ const format_1 = __importDefault(require("./format"));
|
|
|
21
21
|
const texts_js_1 = require("./texts.js");
|
|
22
22
|
const dns_js_1 = __importDefault(require("./tunnel/dns.js"));
|
|
23
23
|
class Tunnel extends events_1.default {
|
|
24
|
-
constructor({ id, type, target, region, timeout, domain, subdomain, whitelist, tlsSettings, httpSettings, sshSettings, sshHostKey, }) {
|
|
24
|
+
constructor({ id, type, target, region, timeout, domain, customDomain, subdomain, whitelist, tlsSettings, httpSettings, sshSettings, sshHostKey, }) {
|
|
25
25
|
super();
|
|
26
26
|
if (!sshHostKey)
|
|
27
27
|
sshHostKey = (0, utils_js_1.createSshHostKey)();
|
|
@@ -33,6 +33,7 @@ class Tunnel extends events_1.default {
|
|
|
33
33
|
region,
|
|
34
34
|
timeout,
|
|
35
35
|
domain,
|
|
36
|
+
customDomain,
|
|
36
37
|
subdomain,
|
|
37
38
|
whitelist,
|
|
38
39
|
tlsSettings,
|
|
@@ -40,12 +41,13 @@ class Tunnel extends events_1.default {
|
|
|
40
41
|
sshSettings,
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
|
-
create({ type, target, region, timeout, domain, subdomain, whitelist, tlsSettings, httpSettings, sshSettings, }) {
|
|
44
|
+
create({ type, target, region, timeout, domain, customDomain, subdomain, whitelist, tlsSettings, httpSettings, sshSettings, }) {
|
|
44
45
|
this.type = type;
|
|
45
46
|
this.region = region;
|
|
46
47
|
this.target = target;
|
|
47
48
|
this.whitelist = whitelist || [];
|
|
48
49
|
this.domain = domain;
|
|
50
|
+
this.customDomain = !!customDomain;
|
|
49
51
|
this.subdomain = subdomain;
|
|
50
52
|
this.timeout = timeout || utils_js_1.DEFAULT_TIMEOUT;
|
|
51
53
|
this.useragents = [];
|
|
@@ -135,7 +137,7 @@ class Tunnel extends events_1.default {
|
|
|
135
137
|
this.ssh = null;
|
|
136
138
|
this.started = false;
|
|
137
139
|
}
|
|
138
|
-
recreate({ type, target, region, timeout, domain, subdomain, whitelist, tlsSettings, httpSettings, sshSettings, }) {
|
|
140
|
+
recreate({ type, target, region, timeout, domain, customDomain, subdomain, whitelist, tlsSettings, httpSettings, sshSettings, }) {
|
|
139
141
|
const started = this.started;
|
|
140
142
|
this.stop(false);
|
|
141
143
|
this.create({
|
|
@@ -144,6 +146,7 @@ class Tunnel extends events_1.default {
|
|
|
144
146
|
region,
|
|
145
147
|
timeout,
|
|
146
148
|
domain,
|
|
149
|
+
customDomain,
|
|
147
150
|
subdomain,
|
|
148
151
|
whitelist,
|
|
149
152
|
tlsSettings,
|
|
@@ -547,7 +550,7 @@ class Tunnel extends events_1.default {
|
|
|
547
550
|
this.targetLatency.startChecking();
|
|
548
551
|
}
|
|
549
552
|
// dns health
|
|
550
|
-
this.dns = new dns_js_1.default(this.sshIp, this.domain, this.subdomain, this.region, this.sshId);
|
|
553
|
+
this.dns = new dns_js_1.default(this.sshIp, this.domain, this.customDomain, this.subdomain, this.region, this.sshId);
|
|
551
554
|
this.dns.startChecking();
|
|
552
555
|
if (this.type === utils_js_1.TUNNEL_TLS && this.terminate === utils_js_1.TLS_TERMINATE_AT_AGENT) {
|
|
553
556
|
// tls
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.21-dev",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"jsonwebtoken": "9.0.2",
|
|
32
32
|
"mime-db": "1.52.0",
|
|
33
33
|
"mime-types": "2.1.35",
|
|
34
|
+
"punycode": "2.3.1",
|
|
34
35
|
"netmask": "2.0.2",
|
|
35
36
|
"node-fetch": "3.3.2",
|
|
36
37
|
"node-forge": "1.3.1",
|