Skip to content
Snippets Groups Projects
Commit 685c3bd2 authored by Arlo Breault's avatar Arlo Breault
Browse files

Disable the webext if the bridge is unreachable

parent 19bc6d88
Branches
Tags
No related merge requests found
...@@ -31,6 +31,20 @@ class WebExtUI extends UI { ...@@ -31,6 +31,20 @@ class WebExtUI extends UI {
this.setEnabled(false); this.setEnabled(false);
return; return;
} }
(new Promise((resolve, reject) => {
const ws = WS.makeWebsocket(config.relayAddr);
ws.onopen = () => {
resolve();
ws.close();
};
ws.onerror = () => {
this.missingFeature = 'popupBridgeUnreachable';
this.setEnabled(false);
reject('Could not connect to bridge.');
ws.close();
};
}))
.then(() => {
chrome.storage.local.get("snowflake-enabled", (result) => { chrome.storage.local.get("snowflake-enabled", (result) => {
let enabled = this.enabled; let enabled = this.enabled;
if (result['snowflake-enabled'] !== void 0) { if (result['snowflake-enabled'] !== void 0) {
...@@ -40,6 +54,10 @@ class WebExtUI extends UI { ...@@ -40,6 +54,10 @@ class WebExtUI extends UI {
} }
this.setEnabled(enabled); this.setEnabled(enabled);
}); });
})
.catch((e) => {
log(e);
});
} }
postActive() { postActive() {
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
"popupWebRTCOff": { "popupWebRTCOff": {
"message": "WebRTC feature is not detected." "message": "WebRTC feature is not detected."
}, },
"popupBridgeUnreachable": {
"message": "Could not connect to the bridge."
},
"popupDescOn": { "popupDescOn": {
"message": "Number of users your Snowflake has helped circumvent censorship in the last 24 hours: $1" "message": "Number of users your Snowflake has helped circumvent censorship in the last 24 hours: $1"
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment