commit f644623da84c5a4f851924a6b12916e6e0bbe4ea Author: Karsten Loesing karsten.loesing@gmx.net Date: Sun Sep 9 10:43:55 2012 -0400
Handle bridges without any flags. --- src/org/torproject/onionoo/CurrentNodes.java | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/org/torproject/onionoo/CurrentNodes.java b/src/org/torproject/onionoo/CurrentNodes.java index a34cbb7..252abbe 100644 --- a/src/org/torproject/onionoo/CurrentNodes.java +++ b/src/org/torproject/onionoo/CurrentNodes.java @@ -174,11 +174,11 @@ public class CurrentNodes { entry.getLastSeenMillis()); String orPort = String.valueOf(entry.getOrPort()); String dirPort = String.valueOf(entry.getDirPort()); - StringBuilder sb = new StringBuilder(); + StringBuilder flagsBuilder = new StringBuilder(); + written = 0; for (String relayFlag : entry.getRelayFlags()) { - sb.append("," + relayFlag); + flagsBuilder.append((written++ > 0 ? "," : "") + relayFlag); } - String relayFlags = sb.toString().substring(1); String consensusWeight = String.valueOf( entry.getConsensusWeight()); String countryCode = entry.getCountryCode() != null @@ -192,7 +192,7 @@ public class CurrentNodes { ? entry.getPortList() : "null"; bw.write("r " + nickname + " " + fingerprint + " " + addressesBuilder.toString() + " " + validAfter + " " - + orPort + " " + dirPort + " " + relayFlags + " " + + orPort + " " + dirPort + " " + flagsBuilder.toString() + " " + consensusWeight + " " + countryCode + " " + hostName + " " + String.valueOf(lastRdnsLookup) + " " + defaultPolicy + " " + portList + "\n"); @@ -213,15 +213,15 @@ public class CurrentNodes { addressesBuilder.append(";"); String orPort = String.valueOf(entry.getOrPort()); String dirPort = String.valueOf(entry.getDirPort()); - StringBuilder sb = new StringBuilder(); + StringBuilder flagsBuilder = new StringBuilder(); + written = 0; for (String relayFlag : entry.getRelayFlags()) { - sb.append("," + relayFlag); + flagsBuilder.append((written++ > 0 ? "," : "") + relayFlag); } - String relayFlags = sb.toString().substring(1); bw.write("b " + nickname + " " + fingerprint + " " + addressesBuilder.toString() + " " + published + " " + orPort - + " " + dirPort + " " + relayFlags + " -1 ?? null -1 null " - + "null\n"); + + " " + dirPort + " " + flagsBuilder.toString() + + " -1 ?? null -1 null null\n"); } bw.close(); } catch (IOException e) {
tor-commits@lists.torproject.org