[tor-commits] [onionoo/master] Fix contact parameter.
karsten at torproject.org
karsten at torproject.org
Tue May 13 13:57:37 UTC 2014
commit 0dc7436cbdefe03ca4ca4aec4aea4e52038163a6
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Tue May 13 09:25:42 2014 +0200
Fix contact parameter.
We support searching for relays by contact. In order to learn contacts,
we need to parse contact lines from server descriptors. However, our
earlier approach, which was introduced in 51d883b, only stored the contact
whenever the relay published a new server descriptor. In all other
executions we would reset that contact line, assuming that the relay did
not provide a contact line.
The new approach is to rely on the details status file that we're writing
for details documents and use the contact information contained there.
This also works better than the earlier approach, because the details
status file also contains the descriptor publication time which allows us
to always memorize the latest contact information of a relay.
Fixes #11822.
---
.../onionoo/NodeDetailsStatusUpdater.java | 21 ++++++++++----------
src/org/torproject/onionoo/NodeStatus.java | 1 -
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/org/torproject/onionoo/NodeDetailsStatusUpdater.java b/src/org/torproject/onionoo/NodeDetailsStatusUpdater.java
index 030a8ec..afc72bb 100644
--- a/src/org/torproject/onionoo/NodeDetailsStatusUpdater.java
+++ b/src/org/torproject/onionoo/NodeDetailsStatusUpdater.java
@@ -36,8 +36,6 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
private SortedMap<String, NodeStatus> knownNodes =
new TreeMap<String, NodeStatus>();
- private Map<String, String> contacts = new HashMap<String, String>();
-
private SortedMap<String, NodeStatus> relays;
private SortedMap<String, NodeStatus> bridges;
@@ -214,17 +212,21 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
for (Map.Entry<String, NodeStatus> e : this.knownNodes.entrySet()) {
String fingerprint = e.getKey();
NodeStatus node = e.getValue();
- if (node.isRelay() && node.getRelayFlags().contains("Running") &&
- node.getLastSeenMillis() == this.relaysLastValidAfterMillis) {
- node.setRunning(true);
+ if (node.isRelay()) {
+ if (node.getRelayFlags().contains("Running") &&
+ node.getLastSeenMillis() == this.relaysLastValidAfterMillis) {
+ node.setRunning(true);
+ }
+ DetailsStatus detailsStatus = this.documentStore.retrieve(
+ DetailsStatus.class, true, fingerprint);
+ if (detailsStatus != null) {
+ node.setContact(detailsStatus.getContact());
+ }
}
if (!node.isRelay() && node.getRelayFlags().contains("Running") &&
node.getLastSeenMillis() == this.bridgesLastPublishedMillis) {
node.setRunning(true);
}
- if (this.contacts.containsKey(fingerprint)) {
- node.setContact(this.contacts.get(fingerprint));
- }
}
}
@@ -334,9 +336,6 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
detailsStatus.setHibernating(true);
}
this.documentStore.store(detailsStatus, fingerprint);
- if (descriptor.getContact() != null) {
- this.contacts.put(fingerprint, descriptor.getContact());
- }
}
private void processBridgeServerDescriptor(
diff --git a/src/org/torproject/onionoo/NodeStatus.java b/src/org/torproject/onionoo/NodeStatus.java
index dbbc9fa..781d6db 100644
--- a/src/org/torproject/onionoo/NodeStatus.java
+++ b/src/org/torproject/onionoo/NodeStatus.java
@@ -492,7 +492,6 @@ public class NodeStatus extends Document {
this.defaultPolicy = newNodeStatus.defaultPolicy;
this.portList = newNodeStatus.portList;
this.aSNumber = newNodeStatus.aSNumber;
- this.contact = newNodeStatus.contact;
this.recommendedVersion = newNodeStatus.recommendedVersion;
}
if (this.isRelay && newNodeStatus.isRelay) {
More information about the tor-commits
mailing list