Skip to content

Commit 1456c44

Browse files
committed
Merge remote-tracking branch 'origin/proxy_support' into testing
2 parents 38e5788 + 1e6394d commit 1456c44

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ Identifier for the current instance of the tunnel process. In `TRAVIS` setup `TR
137137
* `BROWSERSTACK_JSON`:
138138
Path to the browserstack.json file. If null, `browserstack.json` in the root directory will be used.
139139

140+
### Proxy support for BrowserStack local
141+
Add the following in `browserstack.json`
142+
```json
143+
...
144+
"proxy": {
145+
"host": "localhost",
146+
"port": 3128,
147+
"username": "foo",
148+
"password": "bar"
149+
}
150+
...
151+
```
140152

141153
### Secure Information
142154

lib/local.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) {
1919
tunnelCommand += port.toString() + ',';
2020
tunnelCommand += '0';
2121
tunnelCommand += (typeof uniqueIdentifier === 'undefined') ? ' -force -onlyAutomate' : ' -tunnelIdentifier ' + uniqueIdentifier;
22+
tunnelCommand += checkAndAddProxy();
2223

2324
if (typeof callback !== 'function') {
2425
callback = function(){};
@@ -62,6 +63,21 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) {
6263
that.process = subProcess;
6364
}
6465

66+
function checkAndAddProxy() {
67+
var proxy = config.proxy;
68+
if(typeof proxy == 'undefined') {
69+
return "";
70+
}
71+
var proxyCommand = "";
72+
proxyCommand += " -proxyHost " + proxy.host;
73+
proxyCommand += " -proxyPort " + proxy.port;
74+
if(typeof proxy.username !== 'undefined'){
75+
proxyCommand += " -proxyUser " + proxy.username;
76+
proxyCommand += " -proxyPass " + proxy.password;
77+
}
78+
return proxyCommand;
79+
}
80+
6581
fs.exists(localBinary, function(exists) {
6682
if (exists) {
6783
tunnelLauncher();

0 commit comments

Comments
 (0)