[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [onionoo/release] Stop omitting "n" in summary docs for "Unnamed" relays/bridges.



commit 81c72b0531ecc474bfc92afcb62e4fb78348d2d8
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Thu Feb 8 16:42:25 2018 +0100

    Stop omitting "n" in summary docs for "Unnamed" relays/bridges.
    
    Fixes #24494.
---
 .../org/torproject/onionoo/server/ResponseBuilder.java   | 16 ++++++----------
 .../torproject/onionoo/server/ResourceServletTest.java   |  4 ++--
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
index 80ee223..5f66f62 100644
--- a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
+++ b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
@@ -210,8 +210,7 @@ public class ResponseBuilder {
   }
 
   private String writeRelaySummaryLine(SummaryDocument entry) {
-    String nickname = !entry.getNickname().equals("Unnamed")
-        ? entry.getNickname() : null;
+    String nickname = entry.getNickname();
     String fingerprint = entry.getFingerprint();
     String running = entry.isRunning() ? "true" : "false";
     List<String> addresses = entry.getAddresses();
@@ -221,19 +220,16 @@ public class ResponseBuilder {
       addressesBuilder.append((written++ > 0 ? "," : "") + "\""
           + address.toLowerCase() + "\"");
     }
-    return String.format("{%s\"f\":\"%s\",\"a\":[%s],\"r\":%s}",
-        (nickname == null ? "" : "\"n\":\"" + nickname + "\","),
-        fingerprint, addressesBuilder.toString(), running);
+    return String.format("{\"n\":\"%s\",\"f\":\"%s\",\"a\":[%s],\"r\":%s}",
+        nickname, fingerprint, addressesBuilder.toString(), running);
   }
 
   private String writeBridgeSummaryLine(SummaryDocument entry) {
-    String nickname = !entry.getNickname().equals("Unnamed")
-        ? entry.getNickname() : null;
+    String nickname = entry.getNickname();
     String hashedFingerprint = entry.getFingerprint();
     String running = entry.isRunning() ? "true" : "false";
-    return String.format("{%s\"h\":\"%s\",\"r\":%s}",
-         (nickname == null ? "" : "\"n\":\"" + nickname + "\","),
-         hashedFingerprint, running);
+    return String.format("{\"n\":\"%s\",\"h\":\"%s\",\"r\":%s}",
+        nickname, hashedFingerprint, running);
   }
 
   private String writeDetailsLines(SummaryDocument entry) {
diff --git a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
index 5f07140..c371d71 100644
--- a/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
+++ b/src/test/java/org/torproject/onionoo/server/ResourceServletTest.java
@@ -1419,7 +1419,7 @@ public class ResourceServletTest {
         "/summary?order=" + OrderParameterValues.FIRST_SEEN_ASC + ","
         + OrderParameterValues.CONSENSUS_WEIGHT_ASC, 3,
         new String[] { "TimMayTribute", "Ferrari458", "TorkaZ" }, 3,
-        new String[] { "gummy", null, "ec2bridgercc7f31fe" });
+        new String[] { "gummy", "Unnamed", "ec2bridgercc7f31fe" });
   }
 
   @Test(timeout = 100)
@@ -1428,7 +1428,7 @@ public class ResourceServletTest {
         + OrderParameterValues.FIRST_SEEN_DES + ","
         + OrderParameterValues.CONSENSUS_WEIGHT_ASC, 3,
         new String[] { "TorkaZ", "TimMayTribute", "Ferrari458" }, 3,
-        new String[] { "ec2bridgercc7f31fe", null, "gummy" });
+        new String[] { "ec2bridgercc7f31fe", "Unnamed", "gummy" });
   }
 
   @Test(timeout = 100)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits