Commit 73df82bd authored by Richard Pospesel's avatar Richard Pospesel Committed by Georg Koppen
Browse files

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".
parent 324e8fd7
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -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.
    // 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) { }
    } 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;
+3 −0
Original line number Diff line number Diff line
@@ -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.