bdy 1.25.28-stage → 1.25.29-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.
@@ -79,8 +79,9 @@ class Tunnel extends events_1.default {
79
79
  inFlight = new Set();
80
80
  constructor({ agent, id, sshHostKey, ...options }) {
81
81
  super();
82
- if (!sshHostKey)
83
- sshHostKey = require('../sshKeygen').createSshHostKey();
82
+ const { createSshHostKey, isSshHostKeyValid } = require('../sshKeygen');
83
+ if (!isSshHostKeyValid(sshHostKey))
84
+ sshHostKey = createSshHostKey();
84
85
  this.agent = agent;
85
86
  this.id = id;
86
87
  this.sshHostKey = sshHostKey;
@@ -593,60 +594,69 @@ class Tunnel extends events_1.default {
593
594
  return;
594
595
  this.started = true;
595
596
  logger_1.default.info((0, texts_1.LOG_STARTING_TUNNEL)(this.id));
596
- // region latency
597
- this.regionLatency = new latency_1.default(this.sshIp, this.sshPort);
598
- this.regionLatency.startChecking();
599
- // target latency
600
- if (!this.serve && this.type !== tunnel_1.TUNNEL_TYPE.SSH) {
601
- this.targetLatency = new latency_1.default(this.targetHost, this.targetPort);
602
- this.targetLatency.on(tunnel_1.TUNNEL_EVENT_LATENCY.RECONNECTED, () => this.targetReconnected());
603
- this.targetLatency.startChecking();
604
- }
605
- // dns health
606
- this.dns = new dns_1.default(this.sshIp, this.domain, this.subdomain, this.region, this.sshId);
607
- this.dns.startChecking();
608
- if (this.type === tunnel_1.TUNNEL_TYPE.TLS &&
609
- this.terminate === tunnel_1.TUNNEL_TERMINATE_AT.AGENT) {
610
- // tls
611
- const ServerTlsImpl = require('./server/tls').default;
612
- const tls = new ServerTlsImpl(this.key, this.cert, this.ca);
613
- tls.on(tunnel_1.TUNNEL_EVENT.TLS_SOCKET, (socket) => this.tlsSocket(socket));
614
- this.tls = tls;
615
- }
616
- else if (this.type === tunnel_1.TUNNEL_TYPE.HTTP) {
617
- // http
618
- this.httpLog = new log_1.default(this.log, this.circuitBreaker);
619
- this.httpLog.on(tunnel_1.TUNNEL_EVENT_HTTP.NEW_REQUEST, (logRequest) => this.httpLogRequest(logRequest));
620
- this.httpLog.on(tunnel_1.TUNNEL_EVENT_HTTP.NEW_RESPONSE, (logRequest) => this.httpLogResponse(logRequest));
621
- this.identify = new identification_1.default(this.targetProto, this.targetHost, this.targetPort, this.http2 || !!this.serve);
622
- this.identify.on(tunnel_1.TUNNEL_EVENT.IDENTIFIED, (type) => this.httpIdentified(type));
623
- const host = format_1.default.entryHostEncoded(this);
624
- this.http2server = new http2_1.default(host);
625
- this.http2server.on(tunnel_1.TUNNEL_EVENT.HTTP_SESSION_OPEN, (session) => this.httpConnectionOpen(session));
626
- this.http2server.on(tunnel_1.TUNNEL_EVENT.HTTP_SESSION_CLOSED, (session) => this.httpConnectionClosed(session));
627
- this.http2server.on(tunnel_1.TUNNEL_EVENT.HTTP_REQUEST, async (req, res) => await this.httpRequest(req, res));
628
- this.http1server = new http1_1.default(host);
629
- this.http1server.on(tunnel_1.TUNNEL_HTTP_SOCKET.OPEN, (socket) => this.httpConnectionOpen(socket));
630
- this.http1server.on(tunnel_1.TUNNEL_HTTP_SOCKET.CLOSED, (socket) => this.httpConnectionClosed(socket));
631
- this.http1server.on(tunnel_1.TUNNEL_EVENT.HTTP_REQUEST, async (req, res) => await this.httpRequest(req, res));
632
- }
633
- else if (this.type === tunnel_1.TUNNEL_TYPE.SSH) {
634
- // ssh server
635
- const ServerSsh = require('./server/ssh').default;
636
- this.sshServer = new ServerSsh(this.agent, this.sshClientUser || '', this.sshClientPassword || '', this.sshHostKey);
637
- }
638
- // ssh
639
- const SshClientImpl = require('./ssh/client').default;
640
- const ssh = new SshClientImpl(this.sshIp, this.sshPort, this.sshUser, this.sshPassword);
641
- ssh.on(tunnel_1.TUNNEL_SSH_EVENT.CONNECTED, () => this.sshConnected());
642
- ssh.on(tunnel_1.TUNNEL_SSH_EVENT.DISCONNECTED, () => this.sshDisconnected());
643
- ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TCP, (stream) => this.sshStreamTcp(stream));
644
- ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TLS, (stream) => this.sshStreamTls(stream));
645
- ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP1, (stream, info, ip) => this.sshStreamHttp1(stream, info, ip));
646
- ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP2, (stream, info, ip) => this.sshStreamHttp2(stream, info, ip));
647
- ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_SSH, (stream) => this.sshStreamSsh(stream));
648
- ssh.openKeepAlive();
649
- this.ssh = ssh;
597
+ try {
598
+ // region latency
599
+ this.regionLatency = new latency_1.default(this.sshIp, this.sshPort);
600
+ this.regionLatency.startChecking();
601
+ // target latency
602
+ if (!this.serve && this.type !== tunnel_1.TUNNEL_TYPE.SSH) {
603
+ this.targetLatency = new latency_1.default(this.targetHost, this.targetPort);
604
+ this.targetLatency.on(tunnel_1.TUNNEL_EVENT_LATENCY.RECONNECTED, () => this.targetReconnected());
605
+ this.targetLatency.startChecking();
606
+ }
607
+ // dns health
608
+ this.dns = new dns_1.default(this.sshIp, this.domain, this.subdomain, this.region, this.sshId);
609
+ this.dns.startChecking();
610
+ if (this.type === tunnel_1.TUNNEL_TYPE.TLS &&
611
+ this.terminate === tunnel_1.TUNNEL_TERMINATE_AT.AGENT) {
612
+ // tls
613
+ const ServerTlsImpl = require('./server/tls').default;
614
+ const tls = new ServerTlsImpl(this.key, this.cert, this.ca);
615
+ tls.on(tunnel_1.TUNNEL_EVENT.TLS_SOCKET, (socket) => this.tlsSocket(socket));
616
+ this.tls = tls;
617
+ }
618
+ else if (this.type === tunnel_1.TUNNEL_TYPE.HTTP) {
619
+ // http
620
+ this.httpLog = new log_1.default(this.log, this.circuitBreaker);
621
+ this.httpLog.on(tunnel_1.TUNNEL_EVENT_HTTP.NEW_REQUEST, (logRequest) => this.httpLogRequest(logRequest));
622
+ this.httpLog.on(tunnel_1.TUNNEL_EVENT_HTTP.NEW_RESPONSE, (logRequest) => this.httpLogResponse(logRequest));
623
+ this.identify = new identification_1.default(this.targetProto, this.targetHost, this.targetPort, this.http2 || !!this.serve);
624
+ this.identify.on(tunnel_1.TUNNEL_EVENT.IDENTIFIED, (type) => this.httpIdentified(type));
625
+ const host = format_1.default.entryHostEncoded(this);
626
+ this.http2server = new http2_1.default(host);
627
+ this.http2server.on(tunnel_1.TUNNEL_EVENT.HTTP_SESSION_OPEN, (session) => this.httpConnectionOpen(session));
628
+ this.http2server.on(tunnel_1.TUNNEL_EVENT.HTTP_SESSION_CLOSED, (session) => this.httpConnectionClosed(session));
629
+ this.http2server.on(tunnel_1.TUNNEL_EVENT.HTTP_REQUEST, async (req, res) => await this.httpRequest(req, res));
630
+ this.http1server = new http1_1.default(host);
631
+ this.http1server.on(tunnel_1.TUNNEL_HTTP_SOCKET.OPEN, (socket) => this.httpConnectionOpen(socket));
632
+ this.http1server.on(tunnel_1.TUNNEL_HTTP_SOCKET.CLOSED, (socket) => this.httpConnectionClosed(socket));
633
+ this.http1server.on(tunnel_1.TUNNEL_EVENT.HTTP_REQUEST, async (req, res) => await this.httpRequest(req, res));
634
+ }
635
+ else if (this.type === tunnel_1.TUNNEL_TYPE.SSH) {
636
+ // ssh server
637
+ const ServerSsh = require('./server/ssh').default;
638
+ this.sshServer = new ServerSsh(this.agent, this.sshClientUser || '', this.sshClientPassword || '', this.sshHostKey);
639
+ }
640
+ // ssh
641
+ const SshClientImpl = require('./ssh/client').default;
642
+ const ssh = new SshClientImpl(this.sshIp, this.sshPort, this.sshUser, this.sshPassword);
643
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.CONNECTED, () => this.sshConnected());
644
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.DISCONNECTED, () => this.sshDisconnected());
645
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TCP, (stream) => this.sshStreamTcp(stream));
646
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_TLS, (stream) => this.sshStreamTls(stream));
647
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP1, (stream, info, ip) => this.sshStreamHttp1(stream, info, ip));
648
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_HTTP2, (stream, info, ip) => this.sshStreamHttp2(stream, info, ip));
649
+ ssh.on(tunnel_1.TUNNEL_SSH_EVENT.STREAM_SSH, (stream) => this.sshStreamSsh(stream));
650
+ ssh.openKeepAlive();
651
+ this.ssh = ssh;
652
+ }
653
+ catch (err) {
654
+ // Undo the half-started state instead of leaving a tunnel that is "started" but never
655
+ // connected to the region: Agent.refreshTunnels starts it again on the next refresh.
656
+ logger_1.default.error((0, texts_1.LOG_TUNNEL_START_FAILED)(this.id));
657
+ logger_1.default.error(err);
658
+ this.stop(false);
659
+ }
650
660
  }
651
661
  stop(emitEvent = true) {
652
662
  if (!this.started)
@@ -95,6 +95,7 @@ var REST_API_SCOPE;
95
95
  REST_API_SCOPE["ENVIRONMENT_MANAGE"] = "ENVIRONMENT_MANAGE";
96
96
  REST_API_SCOPE["ENVIRONMENT_READ"] = "ENVIRONMENT_READ";
97
97
  REST_API_SCOPE["ENVIRONMENT_WRITE"] = "ENVIRONMENT_WRITE";
98
+ REST_API_SCOPE["INTEGRATION_MANAGE"] = "INTEGRATION_MANAGE";
98
99
  REST_API_SCOPE["INTEGRATION_READ"] = "INTEGRATION_READ";
99
100
  REST_API_SCOPE["PROJECT_MANAGE"] = "PROJECT_MANAGE";
100
101
  REST_API_SCOPE["PROJECT_READ"] = "PROJECT_READ";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.25.28-stage",
4
+ "version": "1.25.29-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "homepage": "https://buddy.works/docs/cli",