Commit 108b16ee authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Include or retain "fingerprint" lines.

Implements #22833.
parent de69bd5e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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.
+16 −0
Original line number Diff line number Diff line
@@ -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. */
+1 −1
Original line number Diff line number Diff line
@@ -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");

+2 −1
Original line number Diff line number Diff line
@@ -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",
+2 −1
Original line number Diff line number Diff line
@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