[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [torbutton/master] Various minor fixes for tor-control-port.js and tor-circuit-display.js
commit 5aca83a36d00b3624500ae2e07d559a915d333f1
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date: Tue Nov 4 11:17:45 2014 -0800
Various minor fixes for tor-control-port.js and tor-circuit-display.js
---
src/chrome/content/tor-circuit-display.js | 51 ++++++++++++++++-------------
src/modules/tor-control-port.js | 4 +--
2 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/src/chrome/content/tor-circuit-display.js b/src/chrome/content/tor-circuit-display.js
index 3a1fed8..c8d255e 100644
--- a/src/chrome/content/tor-circuit-display.js
+++ b/src/chrome/content/tor-circuit-display.js
@@ -55,7 +55,7 @@ let domainToNodeDataMap = {};
// __trimQuotes(s)__.
// Removes quotation marks around a quoted string.
-let trimQuotes = s => s.match(/^\"(.*)\"$/)[1];
+let trimQuotes = s => s ? s.match(/^\"(.*)\"$/)[1] : undefined;
// nodeDataForID(controller, id, onResult)__.
// Requests the IP, country code, and name of a node with given ID.
@@ -94,7 +94,7 @@ let nodeLines = function (nodeData) {
for (let {ip, country} of nodeData) {
result.push(localizedCountryNameFromCode(country) + " (" + ip + ")");
}
- result.push("Internet");
+ result[4] = ("Internet");
return result;
};
@@ -102,30 +102,35 @@ let nodeLines = function (nodeData) {
// Updates the Tor circuit display SVG, showing the current domain
// and the relay nodes for that domain.
let updateCircuitDisplay = function () {
- let URI = gBrowser.selectedBrowser.currentURI,
- domain = null,
- nodeData = null;
- // Try to get a domain for this URI. Otherwise it remains null.
- try {
- domain = URI.host;
- } catch (e) { }
- if (domain) {
- // Check if we have anything to show for this domain.
- nodeData = domainToNodeDataMap[domain];
- if (nodeData) {
- // Update the displayed domain.
- document.querySelector("svg#tor-circuit text#domain").innerHTML = "(" + domain + "):";
- // Update the displayed information for the relay nodes.
- let diagramNodes = document.querySelectorAll("svg#tor-circuit text.node-text"),
- lines = nodeLines(nodeData);
- for (let i = 0; i < diagramNodes.length; ++i) {
- diagramNodes[i].innerHTML = lines[i];
+ let selectedBrowser = gBrowser.selectedBrowser;
+ if (selectedBrowser) {
+ let URI = selectedBrowser.currentURI,
+ domain = null,
+ nodeData = null;
+ // Try to get a domain for this URI. Otherwise it remains null.
+ try {
+ domain = URI.host;
+ } catch (e) { }
+ if (domain) {
+ // Check if we have anything to show for this domain.
+ nodeData = domainToNodeDataMap[domain];
+ if (nodeData) {
+ // Update the displayed domain.
+ document.querySelector("svg#tor-circuit text#domain").innerHTML = "(" + domain + "):";
+ // Update the displayed information for the relay nodes.
+ let diagramNodes = document.querySelectorAll("svg#tor-circuit text.node-text"),
+ //diagramCircles = document.querySelectorAll("svg#tor-circuit .node-circule"),
+ lines = nodeLines(nodeData);
+ for (let i = 0; i < diagramNodes.length; ++i) {
+ let line = lines[i];
+ diagramNodes[i].innerHTML = line ? line : "";
+ }
}
}
+ // Only show the Tor circuit if we have a domain and node data.
+ document.querySelector("svg#tor-circuit").style.display = (domain && nodeData) ?
+ 'block' : 'none';
}
- // Only show the Tor circuit if we have a domain and node data.
- document.querySelector("svg#tor-circuit").style.display = (domain && nodeData) ?
- 'block' : 'none';
};
// __collectBuiltCircuitData(aController)__.
diff --git a/src/modules/tor-control-port.js b/src/modules/tor-control-port.js
index 855b34b..c461aa6 100644
--- a/src/modules/tor-control-port.js
+++ b/src/modules/tor-control-port.js
@@ -107,7 +107,7 @@ io.asyncSocket = function (host, port, onInputData, onError) {
let totalString = pendingWrites.join("");
try {
outputStream.write(totalString, totalString.length);
- log("wrote: " + aString + "\n");
+ log("controlPort << " + aString + "\n");
} catch (err) {
onError(err);
}
@@ -164,7 +164,7 @@ io.onLineFromOnMessage = function (onMessage) {
pendingLines = [];
// Pass multiline message to onMessage.
onMessage(message);
- //log(message);
+ log("controlPort >> " + message);
}
};
};
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits