From 5abff544e916cb2694927c232bdb34d0c882e239 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 1 Jun 2018 01:36:49 -0600 Subject: [PATCH] ws --- lib/sorting-hat.js | 64 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/lib/sorting-hat.js b/lib/sorting-hat.js index f98acc3..21fae43 100644 --- a/lib/sorting-hat.js +++ b/lib/sorting-hat.js @@ -142,40 +142,40 @@ module.exports.assign = function (state, tun, cb) { } function invokeHandler(conf, tlsSocket, tun, id) { - if (parseInt(conf.handler, 10)) { - // TODO http-proxy with proper headers and ws support - var conn = getNetConn(conf.handler); - console.info("Port-Forwarding '" + (tun.name || tun.serviceport) + "' to '" + conf.handler + "'"); - conn.pipe(tlsSocket); - tlsSocket.pipe(conn); - return; - } - var handle = tun.name || tun.port; - var handler; - var path = require('path'); - var homedir = require('os').homedir(); - var localshare = path.join(homedir, '.local/share/telebit/apps'); + if (parseInt(conf.handler, 10)) { + // TODO http-proxy with proper headers and ws support + var conn = getNetConn(conf.handler); + console.info("Port-Forwarding '" + (tun.name || tun.serviceport) + "' to '" + conf.handler + "'"); + conn.pipe(tlsSocket); + tlsSocket.pipe(conn); + return; + } + var handle = tun.name || tun.port; + var handler; + var path = require('path'); + var homedir = require('os').homedir(); + var localshare = path.join(homedir, '.local/share/telebit/apps'); - if (/^~/.test(conf.handler)) { - conf.handler = require('path').join(require('os').homedir(), conf.handler.replace(/^~(\/?)/, '')); - } + if (/^~/.test(conf.handler)) { + conf.handler = require('path').join(require('os').homedir(), conf.handler.replace(/^~(\/?)/, '')); + } - try { - handler = require(conf.handler); - console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'"); - handler(tlsSocket, tun, id); - } catch(e1) { - try { - handler = require(path.join(localshare, conf.handler)); - console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'"); - handler(tlsSocket, tun, id); - } catch(e2) { - console.error("Failed to load '" + conf.handler + "':", e1.message); - console.error("Failed to load '" + path.join(localshare, conf.handler) + "':", e2.message); - console.warn("Using default handler for '" + handle + ":" + id + "'"); - handlers.https(tlsSocket, tun, id); - } - } + try { + handler = require(conf.handler); + console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'"); + handler(tlsSocket, tun, id); + } catch(e1) { + try { + handler = require(path.join(localshare, conf.handler)); + console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'"); + handler(tlsSocket, tun, id); + } catch(e2) { + console.error("Failed to load '" + conf.handler + "':", e1.message); + console.error("Failed to load '" + path.join(localshare, conf.handler) + "':", e2.message); + console.warn("Using default handler for '" + handle + ":" + id + "'"); + handlers.https(tlsSocket, tun, id); + } + } } function terminateTls(tun, cb) {