From 73f26d6e058a01aa080ab31ef920195a27cf245d Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 6 Jun 2018 09:44:35 +0000 Subject: [PATCH] fix finalhandler for 404s --- bin/telebitd.js | 4 ++-- lib/handlers.js | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/bin/telebitd.js b/bin/telebitd.js index a0f07dc..edf7445 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -5,7 +5,7 @@ var pkg = require('../package.json'); var argv = process.argv.slice(2); -var telebitd = require('../'); +var relay = require('../'); var Greenlock = require('greenlock'); var confIndex = argv.indexOf('--config'); @@ -168,7 +168,7 @@ function applyConfig(config) { }; var net = require('net'); - var netConnHandlers = telebitd.create(state); // { tcp, ws } + var netConnHandlers = relay.create(state); // { tcp, ws } var WebSocketServer = require('ws').Server; var wss = new WebSocketServer({ server: (state.httpTunnelServer || state.httpServer) }); wss.on('connection', netConnHandlers.ws); diff --git a/lib/handlers.js b/lib/handlers.js index bd69a15..2acae41 100644 --- a/lib/handlers.js +++ b/lib/handlers.js @@ -114,13 +114,11 @@ module.exports.create = function (state) { // // To ADMIN / CONTROL PANEL of the Tunnel Server Itself // - var serveAdmin = require('serve-static')(__dirname + '/admin', { redirect: true }); + var serveAdmin = require('serve-static')(__dirname + '/../admin', { redirect: true }); var finalhandler = require('finalhandler'); state.httpTunnelServer = http.createServer(function (req, res) { res.setHeader('connection', 'close'); - serveAdmin(req, res, function () { - finalhandler(req, res) - }); + serveAdmin(req, res, finalhandler(req, res)); }); Object.keys(state.tlsOptions).forEach(function (key) { tunnelAdminTlsOpts[key] = state.tlsOptions[key]; @@ -152,7 +150,7 @@ module.exports.create = function (state) { // // First time setup // - var serveSetup = require('serve-static')(__dirname + '/admin/setup', { redirect: true }); + var serveSetup = require('serve-static')(__dirname + '/../admin/setup', { redirect: true }); var finalhandler = require('finalhandler'); state.httpSetupServer = http.createServer(function (req, res) { if (req.socket.encrypted) {