[tbb-commits] [torbutton/master] Bug 32125: Fix circuit display for bridge without a fingerprint

gk at torproject.org gk at torproject.org
Sat Oct 19 21:01:02 UTC 2019


commit 73df82bd36a812496067c8bef948df5130cb991b
Author: Richard Pospesel <richard at torproject.org>
Date:   Thu Oct 17 14:40:40 2019 -0700

    Bug 32125: Fix circuit display for bridge without a fingerprint
    
    Torbutton expects all bridges to have a fingerprint when creating
    the browser's circuit display. This patch works around the case
    when the user provides a bridge without a fingerprint by assuming
    it is a bridge, but we cannot determine the other displayed info:
    type (obfs4, meek, etc) nor the ip.
    
    In this scenario, the entry node in the circuit display will simply
    say "Bridge".
---
 chrome/content/tor-circuit-display.js | 24 ++++++++++++++++--------
 modules/tor-control-port.js           |  3 +++
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/chrome/content/tor-circuit-display.js b/chrome/content/tor-circuit-display.js
index f75bd781..21bcc57b 100644
--- a/chrome/content/tor-circuit-display.js
+++ b/chrome/content/tor-circuit-display.js
@@ -84,12 +84,19 @@ let nodeDataForID = async function (controller, id) {
       result.ip = bridge.address.split(":")[0];
     } catch (e) { }
   } else {
-    result.type = "default";
-    // Get the IP address for the given node ID.
-     try {
-       let statusMap = await controller.getInfo("ns/id/" + id);
-       result.ip = statusMap.IP;
-     } catch (e) { }
+    // either dealing with a relay, or a bridge whose fingerprint is not saved in torrc
+    try {
+      let statusMap = await controller.getInfo("ns/id/" + id);
+      result.type = "default";
+      result.ip = statusMap.IP;
+    } catch (e) {
+      // getInfo will throw if the given id is not a relay
+      // this probably means we are dealing with a user-provided bridge with no fingerprint
+      result.type = "bridge";
+      // we don't know the ip or type, so leave blank
+      result.ip = "";
+      result.bridgeType = "";
+    }
   }
   if (result.ip) {
     // Get the country code for the node's IP address.
@@ -294,10 +301,11 @@ let updateCircuitDisplay = function () {
         let bridgeType = nodeData[i].bridgeType;
         if (bridgeType === "meek_lite") {
           relayText += ": meek";
-        } else if (bridgeType !== "vanilla") {
+        }
+        else if (bridgeType !== "vanilla" && bridgeType !== "") {
           relayText += ": " + bridgeType;
         }
-      } else {
+      } else if (nodeData[i].type == "default") {
         relayText = localizedCountryNameFromCode(nodeData[i].countryCode);
       }
       let ip = nodeData[i].ip.startsWith("0.") ? "" : nodeData[i].ip;
diff --git a/modules/tor-control-port.js b/modules/tor-control-port.js
index 6e310b52..9f6dbeb6 100644
--- a/modules/tor-control-port.js
+++ b/modules/tor-control-port.js
@@ -459,6 +459,9 @@ info.streamStatusParser = function (text) {
                                   "CircuitID", "Target"]);
 };
 
+
+// TODO: fix this parsing logic to handle bridgeLine correctly
+// fingerprint/id is an optional parameter
 // __info.bridgeParser(bridgeLine)__.
 // Takes a single line from a `getconf bridge` result and returns
 // a map containing the bridge's type, address, and ID.



More information about the tbb-commits mailing list