[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Add bridge probe to badge



commit 8d81270a9f217a5d0867a5db9237a02c8498eef9
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date:   Thu Sep 26 12:31:09 2019 -0400

    Add bridge probe to badge
---
 proxy/init-badge.js | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/proxy/init-badge.js b/proxy/init-badge.js
index ed6dee9..d8d9113 100644
--- a/proxy/init-badge.js
+++ b/proxy/init-badge.js
@@ -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
@@ -125,27 +125,39 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific
 
   update = function() {
     const cookies = Parse.cookie(document.cookie);
-    if (cookies[COOKIE_NAME] === '1') {
-      ui.turnOn();
-      dbg('Contacting Broker at ' + broker.url);
-      log('Starting snowflake');
-      snowflake.setRelayAddr(config.relayAddr);
-      snowflake.beginWebRTC();
-    } else {
+    if (cookies[COOKIE_NAME] !== '1') {
       ui.turnOff();
       snowflake.disable();
       log('Currently not active.');
+      return;
     }
-  };
-
-  init = function() {
-    ui = new BadgeUI();
 
     if (!Util.hasWebRTC()) {
       ui.missingFeature(messages.getMessage('popupWebRTCOff'));
+      snowflake.disable();
       return;
     }
 
+    WS.probeWebsocket(config.relayAddr)
+    .then(
+      () => {
+        ui.turnOn();
+        dbg('Contacting Broker at ' + broker.url);
+        log('Starting snowflake');
+        snowflake.setRelayAddr(config.relayAddr);
+        snowflake.beginWebRTC();
+      },
+      () => {
+        ui.missingFeature(messages.getMessage('popupBridgeUnreachable'));
+        snowflake.disable();
+        log('Could not connect to bridge.');
+      }
+    );
+  };
+
+  init = function() {
+    ui = new BadgeUI();
+
     if (!Util.hasCookies()) {
       ui.missingFeature(messages.getMessage('badgeCookiesOff'));
       return;

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits