Merge branch 'master' of github.com:Daplie/node-tunnel-server

This commit is contained in:
AJ ONeal 2016-10-18 15:33:48 -06:00
commit 594a0786c9
2 changed files with 8 additions and 1 deletions

View File

@ -50,6 +50,7 @@
"commander": "^2.9.0", "commander": "^2.9.0",
"jsonwebtoken": "^7.1.9", "jsonwebtoken": "^7.1.9",
"localhost.daplie.com-certificates": "^1.2.3", "localhost.daplie.com-certificates": "^1.2.3",
"redirect-https": "^1.1.0",
"sni": "^1.0.0", "sni": "^1.0.0",
"tunnel-packer": "^1.0.0", "tunnel-packer": "^1.0.0",
"ws": "^1.1.1" "ws": "^1.1.1"

View File

@ -55,6 +55,7 @@ module.exports.create = function (copts) {
}); });
remote = remote || {}; remote = remote || {};
token.domains.forEach(function (domainname) { token.domains.forEach(function (domainname) {
console.log('domainname', domainname);
remotes[domainname] = remote; remotes[domainname] = remote;
}); });
var handlers = { var handlers = {
@ -135,7 +136,7 @@ module.exports.create = function (copts) {
function connectHttp(servername, socket) { function connectHttp(servername, socket) {
console.log("connectHttp('" + servername + "', socket)"); console.log("connectHttp('" + servername + "', socket)");
socket.__my_servername = servername; socket.__my_servername = servername;
httpServer.emit('connection', socket); redirectServer.emit('connection', socket);
} }
function connectHttps(servername, socket) { function connectHttps(servername, socket) {
@ -321,7 +322,12 @@ module.exports.create = function (copts) {
var remotes = {}; var remotes = {};
var selfnames = copts.servernames; var selfnames = copts.servernames;
var secret = copts.secret; var secret = copts.secret;
var redirectHttps = require('redirect-https')();
var redirectServer = http.createServer(function (req, res) {
res.setHeader('Connection', 'close');
redirectHttps(req, res);
});
var httpServer = http.createServer(function (req, res) { var httpServer = http.createServer(function (req, res) {
console.log('req.socket.encrypted', req.socket.encrypted); console.log('req.socket.encrypted', req.socket.encrypted);
res.end('Hello, World!'); res.end('Hello, World!');