[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-db/master] Prepare for flag-thresholds lines in bridge statuses.
commit f1b013d06a5b86a2d45424634769407131467a1a
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Wed Oct 16 15:49:05 2013 +0200
Prepare for flag-thresholds lines in bridge statuses.
Added in #9859.
---
.../ernie/db/bridgedescs/BridgeDescriptorParser.java | 8 ++++----
.../torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java | 3 ++-
.../ernie/db/bridgedescs/SanitizedBridgesWriter.java | 8 +++++++-
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/org/torproject/ernie/db/bridgedescs/BridgeDescriptorParser.java b/src/org/torproject/ernie/db/bridgedescs/BridgeDescriptorParser.java
index f0b617a..b78171a 100644
--- a/src/org/torproject/ernie/db/bridgedescs/BridgeDescriptorParser.java
+++ b/src/org/torproject/ernie/db/bridgedescs/BridgeDescriptorParser.java
@@ -23,10 +23,6 @@ public class BridgeDescriptorParser {
String line = br.readLine();
if (line == null) {
return;
- } else if (line.startsWith("r ")) {
- if (this.sbw != null) {
- this.sbw.sanitizeAndStoreNetworkStatus(allData, dateTime);
- }
} else if (line.startsWith("router ")) {
if (this.sbw != null) {
this.sbw.sanitizeAndStoreServerDescriptor(allData);
@@ -35,6 +31,10 @@ public class BridgeDescriptorParser {
if (this.sbw != null) {
this.sbw.sanitizeAndStoreExtraInfoDescriptor(allData);
}
+ } else {
+ if (this.sbw != null) {
+ this.sbw.sanitizeAndStoreNetworkStatus(allData, dateTime);
+ }
}
} catch (IOException e) {
this.logger.log(Level.WARNING, "Could not parse bridge descriptor.",
diff --git a/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java b/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java
index 783775c..493a7b6 100644
--- a/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java
+++ b/src/org/torproject/ernie/db/bridgedescs/BridgeSnapshotReader.java
@@ -118,7 +118,8 @@ public class BridgeSnapshotReader {
break;
}
}
- if (firstLine.startsWith("r ")) {
+ if (firstLine.startsWith("r ") ||
+ firstLine.startsWith("flag-thresholds ")) {
bdp.parse(allData, dateTime);
parsedStatuses++;
} else if (descriptorImportHistory.contains(fileDigest)) {
diff --git a/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java b/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
index 5861ade..dcdfb87 100644
--- a/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/org/torproject/ernie/db/bridgedescs/SanitizedBridgesWriter.java
@@ -422,6 +422,7 @@ public class SanitizedBridgesWriter extends Thread {
}
/* Parse the given network status line by line. */
+ StringBuilder header = new StringBuilder();
SortedMap<String, String> scrubbedLines =
new TreeMap<String, String>();
try {
@@ -435,9 +436,13 @@ public class SanitizedBridgesWriter extends Thread {
String hashedBridgeIdentityHex = null;
while ((line = br.readLine()) != null) {
+ /* Header lines don't have to be cleaned up. */
+ if (line.startsWith("flag-thresholds ")) {
+ header.append(line + "\n");
+
/* r lines contain sensitive information that needs to be removed
* or replaced. */
- if (line.startsWith("r ")) {
+ } else if (line.startsWith("r ")) {
/* Clear buffer from previously scrubbed lines. */
if (scrubbed.length() > 0) {
@@ -563,6 +568,7 @@ public class SanitizedBridgesWriter extends Thread {
outputFile));
bw.write("@type bridge-network-status 1.0\n");
bw.write("published " + publicationTime + "\n");
+ bw.write(header.toString());
for (String scrubbed : scrubbedLines.values()) {
bw.write(scrubbed);
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits