Merge pull request #4046 from deepak1556/session_proxy_patch
session: allow user to isolate pac script and proxy bypass rules
This commit is contained in:
commit
34c9279fc5
2 changed files with 26 additions and 12 deletions
|
@ -114,14 +114,27 @@ struct Converter<net::ProxyConfig> {
|
||||||
static bool FromV8(v8::Isolate* isolate,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Value> val,
|
v8::Local<v8::Value> val,
|
||||||
net::ProxyConfig* out) {
|
net::ProxyConfig* out) {
|
||||||
std::string proxy;
|
mate::Dictionary options;
|
||||||
if (!ConvertFromV8(isolate, val, &proxy))
|
if (!ConvertFromV8(isolate, val, &options)) {
|
||||||
return false;
|
// Fallback to previous api (https://git.io/vuhjj).
|
||||||
auto pac_url = GURL(proxy);
|
std::string proxy;
|
||||||
if (pac_url.is_valid()) {
|
if (!ConvertFromV8(isolate, val, &proxy))
|
||||||
|
return false;
|
||||||
|
auto pac_url = GURL(proxy);
|
||||||
|
if (pac_url.is_valid()) {
|
||||||
|
out->set_pac_url(pac_url);
|
||||||
|
} else {
|
||||||
|
out->proxy_rules().ParseFromString(proxy);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GURL pac_url;
|
||||||
|
std::string rules;
|
||||||
|
if (options.Get("pacScript", &pac_url)) {
|
||||||
out->set_pac_url(pac_url);
|
out->set_pac_url(pac_url);
|
||||||
} else {
|
} else if (options.Get("proxyRules", &rules)) {
|
||||||
out->proxy_rules().ParseFromString(proxy);
|
out->proxy_rules().ParseFromString(rules);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,15 +181,16 @@ Clears the data of web storages.
|
||||||
|
|
||||||
#### `ses.setProxy(config, callback)`
|
#### `ses.setProxy(config, callback)`
|
||||||
|
|
||||||
* `config` String
|
* `config` Object
|
||||||
|
* `pacScript` String - The URL associated with the PAC file.
|
||||||
|
* `proxyRules` String - Rules indicating which proxies to use.
|
||||||
* `callback` Function - Called when operation is done.
|
* `callback` Function - Called when operation is done.
|
||||||
|
|
||||||
If `config` is a PAC url, it is used directly otherwise
|
When `pacScript` and `proxyRules` are provided together, the `proxyRules`
|
||||||
`config` is parsed based on the following rules indicating which
|
option is ignored and `pacScript` configuration is applied.
|
||||||
proxies to use for the session.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
config = scheme-proxies[";"<scheme-proxies>]
|
proxyRules = scheme-proxies[";"<scheme-proxies>]
|
||||||
scheme-proxies = [<url-scheme>"="]<proxy-uri-list>
|
scheme-proxies = [<url-scheme>"="]<proxy-uri-list>
|
||||||
url-scheme = "http" | "https" | "ftp" | "socks"
|
url-scheme = "http" | "https" | "ftp" | "socks"
|
||||||
proxy-uri-list = <proxy-uri>[","<proxy-uri-list>]
|
proxy-uri-list = <proxy-uri>[","<proxy-uri-list>]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue