[tor-commits] [onionoo/master] Add "as" field as a copy of "as_number".
karsten at torproject.org
karsten at torproject.org
Sun Jul 29 20:13:24 UTC 2018
commit dcd204de903fc844586796c27d25492ba890d27b
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Tue Jul 24 10:43:31 2018 +0200
Add "as" field as a copy of "as_number".
Implements part of #23713.
---
CHANGELOG.md | 2 ++
.../org/torproject/onionoo/docs/DetailsDocument.java | 19 +++++++++++++++++++
.../torproject/onionoo/server/ResponseBuilder.java | 2 ++
.../onionoo/writer/DetailsDocumentWriter.java | 2 +-
4 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00a0c6a..9d0d091 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@
- Support a comma-separated list of fingerprints in the lookup
parameter to allow for URLs that specify a list of relays or
bridges.
+ - Add "as" field as a copy of the "as_number" field in preparation
+ of removing the "as_number" field in the future.
# Changes in version 6.1-1.15.0 - 2018-07-16
diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
index 7820305..650ba5b 100644
--- a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
+++ b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
@@ -201,12 +201,31 @@ public class DetailsDocument extends Document {
return this.longitude;
}
+ private String as;
+
+ @Deprecated
private String asNumber;
+ public void setAs(String as) {
+ this.as = escapeJson(as);
+ }
+
+ @Deprecated
public void setAsNumber(String asNumber) {
this.asNumber = escapeJson(asNumber);
}
+ @Deprecated
+ public void setAsAndAsNumber(String asNumber) {
+ this.as = escapeJson(asNumber);
+ this.asNumber = escapeJson(asNumber);
+ }
+
+ public String getAs() {
+ return unescapeJson(this.as);
+ }
+
+ @Deprecated
public String getAsNumber() {
return unescapeJson(this.asNumber);
}
diff --git a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
index 241b3bd..1a5c925 100644
--- a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
+++ b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
@@ -279,6 +279,8 @@ public class ResponseBuilder {
dd.setLatitude(detailsDocument.getLatitude());
} else if (field.equals("longitude")) {
dd.setLongitude(detailsDocument.getLongitude());
+ } else if (field.equals("as")) {
+ dd.setAs(detailsDocument.getAs());
} else if (field.equals("as_number")) {
dd.setAsNumber(detailsDocument.getAsNumber());
} else if (field.equals("as_name")) {
diff --git a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
index bc5bf8c..0162d0b 100644
--- a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
@@ -97,7 +97,7 @@ public class DetailsDocumentWriter implements DocumentWriter {
detailsDocument.setCountryName(detailsStatus.getCountryName());
detailsDocument.setRegionName(detailsStatus.getRegionName());
detailsDocument.setCityName(detailsStatus.getCityName());
- detailsDocument.setAsNumber(detailsStatus.getAsNumber());
+ detailsDocument.setAsAndAsNumber(detailsStatus.getAsNumber());
detailsDocument.setAsName(detailsStatus.getAsName());
if (detailsStatus.isRunning()) {
detailsDocument.setConsensusWeightFraction(
More information about the tor-commits
mailing list