commit d3a750533fbc28e9e80cce5311bbf79a3f58db21 Author: Alex Catarineu acat@torproject.org Date: Wed Apr 8 21:33:14 2020 +0200
Bug 33845: Rebase namecoin torbutton patch --- projects/firefox/namecoin-torbutton.patch | 75 ++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 17 deletions(-)
diff --git a/projects/firefox/namecoin-torbutton.patch b/projects/firefox/namecoin-torbutton.patch index 11cf7a1..5649ee6 100644 --- a/projects/firefox/namecoin-torbutton.patch +++ b/projects/firefox/namecoin-torbutton.patch @@ -1,8 +1,8 @@ diff --git a/chrome/content/tor-circuit-display.js b/chrome/content/tor-circuit-display.js -index 5ecbe7d..f771150 100644 +index 119f6fca..477b0302 100644 --- a/chrome/content/tor-circuit-display.js +++ b/chrome/content/tor-circuit-display.js -@@ -49,7 +49,11 @@ let credentialsToNodeDataMap = new Map(), +@@ -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. @@ -15,7 +15,7 @@ index 5ecbe7d..f771150 100644
// __trimQuotes(s)__. // Removes quotation marks around a quoted string. -@@ -126,6 +130,28 @@ let getCircuitStatusByID = async function (aController, circuitID) { +@@ -132,6 +136,28 @@ let getCircuitStatusByID = async function (aController, circuitID) { return null; };
@@ -44,7 +44,7 @@ index 5ecbe7d..f771150 100644 // __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 -@@ -139,6 +165,15 @@ let collectIsolationData = function (aController, updateUI) { +@@ -145,6 +171,15 @@ let collectIsolationData = function (aController, updateUI) { "STREAM", streamEvent => streamEvent.StreamStatus === "SENTCONNECT", async (streamEvent) => { @@ -52,7 +52,7 @@ index 5ecbe7d..f771150 100644 + // 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")) { ++ if (targetDomain.endsWith(".onion")) { + bitToOnionMap[bitTargets[streamEvent.StreamID]] = targetDomain; + logger.eclog(3, "mapped " + bitTargets[streamEvent.StreamID] + " to " + targetDomain); + } @@ -60,10 +60,10 @@ index 5ecbe7d..f771150 100644 if (!knownCircuitIDs.get(streamEvent.CircuitID)) { logger.eclog(3, "streamEvent.CircuitID: " + streamEvent.CircuitID); knownCircuitIDs.set(streamEvent.CircuitID, true); -@@ -306,12 +341,14 @@ let updateCircuitDisplay = function () { - (i === 0 && nodeData[0].type !== "bridge") ? - ["span", { class: "circuit-guard-info" }, uiString("guard")] : null); +@@ -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]; @@ -71,13 +71,54 @@ index 5ecbe7d..f771150 100644 for (let i = 0; i < 3; ++i) { li(uiString("relay")); } +@@ -325,24 +362,28 @@ let updateCircuitDisplay = function () { + domainParts.push(domain); } -- li(domain); -+ li(domain, " ", mappedOnion ? ["span", { class: "circuit-ip-address" }, mappedOnion] : null); + +- // 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 = - (nodeData[0].type === "bridge") ? "none" : "block"; -@@ -418,6 +455,7 @@ let setupDisplay = function (ipcFile, host, port, password, enablePrefName) { +@@ -450,6 +491,7 @@ let setupDisplay = function (enablePrefName) { stopCollectingIsolationData = null, stopCollectingBrowserCredentials = null, stopEnsuringCorrectPopupDimensions = null, @@ -85,17 +126,17 @@ index 5ecbe7d..f771150 100644 stop = function() { syncDisplayWithSelectedTab(false); if (myController) { -@@ -430,6 +468,9 @@ let setupDisplay = function (ipcFile, host, port, password, enablePrefName) { +@@ -462,6 +504,9 @@ let setupDisplay = function (enablePrefName) { if (stopEnsuringCorrectPopupDimensions) { stopEnsuringCorrectPopupDimensions(); } -+ if (stopCollectingBitTargets) { -+ stopCollectingBitTargets(); -+ } ++ if (stopCollectingBitTargets) { ++ stopCollectingBitTargets(); ++ } myController = null; } }, -@@ -444,6 +485,7 @@ let setupDisplay = function (ipcFile, host, port, password, enablePrefName) { +@@ -475,6 +520,7 @@ let setupDisplay = function (enablePrefName) { stop(); }); syncDisplayWithSelectedTab(true);