mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Disable the webext if the bridge is unreachable
This commit is contained in:
parent
19bc6d8858
commit
685c3bd262
2 changed files with 29 additions and 8 deletions
|
@ -31,14 +31,32 @@ class WebExtUI extends UI {
|
|||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
chrome.storage.local.get("snowflake-enabled", (result) => {
|
||||
let enabled = this.enabled;
|
||||
if (result['snowflake-enabled'] !== void 0) {
|
||||
enabled = result['snowflake-enabled'];
|
||||
} else {
|
||||
log("Toggle state not yet saved");
|
||||
}
|
||||
this.setEnabled(enabled);
|
||||
(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) => {
|
||||
let enabled = this.enabled;
|
||||
if (result['snowflake-enabled'] !== void 0) {
|
||||
enabled = result['snowflake-enabled'];
|
||||
} else {
|
||||
log("Toggle state not yet saved");
|
||||
}
|
||||
this.setEnabled(enabled);
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
log(e);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
"popupWebRTCOff": {
|
||||
"message": "WebRTC feature is not detected."
|
||||
},
|
||||
"popupBridgeUnreachable": {
|
||||
"message": "Could not connect to the bridge."
|
||||
},
|
||||
"popupDescOn": {
|
||||
"message": "Number of users your Snowflake has helped circumvent censorship in the last 24 hours: $1"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue