namecoin-torbutton.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. diff --git a/chrome/content/tor-circuit-display.js b/chrome/content/tor-circuit-display.js
  2. index 5ecbe7d..f771150 100644
  3. --- a/chrome/content/tor-circuit-display.js
  4. +++ b/chrome/content/tor-circuit-display.js
  5. @@ -49,7 +49,11 @@ let credentialsToNodeDataMap = new Map(),
  6. knownCircuitIDs = new Map(),
  7. // A mutable map that records the SOCKS credentials for the
  8. // latest channels for each browser + domain.
  9. - browserToCredentialsMap = new Map();
  10. + browserToCredentialsMap = new Map(),
  11. + // A mutable map from stream id to .bit[.onion] domains
  12. + bitTargets = {},
  13. + // A mutable map from .bit[.onion] domains to .onion domains.
  14. + bitToOnionMap = {};
  15. // __trimQuotes(s)__.
  16. // Removes quotation marks around a quoted string.
  17. @@ -126,6 +130,28 @@ let getCircuitStatusByID = async function (aController, circuitID) {
  18. return null;
  19. };
  20. +// __collectBitTargets(aContoller)__.
  21. +// Watches for STREAM NEW events. When a NEW event occurs, we will see
  22. +// the stream's target domain. If that target is a .bit domain, then
  23. +// we want to be sure to record this so we can later record if it is
  24. +// remapped to a .onion domain.
  25. +let collectBitTargets = function (aController) {
  26. + return aController.watchEvent(
  27. + "STREAM",
  28. + streamEvent => streamEvent.StreamStatus === "NEW",
  29. + async (streamEvent) => {
  30. + logger.eclog(3, "new streamEvent:" + JSON.stringify(streamEvent));
  31. + if (streamEvent && streamEvent.StreamID && streamEvent.Target) {
  32. + let targetDomain = streamEvent.Target.split(":")[0];
  33. + if (targetDomain.endsWith(".bit") ||
  34. + targetDomain.endsWith(".bit.onion")) {
  35. + bitTargets[streamEvent.StreamID] = Services.eTLD.getBaseDomainFromHost(targetDomain);
  36. + logger.eclog(3, "stream on .bit domain: " + targetDomain);
  37. + }
  38. + }
  39. + });
  40. +};
  41. +
  42. // __collectIsolationData(aController, updateUI)__.
  43. // Watches for STREAM SENTCONNECT events. When a SENTCONNECT event occurs, then
  44. // we assume isolation settings (SOCKS username+password) are now fixed for the
  45. @@ -139,6 +165,15 @@ let collectIsolationData = function (aController, updateUI) {
  46. "STREAM",
  47. streamEvent => streamEvent.StreamStatus === "SENTCONNECT",
  48. async (streamEvent) => {
  49. + logger.eclog(3, "sentconnect streamEvent:" + JSON.stringify(streamEvent));
  50. + // Collect any stream target that might be an onion.
  51. + if (streamEvent && streamEvent.StreamID && streamEvent.Target) {
  52. + let targetDomain = streamEvent.Target.split(":")[0];
  53. + if (targetDomain.endsWith(".onion")) {
  54. + bitToOnionMap[bitTargets[streamEvent.StreamID]] = targetDomain;
  55. + logger.eclog(3, "mapped " + bitTargets[streamEvent.StreamID] + " to " + targetDomain);
  56. + }
  57. + }
  58. if (!knownCircuitIDs.get(streamEvent.CircuitID)) {
  59. logger.eclog(3, "streamEvent.CircuitID: " + streamEvent.CircuitID);
  60. knownCircuitIDs.set(streamEvent.CircuitID, true);
  61. @@ -306,12 +341,14 @@ let updateCircuitDisplay = function () {
  62. (i === 0 && nodeData[0].type !== "bridge") ?
  63. ["span", { class: "circuit-guard-info" }, uiString("guard")] : null);
  64. }
  65. - if (domain.endsWith(".onion")) {
  66. + logger.eclog(3, "bit to onion map:" + JSON.stringify(bitToOnionMap) + ", domain: " + domain);
  67. + let mappedOnion = bitToOnionMap[domain];
  68. + if (domain.endsWith(".onion") || mappedOnion) {
  69. for (let i = 0; i < 3; ++i) {
  70. li(uiString("relay"));
  71. }
  72. }
  73. - li(domain);
  74. + li(domain, " ", mappedOnion ? ["span", { class: "circuit-ip-address" }, mappedOnion] : null);
  75. // Hide the note about guards if we are using a bridge.
  76. document.getElementById("circuit-guard-note-container").style.display =
  77. (nodeData[0].type === "bridge") ? "none" : "block";
  78. @@ -418,6 +455,7 @@ let setupDisplay = function (ipcFile, host, port, password, enablePrefName) {
  79. stopCollectingIsolationData = null,
  80. stopCollectingBrowserCredentials = null,
  81. stopEnsuringCorrectPopupDimensions = null,
  82. + stopCollectingBitTargets = null,
  83. stop = function() {
  84. syncDisplayWithSelectedTab(false);
  85. if (myController) {
  86. @@ -430,6 +468,9 @@ let setupDisplay = function (ipcFile, host, port, password, enablePrefName) {
  87. if (stopEnsuringCorrectPopupDimensions) {
  88. stopEnsuringCorrectPopupDimensions();
  89. }
  90. + if (stopCollectingBitTargets) {
  91. + stopCollectingBitTargets();
  92. + }
  93. myController = null;
  94. }
  95. },
  96. @@ -444,6 +485,7 @@ let setupDisplay = function (ipcFile, host, port, password, enablePrefName) {
  97. stop();
  98. });
  99. syncDisplayWithSelectedTab(true);
  100. + stopCollectingBitTargets = collectBitTargets(myController);
  101. stopCollectingIsolationData = collectIsolationData(myController, updateCircuitDisplay);
  102. stopCollectingBrowserCredentials = collectBrowserCredentials();
  103. stopEnsuringCorrectPopupDimensions = ensureCorrectPopupDimensions();