buddy-tunnel
Advanced tools
Comparing version 1.4.14-dev to 1.6.0-dev
{ | ||
"name": "buddy-tunnel", | ||
"preferGlobal": false, | ||
"version": "1.4.14-dev", | ||
"version": "1.6.0-dev", | ||
"license": "MIT", | ||
@@ -25,3 +25,3 @@ "dependencies": { | ||
"uuid": "9.0.1", | ||
"ws": "8.16.0" | ||
"ws": "8.18.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "devDependencies": { |
@@ -126,2 +126,4 @@ const EventEmitter = require('events'); | ||
if (!tunnel) { | ||
logger.debug('new tunnel'); | ||
logger.debug(data); | ||
this.addTunnel(new Tunnel(data)); | ||
@@ -128,0 +130,0 @@ } else if (tunnel.hasChanged(data)) { |
@@ -92,2 +92,6 @@ const { Command } = require('commander'); | ||
await Output.spinner(TXT_ENABLING_AGENT); | ||
if (process.env.DEBUG === '1') { | ||
AgentManager.start(); | ||
return; | ||
} | ||
try { | ||
@@ -94,0 +98,0 @@ await AgentManager.system.enable(); |
@@ -543,3 +543,3 @@ const { | ||
} | ||
}, fillString('Dns:', ROW_LENGTH)); | ||
}, fillString('DNS:', ROW_LENGTH)); | ||
} | ||
@@ -546,0 +546,0 @@ |
@@ -20,3 +20,5 @@ const { Client } = require('ssh2'); | ||
SOCKET_TYPE_HTTP1, | ||
SOCKET_TYPE_HTTP2 | ||
SOCKET_TYPE_HTTP2, | ||
SOCKET_TYPE_SSH, | ||
SSH_CLIENT_EVENT_STREAM_SSH | ||
} = require('../utils'); | ||
@@ -129,2 +131,7 @@ | ||
} | ||
if (type === SOCKET_TYPE_SSH) { | ||
logger.debug(LOG_DETECTED_STREAM('SSH')); | ||
triggerStream(SSH_CLIENT_EVENT_STREAM_SSH, ip); | ||
return; | ||
} | ||
logger.debug(LOG_WRONG_STREAM); | ||
@@ -131,0 +138,0 @@ stream.emit('error', new Error(ERR_WRONG_STREAM)); |
@@ -205,2 +205,3 @@ const ERR_AGENT_NOT_REGISTERED = 'Agent not registered. Exiting...'; | ||
const LOG_TUNNEL_TLS_AGENT_STREAM = (id) => `New TLS connection on tunnel '${id}'. Terminated at agent. Handle TLS`; | ||
const LOG_TUNNEL_SSH_STREAM = (id) => `New SSH connection on tunnel '${id}'. Stream to localhost`; | ||
@@ -212,2 +213,3 @@ module.exports = { | ||
LOG_TUNNEL_TLS_AGENT_STREAM, | ||
LOG_TUNNEL_SSH_STREAM, | ||
LOG_TUNNEL_TLS_REGION_STREAM, | ||
@@ -214,0 +216,0 @@ LOG_TUNNEL_TLS_TARGET_STREAM, |
@@ -22,2 +22,3 @@ const basicAuth = require('basic-auth'); | ||
const ServerTls = require('./server/tls.js'); | ||
const ServerSsh = require('./server/ssh.js'); | ||
const logger = require('./logger.js'); | ||
@@ -76,4 +77,7 @@ const TunnelIdentification = require('./tunnel/identification.js'); | ||
TUNNEL_EVENT_HTTP_RESPONSE, | ||
TUNNEL_EVENT_STOPPED | ||
TUNNEL_EVENT_STOPPED, | ||
TUNNEL_SSH, | ||
SSH_CLIENT_EVENT_STREAM_SSH | ||
} = require('./utils'); | ||
const { LOG_TUNNEL_SSH_STREAM } = require('./texts'); | ||
@@ -159,4 +163,5 @@ class Tunnel extends EventEmitter { | ||
this.sshForwardPort = sshSettings.forwardPort; | ||
this.sshClientUser = sshSettings.clientUser; | ||
this.sshClientPassword = sshSettings.clientPassword; | ||
} | ||
this.targetProto = 'http'; | ||
@@ -181,2 +186,6 @@ this.targetHost = 'localhost'; | ||
} | ||
} else if (this.type === TUNNEL_SSH) { | ||
this.targetHost = 'localhost'; | ||
this.targetProto = 'ssh://'; | ||
this.targetPort = 22; | ||
} else { | ||
@@ -200,2 +209,3 @@ const m = this.target.match(TARGET_TCP_TLS_REGEX); | ||
this.http1server = null; | ||
this.sshServer = null; | ||
this.ssh = null; | ||
@@ -260,2 +270,4 @@ this.started = false; | ||
if (this.sshForwardPort !== tunnel.sshForwardPort) return true; | ||
if (this.sshClientPassword !== tunnel.sshClientPassword) return true; | ||
if (this.sshClientUser !== tunnel.sshClientUser) return true; | ||
if (this.whitelist.length !== tunnel.whitelist.length) return true; | ||
@@ -483,2 +495,6 @@ this.whitelist.sort(); | ||
canStreamSsh() { | ||
return this.type === TUNNEL_SSH; | ||
} | ||
canStreamHttp() { | ||
@@ -503,2 +519,3 @@ return this.type === TUNNEL_HTTP; | ||
stream.end(); | ||
return; | ||
} | ||
@@ -516,2 +533,3 @@ logger.debug(LOG_TUNNEL_HTTP1_STREAM(this.id)); | ||
stream.end(); | ||
return; | ||
} | ||
@@ -526,2 +544,15 @@ logger.debug(LOG_TUNNEL_HTTP2_STREAM(this.id)); | ||
sshStreamSsh(stream) { | ||
if (!this.canStreamSsh()) { | ||
stream.end(); | ||
return; | ||
} | ||
logger.debug(LOG_TUNNEL_SSH_STREAM(this.id)); | ||
if (this.sshServer) { | ||
this.sshServer.handleSshTunnel(stream); | ||
return; | ||
} | ||
stream.end(); | ||
} | ||
sshStreamTls(stream) { | ||
@@ -558,3 +589,3 @@ if (!this.canStreamTls()) { | ||
// target latency | ||
if (!this.serve) { | ||
if (!this.serve && this.type !== TUNNEL_SSH) { | ||
this.targetLatency = new TunnelLatency(this.targetHost, this.targetPort); | ||
@@ -587,2 +618,5 @@ this.targetLatency.on(TUNNEL_LATENCY_EVENT_RECONNECTED, () => this.targetReconnected()); | ||
this.http1server.on(HTTP1_REQUEST, (req, res) => this.httpRequest(req, res)); | ||
} else if (this.type === TUNNEL_SSH) { | ||
// ssh server | ||
this.sshServer = new ServerSsh(this.sshClientUser, this.sshClientPassword); | ||
} | ||
@@ -593,6 +627,7 @@ // ssh | ||
this.ssh.on(SSH_CLIENT_EVENT_DISCONNECTED, () => this.sshDisconnected()); | ||
this.ssh.on(SSH_CLIENT_EVENT_STREAM_TCP, (stream, info) => this.sshStreamTcp(stream, info)); | ||
this.ssh.on(SSH_CLIENT_EVENT_STREAM_TLS, (stream, info) => this.sshStreamTls(stream, info)); | ||
this.ssh.on(SSH_CLIENT_EVENT_STREAM_TCP, (stream) => this.sshStreamTcp(stream)); | ||
this.ssh.on(SSH_CLIENT_EVENT_STREAM_TLS, (stream) => this.sshStreamTls(stream)); | ||
this.ssh.on(SSH_CLIENT_EVENT_STREAM_HTTP1, (stream, info, ip) => this.sshStreamHttp1(stream, info, ip)); | ||
this.ssh.on(SSH_CLIENT_EVENT_STREAM_HTTP2, (stream, info, ip) => this.sshStreamHttp2(stream, info, ip)); | ||
this.ssh.on(SSH_CLIENT_EVENT_STREAM_SSH, (stream) => this.sshStreamSsh(stream)); | ||
this.ssh.openKeepAlive(); | ||
@@ -630,2 +665,7 @@ } | ||
} | ||
if (this.sshServer) { | ||
this.sshServer.removeAllListeners(); | ||
this.sshServer.stop(); | ||
this.sshServer = null; | ||
} | ||
if (this.identify) { | ||
@@ -632,0 +672,0 @@ this.identify.removeAllListeners(); |
@@ -41,2 +41,3 @@ const { resolve } = require('path'); | ||
const TUNNEL_TLS = 'TLS'; | ||
const TUNNEL_SSH = 'SSH'; | ||
@@ -59,2 +60,3 @@ const EVENT_TUNNEL_IDENTIFIED = 'tunnel identified'; | ||
const SSH_CLIENT_EVENT_DISCONNECTED = 'disconnected'; | ||
const SSH_CLIENT_EVENT_STREAM_SSH = 'stream ssh'; | ||
const SSH_CLIENT_EVENT_STREAM_TCP = 'stream tcp'; | ||
@@ -69,2 +71,3 @@ const SSH_CLIENT_EVENT_STREAM_TLS = 'stream tls'; | ||
const SOCKET_TYPE_HTTP2 = 3; | ||
const SOCKET_TYPE_SSH = 4; | ||
@@ -328,2 +331,3 @@ const TUNNEL_HTTP_RATE_LIMIT = 2000; | ||
TUNNEL_TLS, | ||
TUNNEL_SSH, | ||
TUNNEL_OPEN, | ||
@@ -361,2 +365,3 @@ TUNNEL_CLOSED, | ||
SSH_CLIENT_EVENT_STREAM_TCP, | ||
SSH_CLIENT_EVENT_STREAM_SSH, | ||
SSH_CLIENT_EVENT_STREAM_TLS, | ||
@@ -369,2 +374,3 @@ SSH_CLIENT_EVENT_STREAM_HTTP1, | ||
SOCKET_TYPE_HTTP2, | ||
SOCKET_TYPE_SSH, | ||
TUNNEL_HTTP_RATE_LIMIT, | ||
@@ -371,0 +377,0 @@ TUNNEL_HTTP_RATE_WINDOW, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
340810
93
8069
16
25