Add WebRTCIPPolicy setting to webContents and webview

Resolves #8777
Code to set and get the policy come from the muon framework code:
https://github.com/brave/muon/blob/master/atom/browser/api/atom_api_web_
contents.cc#L1324...L1343
This commit is contained in:
John Kleinschmidt 2017-03-08 09:55:59 -05:00
parent 4f817873f1
commit 1c2a78a896
7 changed files with 57 additions and 1 deletions

View file

@ -1245,6 +1245,20 @@ Schedules a full repaint of the window this web contents is in.
If *offscreen rendering* is enabled invalidates the frame and generates a new
one through the `'paint'` event.
#### `contents.getWebRTCIPHandlingPolicy()`
* Returns `String` - Returns the WebRTC IP Handling Policy
#### `contents.setWebRTCIPHandlingPolicy(policy)`
* `policy` String - Specify the WebRTC IP Handling Policy
* `default` - Exposes user's public and local IPs. This is the default behavior if not specified.
* `default_public_interface_only` - Exposes user's public IP, but does not expose user's local IP.
* `default_public_and_private_interfaces` - Exposes user's public and local IPs.
* `disable_non_proxied_udp` - Does not expose public or local IPs.
Setting the WebRTC IP handling policy allows you to control which IPs are exposed via WebRTC. See [BrowserLeaks](https://browserleaks.com/webrtc) for more details.
### Instance Properties
#### `contents.id`

View file

@ -289,6 +289,13 @@ win.on('resize', () => {
})
```
### `webrtcippolicy`
```html
<webview src="https://browserleaks.com/webrtc" webrtcippolicy="disable_non_proxied_udp"></webview>
```
This attribute allows you to set the WebRTC IP handling policy which controls what IPs are exposed via WebRTC. See [webContents](web-contents.md#contentssetwebrtciphandlingpolicypolicy) for available policies.
## Methods
The `webview` tag has the following methods:
@ -312,7 +319,7 @@ webview.addEventListener('dom-ready', () => {
* `userAgent` String (optional) - A user agent originating the request.
* `extraHeaders` String (optional) - Extra headers separated by "\n"
* `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] - (optional)
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
Loads the `url` in the webview, the `url` must contain the protocol prefix,
e.g. the `http://` or `file://`.