Navigation Menu

Skip to content

Commit

Permalink
noProxy, more aggressive anti-caching for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Jun 28, 2012
1 parent c87d086 commit 64e05b7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Expand Up @@ -86,6 +86,8 @@ which uses the `Xvfb` command to create a fake X server.
To use the browser with a proxy, set `opts.proxy` as a colon-separated
`'host:port'` string.

Set proxy routes to skip over with `opts.noProxy`.

`cb` fires with `cb(err, ps)` where `ps` is the process object created with
`spawn()`.

Expand Down
31 changes: 24 additions & 7 deletions lib/run.js
Expand Up @@ -10,11 +10,17 @@ argue.firefox = function (br, uri, opts, cb) {
var m = /^(?:http:\/\/)?([^:\/]+)(?::(\d+))?/.exec(opts.proxy);
var host = JSON.stringify(m[1]);
var port = m[2] || 80;
prefs +=
'user_pref("network.proxy.http", ' + host + ');\n'
+ 'user_pref("network.proxy.http_port", ' + port + ');\n'
+ 'user_pref("network.proxy.type", 1);\n'
;
prefs += [
'"network.proxy.http", ' + host,
'"network.proxy.http_port", ' + port,
'"network.proxy.type", 1',
'"browser.cache.disk.capacity", 0',
'"browser.cache.disk.smart_size.enabled", false',
'"browser.cache.disk.smart_size.first_run", false',
'"network.proxy.no_proxies_on", '
+ JSON.stringify(opts.noProxy || '')
,
].map(function (x) { return 'user_pref(' + x + ');\n' }).join('');
}

var file = path.join(path.dirname(br.profile.file), 'user.js');
Expand All @@ -32,6 +38,7 @@ argue.chrome = function (br, uri, opts, cb) {
cb(null, [
opts.proxy ? '--proxy-server=' + opts.proxy : null,
br.profile ? '--user-data-dir=' + br.profile : null,
'--incognito',
uri,
].filter(Boolean));
};
Expand Down Expand Up @@ -76,8 +83,18 @@ module.exports = function (config, name, version) {
});

argue[m.type](m, uri, opts, function (err, args) {
if (err) return cb(err)
else cb(null, spawn(m.command, args, { env : env }))
if (err) return cb(err);
if (opts.noProxy && env.no_proxy === undefined) {
env.no_proxy = opts.noProxy;
}
if (opts.proxy && env.http_proxy === undefined) {
env.http_proxy = opts.proxy;
}
if (opts.proxy && env.HTTP_PROXY === undefined) {
env.HTTP_PROXY = opts.proxy;
}

cb(null, spawn(m.command, args, { env : env }))
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name" : "browser-launcher",
"version" : "0.0.0",
"version" : "0.0.1",
"description" : "detect and launch browser versions, headlessly or otherwise",
"main" : "index.js",
"bin" : {},
Expand Down

0 comments on commit 64e05b7

Please sign in to comment.