From fda19c7a076013409f46144ea36826c26a4a8821 Mon Sep 17 00:00:00 2001 From: warner Date: Thu, 28 Sep 2017 14:40:57 -0500 Subject: [PATCH] update readme and proxy PAC is repetitively redundant --- README.md | 13 +++++++++++++ cbt_tunnels.js | 4 ++-- tunnel_start.js | 14 ++++++++------ utils.js | 1 - 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 62f1370..46450d1 100755 --- a/README.md +++ b/README.md @@ -46,6 +46,19 @@ There are three options provided for you to do this: Command line: 'cbt_tunnels --username USERNAME --authkey AUTHKEY --proxyIp PROXYIP --proxyPort PROXYPORT --proxyUser PROXYUSER --proxyPass PROXYPASS' Scripted: 'cbt.start({"username":"USERNAME","authkey":"AUTHKEY","proxyIp":"PROXYIP","proxyPort":"PROXYPORT","proxyUser:":"PROXYUSER","proxyPass":"PROXYPASS"},function(err){ if(!err) do stuff })' +##### PAC File: + In lieu of specifying a specific proxy server, you may provide a proxy auto-config (PAC) file. + Each request made through your local machine will follow the routing directives listed in + the PAC. If the HTTP_PROXY or HTTPS_PROXY options listed below are employed, they will take + precedence in routing the connection from your local machine to CrossBrowserTesting. It does + not make sense to use the above Proxy Server option alongside the PAC file option, but in the + case that you do, the Proxy Server option will take precedence. You may specify a path to a + file or a URL. + + Basic usage: + Command line: 'cbt_tunnels --username USERNAME --authkey AUTHKEY --pac URL/PATHTOFILE' + Scripted: 'cbt.start({"username":"USERNAME","authkey":"AUTHKEY","pac":"URL/PATHTOFILE"},function(err){ if(!err) do stuff })' + ##### Note: All flags may also be set as environment variables beginning with CBT_TUNNELS. e.g. Instead of typing --username, you may instead set the environment variable diff --git a/cbt_tunnels.js b/cbt_tunnels.js index 1475ca4..ac23468 100755 --- a/cbt_tunnels.js +++ b/cbt_tunnels.js @@ -143,7 +143,7 @@ function cbtSocket(api, params) { }); conn.on('connect',function(){ - if(params.proxyPac){ + if(params.pac){ console.log('Connecting using PAC file...'); }else{ console.log('Connecting as '+self.tType+'...'); @@ -279,7 +279,7 @@ function cbtSocket(api, params) { // var host = self.host = data.host; // var port = self.port = data.port; // } - utils.determineHost({host:data.host,port:data.port,proxyHost:self.proxyHost,proxyPort:self.proxyPort,tType:self.tType},params.proxyPac,function(err,hostInfo){ + utils.determineHost({host:data.host,port:data.port,proxyHost:self.proxyHost,proxyPort:self.proxyPort,tType:self.tType},params.pac,function(err,hostInfo){ var host = self.host = hostInfo.host; var port = self.port = hostInfo.port; if(host === 'local' && self.tType === 'webserver'){ diff --git a/tunnel_start.js b/tunnel_start.js index ca7d8a1..5f50c66 100755 --- a/tunnel_start.js +++ b/tunnel_start.js @@ -10,7 +10,7 @@ var _ = require('lodash'), help = gfx.help, validParameters = ['quiet', 'proxyUser', 'proxyPass', 'httpsProxy', 'httpProxy', '_', 'ready', 'username', 'authkey', '$0', 'simpleproxy', 'tunnel', 'webserver', 'cmd', 'proxyIp', - 'proxyPort', 'port', 'dir', 'verbose', 'kill', 'test', 'tunnelname', 'secret', 'proxyPac']; + 'proxyPort', 'port', 'dir', 'verbose', 'kill', 'test', 'tunnelname', 'secret', 'pac']; var validateArgs = function(cmdArgs){ // make sure that user has provided username/authkey and no extraneous options @@ -62,15 +62,16 @@ var determineTunnelType = function(cmdArgs){ } var pacInit = function(cbtUrls,cmdArgs,cb){ - if(cmdArgs.proxyPac){ - utils.getPac(cmdArgs.proxyPac,function(err,pac){ + if(cmdArgs.pac){ + console.log(cmdArgs.pac); + utils.getPac(cmdArgs.pac,function(err,pac){ if(err){ cb(err); } if(!cmdArgs.httpProxy){ utils.determineHost({host:'https://'+cbtUrls.node,port:443},pac,function(err,hostInfo){ if(hostInfo.host+':'+hostInfo.port!=='https://'+cbtUrls.node+':'+443){ - utils.setProxies(true,'https://'+hostInfo.host+':'+hostInfo.port); + utils.setProxies(false,'https://'+hostInfo.host+':'+hostInfo.port); } }); } @@ -195,9 +196,10 @@ module.exports = { pacInit(cbtUrls,cmdArgs,function(err,pac){ if(err){ + warn("Failed to initialize PAC"); return cb(err); } - cmdArgs.proxyPac = pac; + cmdArgs.pac = pac; if(cmdArgs.httpProxy){ utils.setProxies(false,cmdArgs.httpProxy); } @@ -222,7 +224,7 @@ module.exports = { cmd: !!cmdArgs.cmd, ready: !!cmdArgs.ready, secret: cmdArgs.secret, - proxyPac: cmdArgs.proxyPac + pac: cmdArgs.pac } // This api call just to make sure the credentials are valid. diff --git a/utils.js b/utils.js index 34b2563..10a27bc 100755 --- a/utils.js +++ b/utils.js @@ -27,7 +27,6 @@ module.exports = { }, setProxies: function(secure,proxy){ - console.log("Setting proxies..."); if(secure){ console.log('HTTPS proxy set to '+proxy); process.env.https_proxy = proxy;