electron-webrtc
electron-webrtc copied to clipboard
Using electron-wrtc in an Electron app
To support SOCKS proxy for WebRTC in webtorrent in an Electron app, using a combination of electron-wrtc and window.webContents.session.setProxy({proxyRules:"socks5://1.2.3.4:1080"})
seems to be the simplest way to support this (even if not lightweight).
However, when testing (only on OS X for now), I've encountered some problems:
- if node_modules/electron-prebuilt is in app.asar, then spawning the electron process will fail (I think it's a known bug with spawn and asar).
- If node_modules/electron-prebuilt is in asar.unpacked (or the app is simply not packaged in an asar), codesign will fail:
...../app.asar.unpacked/node_modules/electron-prebuilt/dist/Electron.app/Contents/Frameworks/Electron Framework.framework: bundle format unrecognized, invalid, or unsuitable
- If instantiating
electron-wrtc
withopts.electron = app.getPath('exe')
(the path of the Electron executable from the current app), it throws an error (electron exited with code 0).
Here is the PR about SOCKS proxy support in webtorrent: https://github.com/feross/webtorrent/pull/874
I'm also thinking that using electron-wrtc may be overkill in that case (as we could simply create a new hidden window, set a proxy on it and communicate back and forth for WebRTC).
Note: the reason why we can't just session.setProxy() in the current window is that it would then proxy everything happening there (we may not want to proxy connections to trackers for example, or we may be doing something else not webtorrent-related in that window, etc.).
Any suggestions on how to approach this?
Thanks!
cc @yciabaud