mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Warn when WebRTC isn't detected in the webext
Trac 31067
This commit is contained in:
parent
4494dbd3ca
commit
095f4a0510
5 changed files with 23 additions and 7 deletions
|
@ -2,6 +2,10 @@
|
|||
Entry point.
|
||||
###
|
||||
|
||||
if (not TESTING? or not TESTING) and not Util.featureDetect()
|
||||
console.log 'webrtc feature not detected. shutting down'
|
||||
return
|
||||
|
||||
snowflake = null
|
||||
|
||||
query = Query.parse(location)
|
||||
|
|
|
@ -17,6 +17,12 @@ log = (msg) ->
|
|||
|
||||
dbg = (msg) -> log msg if debug
|
||||
|
||||
if not Util.featureDetect()
|
||||
chrome.runtime.onConnect.addListener (port) ->
|
||||
port.postMessage
|
||||
missingFeature: true
|
||||
return
|
||||
|
||||
init = () ->
|
||||
config = new Config
|
||||
ui = new WebExtUI()
|
||||
|
|
|
@ -31,9 +31,5 @@ else
|
|||
SessionDescription = window.RTCSessionDescription ||
|
||||
window.mozRTCSessionDescription
|
||||
|
||||
if typeof PeerConnection isnt 'function'
|
||||
console.log 'webrtc feature not detected. shutting down'
|
||||
return
|
||||
|
||||
WebSocket = window.WebSocket
|
||||
XMLHttpRequest = window.XMLHttpRequest
|
||||
|
|
|
@ -34,6 +34,8 @@ class Util
|
|||
return true
|
||||
return false
|
||||
|
||||
@featureDetect = () ->
|
||||
return typeof PeerConnection is 'function'
|
||||
|
||||
class Query
|
||||
###
|
||||
|
|
|
@ -3,11 +3,19 @@ const port = chrome.runtime.connect({
|
|||
});
|
||||
|
||||
port.onMessage.addListener((m) => {
|
||||
const active = m.active;
|
||||
const div = document.getElementById('active');
|
||||
const img = div.querySelector('img');
|
||||
const enabled = m.enabled
|
||||
const ps = div.querySelectorAll('p');
|
||||
if (m.missingFeature) {
|
||||
div.querySelector('img').src = "icons/status-off.png";
|
||||
ps[0].innerText = "Snowflake is off";
|
||||
ps[1].innerText = "WebRTC feature is not detected.";
|
||||
ps[1].style.color = 'firebrick';
|
||||
document.querySelector('.toggle').style.display = 'none';
|
||||
return;
|
||||
}
|
||||
const active = m.active;
|
||||
const img = div.querySelector('img');
|
||||
const enabled = m.enabled;
|
||||
const clients = active ? 1 : 0;
|
||||
const enabledText = document.getElementById('toggle');
|
||||
if (enabled) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue