[tor-commits] [onionoo/master] Handle bridges without any flags.
karsten at torproject.org
karsten at torproject.org
Sun Sep 9 14:44:45 UTC 2012
commit f644623da84c5a4f851924a6b12916e6e0bbe4ea
Author: Karsten Loesing <karsten.loesing at 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) {
More information about the tor-commits
mailing list