Commit edc796cd authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Add "recommended_version" field to bridge details documents.

Add a "recommended_version" field to bridge details documents based on
whether the directory authorities recommend the bridge's version.

Implements #21827.
parent 919d5ff9
......@@ -7,6 +7,9 @@
server descriptor.
- Extend the "version" parameter to also return bridges with the
given version or version prefix.
- Add a "recommended_version" field to bridge details documents
based on whether the directory authorities recommend the bridge's
version.
# Changes in version 4.3-1.7.1 - 2017-11-17
......
......@@ -89,6 +89,8 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
private SortedMap<String, Integer> lastBandwidthWeights = null;
private Set<String> lastRecommendedServerVersions = null;
private int relayConsensusesProcessed = 0;
private int bridgeStatusesProcessed = 0;
......@@ -248,14 +250,6 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
if (validAfterMillis > this.relaysLastValidAfterMillis) {
this.relaysLastValidAfterMillis = validAfterMillis;
}
Set<String> recommendedVersions = null;
if (consensus.getRecommendedServerVersions() != null) {
recommendedVersions = new HashSet<>();
for (String recommendedVersion :
consensus.getRecommendedServerVersions()) {
recommendedVersions.add("Tor " + recommendedVersion);
}
}
for (Map.Entry<String, NetworkStatusEntry> e :
consensus.getStatusEntries().entrySet()) {
String fingerprint = e.getKey();
......@@ -288,9 +282,6 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
nodeStatus.setConsensusWeight(entry.getBandwidth());
nodeStatus.setDefaultPolicy(entry.getDefaultPolicy());
nodeStatus.setPortList(entry.getPortList());
nodeStatus.setRecommendedVersion((recommendedVersions == null
|| entry.getVersion() == null) ? null :
recommendedVersions.contains(entry.getVersion()));
String version = null;
if (null != entry.getVersion()
&& entry.getVersion().startsWith("Tor ")) {
......@@ -315,6 +306,8 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
this.relayConsensusesProcessed++;
if (this.relaysLastValidAfterMillis == validAfterMillis) {
this.lastBandwidthWeights = consensus.getBandwidthWeights();
this.lastRecommendedServerVersions
= new HashSet<>(consensus.getRecommendedServerVersions());
}
}
......@@ -800,6 +793,15 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
nodeStatus.setVersion(version);
}
/* Compare tor software version (for relays and bridges) with the
* recommended-server-versions line in the last known consensus and set
* the recommended_version field accordingly. */
if (null != this.lastRecommendedServerVersions
&& null != nodeStatus.getVersion()) {
nodeStatus.setRecommendedVersion(this.lastRecommendedServerVersions
.contains(nodeStatus.getVersion()));
}
Map<String, Long> exitAddresses = new HashMap<>();
if (detailsStatus.getExitAddresses() != null) {
for (Map.Entry<String, Long> e :
......
......@@ -189,6 +189,8 @@ public class DetailsDocumentWriter implements DocumentWriter {
detailsDocument.setFirstSeen(detailsStatus.getFirstSeenMillis());
detailsDocument.setRunning(detailsStatus.isRunning());
detailsDocument.setFlags(detailsStatus.getRelayFlags());
detailsDocument.setRecommendedVersion(
detailsStatus.getRecommendedVersion());
detailsDocument.setLastRestarted(detailsStatus.getLastRestarted());
detailsDocument.setAdvertisedBandwidth(
detailsStatus.getAdvertisedBandwidth());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment