Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
update readme and proxy PAC is repetitively redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed Sep 28, 2017
1 parent a1357f0 commit fda19c7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cbt_tunnels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+'...');
Expand Down Expand Up @@ -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'){
Expand Down
14 changes: 8 additions & 6 deletions tunnel_start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
});
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fda19c7

Please sign in to comment.