[tor-commits] [onionoo/master] Don't write flags:[""] but flags:[].

karsten at torproject.org karsten at torproject.org
Tue Nov 8 21:43:35 UTC 2016


commit 3aff99ae6e4bb978b169c0b8bad3fe8b91e06db8
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Sat Apr 25 11:23:43 2015 +0200

    Don't write flags:[""] but flags:[].
    
    Fixes #15798.
---
 src/main/java/org/torproject/onionoo/docs/NodeStatus.java | 10 ++++++++++
 src/main/resources/web/protocol.html                      |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
index 87cacb4..7d595e4 100644
--- a/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/NodeStatus.java
@@ -205,6 +205,16 @@ public class NodeStatus extends Document {
   public void setRelayFlags(SortedSet<String> relayFlags) {
     BitSet newRelayFlags = new BitSet(relayFlagIndexes.size());
     for (String relayFlag : relayFlags) {
+      if (relayFlag.length() == 0) {
+        /* Workaround to handle cases when nodes have no relay flags at
+         * all.  The problem is that we cannot distinguish an empty relay
+         * flags set from a set with a single flag being the empty string.
+         * But given that the empty string is not a valid flag, we can
+         * just skip flags being the empty string and return an empty
+         * set below.  Without this workaround, we'd return a set with one
+         * flag in it: "". */
+        continue;
+      }
       if (!relayFlagIndexes.containsKey(relayFlag)) {
         relayFlagStrings.put(relayFlagIndexes.size(), relayFlag);
         relayFlagIndexes.put(relayFlag, relayFlagIndexes.size());
diff --git a/src/main/resources/web/protocol.html b/src/main/resources/web/protocol.html
index c6cc534..efb31e3 100644
--- a/src/main/resources/web/protocol.html
+++ b/src/main/resources/web/protocol.html
@@ -904,7 +904,7 @@ available about the hiberation status of the relay.
 <p>
 Array of relay flags that the directory authorities
 assigned to this relay.
-Omitted if empty.
+May be omitted if empty.
 </p>
 </li>
 
@@ -1399,7 +1399,7 @@ as running in the last bridge network status.
 <p>
 Array of relay flags that the bridge authority
 assigned to this bridge.
-Omitted if empty.
+May be omitted if empty.
 </p>
 </li>
 



More information about the tor-commits mailing list