From 05cb157cfc75633a60632bfeb2dae57d5ab0f6fb Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 31 May 2018 06:12:37 +0000 Subject: [PATCH] typo fixes and pass serviceport --- bin/telebitd.js | 2 +- lib/unwrap-tls.js | 11 +++++++---- telebitd.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/telebitd.js b/bin/telebitd.js index b6adc27..248e770 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -154,7 +154,7 @@ function applyConfig(config) { state.tcp[port].listen(port, function () { console.log('listening plain TCP on ' + port); }); - state.tcp[port].on('connection', netConnHandlers.tcp); + state.tcp[port].on('connection', function (conn) { netConnHandlers.tcp(conn, port); }); }); //}); } diff --git a/lib/unwrap-tls.js b/lib/unwrap-tls.js index be3200a..3a18b60 100644 --- a/lib/unwrap-tls.js +++ b/lib/unwrap-tls.js @@ -3,11 +3,13 @@ var Packer = require('proxy-packer'); var sni = require('sni'); -function pipeWs(servername, service, conn, remote) { +function pipeWs(servername, service, conn, remote, serviceport) { console.log('[pipeWs] servername:', servername, 'service:', service); var browserAddr = Packer.socketToAddr(conn); browserAddr.service = service; + browserAddr.serviceport = serviceport; + browserAddr.name = servername; var cid = Packer.addrToId(browserAddr); conn.tunnelCid = cid; console.log('[pipeWs] browser is', cid, 'home-cloud is', Packer.socketToId(remote.upgradeReq.socket)); @@ -51,7 +53,8 @@ function pipeWs(servername, service, conn, remote) { module.exports.createTcpConnectionHandler = function (copts) { var Devices = copts.Devices; - return function onTcpConnection(conn) { + return function onTcpConnection(conn, serviceport) { + console.log('[new conn] from port', serviceport); // this works when I put it here, but I don't know if it's tls yet here // httpsServer.emit('connection', socket); //tls3000.emit('connection', socket); @@ -124,7 +127,7 @@ module.exports.createTcpConnectionHandler = function (copts) { console.log("pipeWs(servername, service, socket, deviceLists['" + servername + "'])"); deferData(); - pipeWs(servername, service, conn, nextDevice); + pipeWs(servername, service, conn, nextDevice, serviceport); } if (copts.config.vhost) { @@ -175,7 +178,7 @@ module.exports.createTcpConnectionHandler = function (copts) { // HTTP if (Devices.exist(copts.deviceLists, servername)) { deferData(); - pipeWs(servername, service, conn, Devices.next(copts.deviceLists, servername)); + pipeWs(servername, service, conn, Devices.next(copts.deviceLists, servername), serviceport); return; } deferData('handleHttp'); diff --git a/telebitd.js b/telebitd.js index cefc613..1f383cc 100644 --- a/telebitd.js +++ b/telebitd.js @@ -261,7 +261,7 @@ module.exports.create = function (state) { } , onmessage: function (tun) { - var cid = packer.addrToId(tun); + var cid = Packer.addrToId(tun); console.log("remote '" + logName() + "' has data for '" + cid + "'", tun.data.byteLength); var browserConn = getBrowserConn(cid);