commit 108b16ee01d3cd7f60a98db74a6d10b50c7590c8 Author: Karsten Loesing karsten.loesing@gmx.net Date: Thu Jul 6 12:16:26 2017 +0200
Include or retain "fingerprint" lines.
Implements #22833. --- CHANGELOG.md | 2 ++ .../collector/bridgedescs/SanitizedBridgesWriter.java | 16 ++++++++++++++++ .../java/org/torproject/collector/conf/Annotation.java | 2 +- .../bridgedescs/SanitizedBridgesWriterTest.java | 3 ++- ...60920-063816-1D8F3A91C37C5D1C4C19B1AD1D0CFBE8BF72D8E1 | 3 ++- 5 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0805d48..3aadd87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * Medium changes - Clean up files in recent/exit-lists/ again. - Retain padding-counts lines in sanitized extra-info descriptors. + - Either include or retain "fingerprint" line in bridge network + statuses with @type bridge-network-status 1.2.
* Minor changes - Only consider recent relay descriptors in reference checker. diff --git a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java index 6ad2325..e3abf16 100644 --- a/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java +++ b/src/main/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriter.java @@ -461,6 +461,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
/* Parse the given network status line by line. */ StringBuilder header = new StringBuilder(); + boolean includesFingerprintLine = false; SortedMap<String, String> scrubbedLines = new TreeMap<>(); try { StringBuilder scrubbed = new StringBuilder(); @@ -483,6 +484,18 @@ public class SanitizedBridgesWriter extends CollecTorMain { } else if (line.startsWith("flag-thresholds ")) { header.append(line + "\n");
+ /* The authority fingerprint in the "fingerprint" line can go in + * unscrubbed. */ + } else if (line.startsWith("fingerprint ")) { + if (!("fingerprint " + authorityFingerprint).equals(line)) { + logger.warn("Mismatch between authority fingerprint expected from " + + "file name (" + authorityFingerprint + ") and parsed from " + + ""fingerprint" line ("" + line + "")."); + return; + } + header.append(line + "\n"); + includesFingerprintLine = true; + /* r lines contain sensitive information that needs to be removed * or replaced. */ } else if (line.startsWith("r ")) { @@ -578,6 +591,9 @@ public class SanitizedBridgesWriter extends CollecTorMain { scrubbedLines.put(hashedBridgeIdentityHex, scrubbedLine); scrubbed = new StringBuilder(); } + if (!includesFingerprintLine) { + header.append("fingerprint ").append(authorityFingerprint).append("\n"); + }
/* Check if we can tell from the descriptor publication times * whether this status is possibly stale. */ diff --git a/src/main/java/org/torproject/collector/conf/Annotation.java b/src/main/java/org/torproject/collector/conf/Annotation.java index ec983fc..e4e63d6 100644 --- a/src/main/java/org/torproject/collector/conf/Annotation.java +++ b/src/main/java/org/torproject/collector/conf/Annotation.java @@ -15,7 +15,7 @@ public enum Annotation { MicroConsensus("@type network-status-microdesc-consensus-3 1.0\n"), Microdescriptor("@type microdescriptor 1.0\n"), Server("@type server-descriptor 1.0\n"), - Status("@type bridge-network-status 1.1\n"), + Status("@type bridge-network-status 1.2\n"), Onionperf("@type torperf 1.0\n"), Vote("@type network-status-vote-3 1.0\n");
diff --git a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java index 3546a34..40e3a47 100644 --- a/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java +++ b/src/test/java/org/torproject/collector/bridgedescs/SanitizedBridgesWriterTest.java @@ -573,12 +573,13 @@ public class SanitizedBridgesWriterTest { public void testNetworkStatusDefault() throws Exception { this.runTest(); List<String> expectedLines = Arrays.asList( - "@type bridge-network-status 1.1", + "@type bridge-network-status 1.2", "published 2016-06-30 23:40:28", "flag-thresholds stable-uptime=807660 stable-mtbf=1425164 " + "fast-speed=47000 guard-wfu=98.000% guard-tk=691200 " + "guard-bw-inc-exits=400000 guard-bw-exc-exits=402000 " + "enough-mtbf=1 ignoring-advertised-bws=0", + "fingerprint 4A0CCD2DDC7995083D73F5D667100C8A5831F16D", "r MeekGoogle iPdFhA9HzgxqT+YdgnlQsG+eRTQ " + "tpIv9cBFgU30vLcqDWyUF8/72Ao 2016-06-30 21:43:52 127.0.0.1 " + "1 0", diff --git a/src/test/resources/20160920-063816-1D8F3A91C37C5D1C4C19B1AD1D0CFBE8BF72D8E1 b/src/test/resources/20160920-063816-1D8F3A91C37C5D1C4C19B1AD1D0CFBE8BF72D8E1 index 44cef60..c85732b 100644 --- a/src/test/resources/20160920-063816-1D8F3A91C37C5D1C4C19B1AD1D0CFBE8BF72D8E1 +++ b/src/test/resources/20160920-063816-1D8F3A91C37C5D1C4C19B1AD1D0CFBE8BF72D8E1 @@ -1,6 +1,7 @@ -@type bridge-network-status 1.1 +@type bridge-network-status 1.2 published 2016-09-20 06:38:16 flag-thresholds stable-uptime=1293451 stable-mtbf=1209559 fast-speed=55000 guard-wfu=98.000% guard-tk=691200 guard-bw-inc-exits=336000 guard-bw-exc-exits=337000 enough-mtbf=1 ignoring-advertised-bws=0 +fingerprint 1D8F3A91C37C5D1C4C19B1AD1D0CFBE8BF72D8E1 r Unnamed AAlGwzESK67MpzYXyyPazNZ5qm4 RJ+KTZ6gYUSvkuOS5YFOIkYXtsY 2016-09-20 05:04:15 10.183.232.113 56654 0 s Fast HSDir Running Stable V2Dir Valid w Bandwidth=790
tor-commits@lists.torproject.org