mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20: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.
|
Entry point.
|
||||||
###
|
###
|
||||||
|
|
||||||
|
if (not TESTING? or not TESTING) and not Util.featureDetect()
|
||||||
|
console.log 'webrtc feature not detected. shutting down'
|
||||||
|
return
|
||||||
|
|
||||||
snowflake = null
|
snowflake = null
|
||||||
|
|
||||||
query = Query.parse(location)
|
query = Query.parse(location)
|
||||||
|
|
|
@ -17,6 +17,12 @@ log = (msg) ->
|
||||||
|
|
||||||
dbg = (msg) -> log msg if debug
|
dbg = (msg) -> log msg if debug
|
||||||
|
|
||||||
|
if not Util.featureDetect()
|
||||||
|
chrome.runtime.onConnect.addListener (port) ->
|
||||||
|
port.postMessage
|
||||||
|
missingFeature: true
|
||||||
|
return
|
||||||
|
|
||||||
init = () ->
|
init = () ->
|
||||||
config = new Config
|
config = new Config
|
||||||
ui = new WebExtUI()
|
ui = new WebExtUI()
|
||||||
|
|
|
@ -31,9 +31,5 @@ else
|
||||||
SessionDescription = window.RTCSessionDescription ||
|
SessionDescription = window.RTCSessionDescription ||
|
||||||
window.mozRTCSessionDescription
|
window.mozRTCSessionDescription
|
||||||
|
|
||||||
if typeof PeerConnection isnt 'function'
|
|
||||||
console.log 'webrtc feature not detected. shutting down'
|
|
||||||
return
|
|
||||||
|
|
||||||
WebSocket = window.WebSocket
|
WebSocket = window.WebSocket
|
||||||
XMLHttpRequest = window.XMLHttpRequest
|
XMLHttpRequest = window.XMLHttpRequest
|
||||||
|
|
|
@ -34,6 +34,8 @@ class Util
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@featureDetect = () ->
|
||||||
|
return typeof PeerConnection is 'function'
|
||||||
|
|
||||||
class Query
|
class Query
|
||||||
###
|
###
|
||||||
|
|
|
@ -3,11 +3,19 @@ const port = chrome.runtime.connect({
|
||||||
});
|
});
|
||||||
|
|
||||||
port.onMessage.addListener((m) => {
|
port.onMessage.addListener((m) => {
|
||||||
const active = m.active;
|
|
||||||
const div = document.getElementById('active');
|
const div = document.getElementById('active');
|
||||||
const img = div.querySelector('img');
|
|
||||||
const enabled = m.enabled
|
|
||||||
const ps = div.querySelectorAll('p');
|
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 clients = active ? 1 : 0;
|
||||||
const enabledText = document.getElementById('toggle');
|
const enabledText = document.getElementById('toggle');
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue