From 3a36248377f205a735e0e1fec0fa1792c26e06df Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 5 Oct 2016 23:27:57 -0600 Subject: [PATCH] allow missing proto in local proxy --- bin/stunnel.js | 9 +++++++++ wsclient.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/stunnel.js b/bin/stunnel.js index 396a961..81ba1d4 100755 --- a/bin/stunnel.js +++ b/bin/stunnel.js @@ -14,6 +14,10 @@ function collectProxies(val, memo) { // http:john.example.com:3000 // http://john.example.com:3000 var parts = location.split(':'); + if (!parts[1]) { + parts[1] = parts[0]; + parts[0] = 'https'; + } parts[0] = parts[0].toLowerCase(); parts[1] = parts[1].toLowerCase().replace(/(\/\/)?/, '') || '*'; parts[2] = parseInt(parts[2], 10) || 0; @@ -124,6 +128,11 @@ program.net = { return socket; } }; + +program.locals.forEach(function (proxy) { + console.log('[local proxy]', proxy.protocol + '://' + proxy.hostname + ':' + proxy.port); +}); + stunnel.connect(program); }()); diff --git a/wsclient.js b/wsclient.js index 2e4051f..8c647e9 100644 --- a/wsclient.js +++ b/wsclient.js @@ -24,7 +24,7 @@ function socketToId(socket) { /* var request = require('request'); -request.get('https://pokemap.hellabit.com:3000?access_token=' + token, { rejectUnauthorized: false }, function (err, resp) { +request.get('https://pokemap.hellabit.com/?access_token=' + token, { rejectUnauthorized: false }, function (err, resp) { console.log('resp.body'); console.log(resp.body); });