[tor-commits] [onionoo/master] Only include dir_address if dirport != 0.

karsten at torproject.org karsten at torproject.org
Mon Jun 18 14:57:49 UTC 2012


commit f55f564a9e5ae8508aef92cbbba575d49a66694c
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Mon Jun 18 16:54:22 2012 +0200

    Only include dir_address if dirport != 0.
    
    Onionoo's protocol specification says "Omitted if the relay does not
    accept directory connections."  Let's do what the spec says.
---
 src/org/torproject/onionoo/DetailDataWriter.java |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/org/torproject/onionoo/DetailDataWriter.java b/src/org/torproject/onionoo/DetailDataWriter.java
index 3d03981..8602093 100644
--- a/src/org/torproject/onionoo/DetailDataWriter.java
+++ b/src/org/torproject/onionoo/DetailDataWriter.java
@@ -447,9 +447,12 @@ public class DetailDataWriter {
           + "\"nickname\":\"" + nickname + "\",\n"
           + "\"fingerprint\":\"" + fingerprint + "\",\n"
           + "\"or_addresses\":[" + orAddressesAndPortsBuilder.toString()
-          + "],\n"
-          + "\"dir_address\":\"" + address + ":" + dirPort + "\",\n"
-          + "\"running\":" + running + ",\n");
+          + "]");
+      if (dirPort != 0) {
+        sb.append(",\n\"dir_address\":\"" + address + ":" + dirPort
+            + "\"");
+      }
+      sb.append(",\n\"running\":" + running + ",\n");
       SortedSet<String> relayFlags = entry.getRelayFlags();
       if (!relayFlags.isEmpty()) {
         sb.append("\"flags\":[");



More information about the tor-commits mailing list