mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-02-02 11:48:25 +00:00
feat: proxy rules with --proxy-rules
flag (#854)
See https://electronjs.org/docs/api/session?q=proxy#sessetproxyconfig-callback
This commit is contained in:
parent
84f06e3e79
commit
ef13ff1e1d
@ -75,6 +75,15 @@ function clearCache(browserWindow, targetUrl = null) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setProxyRules(browserWindow, proxyRules) {
|
||||||
|
browserWindow.webContents.session.setProxy(
|
||||||
|
{
|
||||||
|
proxyRules,
|
||||||
|
},
|
||||||
|
() => {},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {{}} inpOptions AppArgs from nativefier.json
|
* @param {{}} inpOptions AppArgs from nativefier.json
|
||||||
@ -284,6 +293,11 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
|
|||||||
if (options.userAgent) {
|
if (options.userAgent) {
|
||||||
window.webContents.setUserAgent(options.userAgent);
|
window.webContents.setUserAgent(options.userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.proxyRules) {
|
||||||
|
setProxyRules(window, options.proxyRules);
|
||||||
|
}
|
||||||
|
|
||||||
maybeInjectCss(window);
|
maybeInjectCss(window);
|
||||||
sendParamsOnDidFinishLoad(window);
|
sendParamsOnDidFinishLoad(window);
|
||||||
window.webContents.on('new-window', onNewWindow);
|
window.webContents.on('new-window', onNewWindow);
|
||||||
@ -318,6 +332,10 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
|
|||||||
mainWindow.webContents.setUserAgent(options.userAgent);
|
mainWindow.webContents.setUserAgent(options.userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.proxyRules) {
|
||||||
|
setProxyRules(mainWindow, options.proxyRules);
|
||||||
|
}
|
||||||
|
|
||||||
maybeInjectCss(mainWindow);
|
maybeInjectCss(mainWindow);
|
||||||
sendParamsOnDidFinishLoad(mainWindow);
|
sendParamsOnDidFinishLoad(mainWindow);
|
||||||
|
|
||||||
|
16
docs/api.md
16
docs/api.md
@ -43,6 +43,7 @@
|
|||||||
- [[enable-es3-apis]](#enable-es3-apis)
|
- [[enable-es3-apis]](#enable-es3-apis)
|
||||||
- [[insecure]](#insecure)
|
- [[insecure]](#insecure)
|
||||||
- [[internal-urls]](#internal-urls)
|
- [[internal-urls]](#internal-urls)
|
||||||
|
- [[proxy-rules]](#proxy-rules)
|
||||||
- [[flash]](#flash)
|
- [[flash]](#flash)
|
||||||
- [[flash-path]](#flash-path)
|
- [[flash-path]](#flash-path)
|
||||||
- [[disk-cache-size]](#disk-cache-size)
|
- [[disk-cache-size]](#disk-cache-size)
|
||||||
@ -378,6 +379,21 @@ Or, if you want to allow all domains for example for external auths,
|
|||||||
nativefier https://google.com --internal-urls ".*?"
|
nativefier https://google.com --internal-urls ".*?"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### [proxy-rules]
|
||||||
|
|
||||||
|
```
|
||||||
|
--proxy-rules <value>
|
||||||
|
```
|
||||||
|
|
||||||
|
Proxy rules. See [proxyRules](https://electronjs.org/docs/api/session?q=proxy#sessetproxyconfig-callback) for more details.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nativefier https://google.com --proxy-rules http://127.0.0.1:1080
|
||||||
|
```
|
||||||
|
|
||||||
#### [flash]
|
#### [flash]
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -42,6 +42,7 @@ function selectAppArgs(options) {
|
|||||||
disableDevTools: options.disableDevTools,
|
disableDevTools: options.disableDevTools,
|
||||||
zoom: options.zoom,
|
zoom: options.zoom,
|
||||||
internalUrls: options.internalUrls,
|
internalUrls: options.internalUrls,
|
||||||
|
proxyRules: options.proxyRules,
|
||||||
crashReporter: options.crashReporter,
|
crashReporter: options.crashReporter,
|
||||||
singleInstance: options.singleInstance,
|
singleInstance: options.singleInstance,
|
||||||
clearCache: options.clearCache,
|
clearCache: options.clearCache,
|
||||||
|
@ -200,6 +200,10 @@ if (require.main === module) {
|
|||||||
'--internal-urls <value>',
|
'--internal-urls <value>',
|
||||||
'regular expression of URLs to consider "internal"; all other URLs will be opened in an external browser. (default: URLs on same second-level domain as app)',
|
'regular expression of URLs to consider "internal"; all other URLs will be opened in an external browser. (default: URLs on same second-level domain as app)',
|
||||||
)
|
)
|
||||||
|
.option(
|
||||||
|
'--proxy-rules <value>',
|
||||||
|
'proxy rules. See https://electronjs.org/docs/api/session?q=proxy#sessetproxyconfig-callback',
|
||||||
|
)
|
||||||
.option(
|
.option(
|
||||||
'--crash-reporter <value>',
|
'--crash-reporter <value>',
|
||||||
'remote server URL to send crash reports',
|
'remote server URL to send crash reports',
|
||||||
|
@ -58,6 +58,7 @@ export default function(inpOptions) {
|
|||||||
tmpdir: false,
|
tmpdir: false,
|
||||||
zoom: inpOptions.zoom || 1.0,
|
zoom: inpOptions.zoom || 1.0,
|
||||||
internalUrls: inpOptions.internalUrls || null,
|
internalUrls: inpOptions.internalUrls || null,
|
||||||
|
proxyRules: inpOptions.proxyRules || null,
|
||||||
singleInstance: inpOptions.singleInstance || false,
|
singleInstance: inpOptions.singleInstance || false,
|
||||||
clearCache: inpOptions.clearCache || false,
|
clearCache: inpOptions.clearCache || false,
|
||||||
appVersion: inpOptions.appVersion,
|
appVersion: inpOptions.appVersion,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user