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);
|
this.setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chrome.storage.local.get("snowflake-enabled", (result) => {
|
(new Promise((resolve, reject) => {
|
||||||
let enabled = this.enabled;
|
const ws = WS.makeWebsocket(config.relayAddr);
|
||||||
if (result['snowflake-enabled'] !== void 0) {
|
ws.onopen = () => {
|
||||||
enabled = result['snowflake-enabled'];
|
resolve();
|
||||||
} else {
|
ws.close();
|
||||||
log("Toggle state not yet saved");
|
};
|
||||||
}
|
ws.onerror = () => {
|
||||||
this.setEnabled(enabled);
|
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": {
|
"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"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue