bdy 1.8.18-dev → 1.8.20-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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.8.18-dev",
4
+ "version": "1.8.20-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -95,6 +95,7 @@ class AgentManagerClass {
95
95
  type: tunnel.type,
96
96
  target: tunnel.target,
97
97
  domain: tunnel.domain,
98
+ customDomain: tunnel.customDomain,
98
99
  subdomain: tunnel.subdomain,
99
100
  serve: tunnel.serve,
100
101
  status: tunnel.status,
@@ -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
  });
@@ -106,11 +106,12 @@ class Format {
106
106
  static entryHost(tunnel) {
107
107
  let host = '';
108
108
  host += tunnel.subdomain;
109
- host += '.';
110
- // todo custom domain
111
- host += tunnel.region.toLowerCase();
112
- host += '-';
113
- host += tunnel.sshId;
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;
@@ -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
- // todo custom domain
18
- const hostname = `${this.subdomain}.${this.region.toLowerCase()}-${this.sshId}.${this.domain}`;
19
- r.resolveCname(hostname, (err, a1) => {
20
- if (err || !a1 || a1.length !== 1) {
21
- this.valid = false;
22
- this.checking = false;
23
- }
24
- else {
25
- r.resolve4(a1[0], (err, a2) => {
26
- if (err || !a2 || a2.length !== 1) {
27
- this.valid = false;
28
- this.checking = false;
29
- }
30
- else {
31
- this.valid = a2[0] === this.sshIp;
32
- this.checking = false;
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();
@@ -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.18-dev",
4
+ "version": "1.8.20-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {