123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- diff --git a/chrome/content/tor-circuit-display.js b/chrome/content/tor-circuit-display.js
- index 119f6fca..477b0302 100644
- --- a/chrome/content/tor-circuit-display.js
- +++ b/chrome/content/tor-circuit-display.js
- @@ -48,7 +48,11 @@ let credentialsToNodeDataMap = new Map(),
- knownCircuitIDs = new Map(),
- // A mutable map that records the SOCKS credentials for the
- // latest channels for each browser + domain.
- - browserToCredentialsMap = new Map();
- + browserToCredentialsMap = new Map(),
- + // A mutable map from stream id to .bit[.onion] domains
- + bitTargets = {},
- + // A mutable map from .bit[.onion] domains to .onion domains.
- + bitToOnionMap = {};
-
- // __trimQuotes(s)__.
- // Removes quotation marks around a quoted string.
- @@ -132,6 +136,28 @@ let getCircuitStatusByID = async function (aController, circuitID) {
- return null;
- };
-
- +// __collectBitTargets(aContoller)__.
- +// Watches for STREAM NEW events. When a NEW event occurs, we will see
- +// the stream's target domain. If that target is a .bit domain, then
- +// we want to be sure to record this so we can later record if it is
- +// remapped to a .onion domain.
- +let collectBitTargets = function (aController) {
- + return aController.watchEvent(
- + "STREAM",
- + streamEvent => streamEvent.StreamStatus === "NEW",
- + async (streamEvent) => {
- + logger.eclog(3, "new streamEvent:" + JSON.stringify(streamEvent));
- + if (streamEvent && streamEvent.StreamID && streamEvent.Target) {
- + let targetDomain = streamEvent.Target.split(":")[0];
- + if (targetDomain.endsWith(".bit") ||
- + targetDomain.endsWith(".bit.onion")) {
- + bitTargets[streamEvent.StreamID] = Services.eTLD.getBaseDomainFromHost(targetDomain);
- + logger.eclog(3, "stream on .bit domain: " + targetDomain);
- + }
- + }
- + });
- +};
- +
- // __collectIsolationData(aController, updateUI)__.
- // Watches for STREAM SENTCONNECT events. When a SENTCONNECT event occurs, then
- // we assume isolation settings (SOCKS username+password) are now fixed for the
- @@ -145,6 +171,15 @@ let collectIsolationData = function (aController, updateUI) {
- "STREAM",
- streamEvent => streamEvent.StreamStatus === "SENTCONNECT",
- async (streamEvent) => {
- + logger.eclog(3, "sentconnect streamEvent:" + JSON.stringify(streamEvent));
- + // Collect any stream target that might be an onion.
- + if (streamEvent && streamEvent.StreamID && streamEvent.Target) {
- + let targetDomain = streamEvent.Target.split(":")[0];
- + if (targetDomain.endsWith(".onion")) {
- + bitToOnionMap[bitTargets[streamEvent.StreamID]] = targetDomain;
- + logger.eclog(3, "mapped " + bitTargets[streamEvent.StreamID] + " to " + targetDomain);
- + }
- + }
- if (!knownCircuitIDs.get(streamEvent.CircuitID)) {
- logger.eclog(3, "streamEvent.CircuitID: " + streamEvent.CircuitID);
- knownCircuitIDs.set(streamEvent.CircuitID, true);
- @@ -312,7 +347,9 @@ let updateCircuitDisplay = function () {
- }
-
- let domainParts = [];
- - if (domain.endsWith(".onion")) {
- + logger.eclog(3, "bit to onion map:" + JSON.stringify(bitToOnionMap) + ", domain: " + domain);
- + let mappedOnion = bitToOnionMap[domain];
- + if (domain.endsWith(".onion") || mappedOnion) {
- for (let i = 0; i < 3; ++i) {
- li(uiString("relay"));
- }
- @@ -325,24 +362,28 @@ let updateCircuitDisplay = function () {
- domainParts.push(domain);
- }
-
- - // We use a XUL html:span element so that the tooltiptext is displayed.
- - li([
- - "html:span",
- - {
- - class: "circuit-onion",
- - onclick: `
- - this.classList.add("circuit-onion-copied");
- - Cc[
- - "@mozilla.org/widget/clipboardhelper;1"
- - ].getService(Ci.nsIClipboardHelper).copyString(this.getAttribute("data-onion"))
- - `,
- - "data-onion": domain,
- - "data-text-clicktocopy": torbutton_get_property_string("torbutton.circuit_display.click_to_copy"),
- - "data-text-copied": torbutton_get_property_string("torbutton.circuit_display.copied"),
- - tooltiptext: domain,
- - },
- - ...domainParts,
- - ]);
- + if (mappedOnion) {
- + li(domain, " ", ["span", { class: "circuit-ip-address" }, mappedOnion]);
- + } else {
- + // We use a XUL html:span element so that the tooltiptext is displayed.
- + li([
- + "html:span",
- + {
- + class: "circuit-onion",
- + onclick: `
- + this.classList.add("circuit-onion-copied");
- + Cc[
- + "@mozilla.org/widget/clipboardhelper;1"
- + ].getService(Ci.nsIClipboardHelper).copyString(this.getAttribute("data-onion"))
- + `,
- + "data-onion": domain,
- + "data-text-clicktocopy": torbutton_get_property_string("torbutton.circuit_display.click_to_copy"),
- + "data-text-copied": torbutton_get_property_string("torbutton.circuit_display.copied"),
- + tooltiptext: domain,
- + },
- + ...domainParts,
- + ]);
- + }
-
- // Hide the note about guards if we are using a bridge.
- document.getElementById("circuit-guard-note-container").style.display =
- @@ -450,6 +491,7 @@ let setupDisplay = function (enablePrefName) {
- stopCollectingIsolationData = null,
- stopCollectingBrowserCredentials = null,
- stopEnsuringCorrectPopupDimensions = null,
- + stopCollectingBitTargets = null,
- stop = function() {
- syncDisplayWithSelectedTab(false);
- if (myController) {
- @@ -462,6 +504,9 @@ let setupDisplay = function (enablePrefName) {
- if (stopEnsuringCorrectPopupDimensions) {
- stopEnsuringCorrectPopupDimensions();
- }
- + if (stopCollectingBitTargets) {
- + stopCollectingBitTargets();
- + }
- myController = null;
- }
- },
- @@ -475,6 +520,7 @@ let setupDisplay = function (enablePrefName) {
- stop();
- });
- syncDisplayWithSelectedTab(true);
- + stopCollectingBitTargets = collectBitTargets(myController);
- stopCollectingIsolationData = collectIsolationData(myController, updateCircuitDisplay);
- stopCollectingBrowserCredentials = collectBrowserCredentials();
- stopEnsuringCorrectPopupDimensions = ensureCorrectPopupDimensions();
|