mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Add bridge probe to badge
This commit is contained in:
parent
d4aa9ad2b3
commit
8d81270a9f
1 changed files with 25 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* global Util, Params, Config, UI, Broker, Snowflake, Popup, Parse, availableLangs */
|
/* global Util, Params, Config, UI, Broker, Snowflake, Popup, Parse, availableLangs, WS */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
UI
|
UI
|
||||||
|
@ -125,27 +125,39 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific
|
||||||
|
|
||||||
update = function() {
|
update = function() {
|
||||||
const cookies = Parse.cookie(document.cookie);
|
const cookies = Parse.cookie(document.cookie);
|
||||||
if (cookies[COOKIE_NAME] === '1') {
|
if (cookies[COOKIE_NAME] !== '1') {
|
||||||
|
ui.turnOff();
|
||||||
|
snowflake.disable();
|
||||||
|
log('Currently not active.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Util.hasWebRTC()) {
|
||||||
|
ui.missingFeature(messages.getMessage('popupWebRTCOff'));
|
||||||
|
snowflake.disable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WS.probeWebsocket(config.relayAddr)
|
||||||
|
.then(
|
||||||
|
() => {
|
||||||
ui.turnOn();
|
ui.turnOn();
|
||||||
dbg('Contacting Broker at ' + broker.url);
|
dbg('Contacting Broker at ' + broker.url);
|
||||||
log('Starting snowflake');
|
log('Starting snowflake');
|
||||||
snowflake.setRelayAddr(config.relayAddr);
|
snowflake.setRelayAddr(config.relayAddr);
|
||||||
snowflake.beginWebRTC();
|
snowflake.beginWebRTC();
|
||||||
} else {
|
},
|
||||||
ui.turnOff();
|
() => {
|
||||||
|
ui.missingFeature(messages.getMessage('popupBridgeUnreachable'));
|
||||||
snowflake.disable();
|
snowflake.disable();
|
||||||
log('Currently not active.');
|
log('Could not connect to bridge.');
|
||||||
}
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
init = function() {
|
init = function() {
|
||||||
ui = new BadgeUI();
|
ui = new BadgeUI();
|
||||||
|
|
||||||
if (!Util.hasWebRTC()) {
|
|
||||||
ui.missingFeature(messages.getMessage('popupWebRTCOff'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Util.hasCookies()) {
|
if (!Util.hasCookies()) {
|
||||||
ui.missingFeature(messages.getMessage('badgeCookiesOff'));
|
ui.missingFeature(messages.getMessage('badgeCookiesOff'));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue