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

Add "version" field to details documents.

Add a "version" field to relay details documents with the Tor software
version listed in the consensus and similarly to bridge details
documents with the Tor software version found in the server
descriptor.

Implements #22488.
parent e118782c
# Changes in version 4.4-1.8.0 - 2017-??-??
* Medium changes
- Add a "version" field to relay details documents with the Tor
software version listed in the consensus and similarly to bridge
details documents with the Tor software version found in the
server descriptor.
# Changes in version 4.3-1.7.1 - 2017-11-17
* Minor changes
......
......@@ -346,6 +346,16 @@ public class DetailsDocument extends Document {
return unescapeJson(this.platform);
}
private String version;
public void setVersion(String version) {
this.version = version;
}
public String getVersion() {
return this.version;
}
private SortedSet<String> alleged_family;
public void setAllegedFamily(SortedSet<String> allegedFamily) {
......
......@@ -540,5 +540,15 @@ public class DetailsStatus extends Document {
public List<String> getAdvertisedOrAddresses() {
return this.advertised_or_addresses;
}
private String version;
public void setVersion(String version) {
this.version = version;
}
public String getVersion() {
return this.version;
}
}
......@@ -324,8 +324,7 @@ public class NodeStatus extends Document {
private String version;
public void setVersion(String version) {
this.version = null == version ? null
: version.substring(version.lastIndexOf(" ") + 1);
this.version = version;
}
public String getVersion() {
......
......@@ -342,6 +342,8 @@ public class ResponseBuilder {
} else if (field.equals("unreachable_or_addresses")) {
dd.setUnreachableOrAddresses(
detailsDocument.getUnreachableOrAddresses());
} else if (field.equals("version")) {
dd.setVersion(detailsDocument.getVersion());
}
}
/* Don't escape HTML characters, like < and >, contained in
......
......@@ -291,7 +291,12 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
nodeStatus.setRecommendedVersion((recommendedVersions == null
|| entry.getVersion() == null) ? null :
recommendedVersions.contains(entry.getVersion()));
nodeStatus.setVersion(entry.getVersion());
String version = null;
if (null != entry.getVersion()
&& entry.getVersion().startsWith("Tor ")) {
version = entry.getVersion().split(" ")[1];
}
nodeStatus.setVersion(version);
}
if (entry.getUnmeasured()) {
if (!this.lastSeenUnmeasured.containsKey(fingerprint)
......@@ -784,6 +789,17 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
nodeStatus.setContact(detailsStatus.getContact());
/* Extract tor software version for bridges from their "platform" line.
* (We already know this for relays from "v" lines in the consensus.) */
if (!nodeStatus.isRelay()) {
String version = null;
if (null != detailsStatus.getPlatform()
&& detailsStatus.getPlatform().startsWith("Tor ")) {
version = detailsStatus.getPlatform().split(" ")[1];
}
nodeStatus.setVersion(version);
}
Map<String, Long> exitAddresses = new HashMap<>();
if (detailsStatus.getExitAddresses() != null) {
for (Map.Entry<String, Long> e :
......@@ -890,6 +906,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
nodeStatus.getRecommendedVersion());
detailsStatus.setLastChangedOrAddressOrPort(
nodeStatus.getLastChangedOrAddressOrPort());
detailsStatus.setVersion(nodeStatus.getVersion());
this.documentStore.store(detailsStatus, fingerprint);
this.documentStore.store(nodeStatus, fingerprint);
......
......@@ -165,6 +165,7 @@ public class DetailsDocumentWriter implements DocumentWriter {
if (!unreachableOrAddresses.isEmpty()) {
detailsDocument.setUnreachableOrAddresses(unreachableOrAddresses);
}
detailsDocument.setVersion(detailsStatus.getVersion());
this.documentStore.store(detailsDocument, fingerprint);
}
......@@ -193,6 +194,7 @@ public class DetailsDocumentWriter implements DocumentWriter {
detailsStatus.getAdvertisedBandwidth());
detailsDocument.setPlatform(detailsStatus.getPlatform());
detailsDocument.setTransports(detailsStatus.getTransports());
detailsDocument.setVersion(detailsStatus.getVersion());
this.documentStore.store(detailsDocument, fingerprint);
}
......
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