[tor-bugs] #17821 [metrics-lib]: adapt metrics-lib to actual tordnsel format

Tor Bug Tracker & Wiki blackhole at torproject.org
Sat Dec 12 07:31:32 UTC 2015


#17821: adapt metrics-lib to actual tordnsel format
-------------------------+-----------------------------------
 Reporter:  iwakeh       |          Owner:  karsten
     Type:  defect       |         Status:  needs_information
 Priority:  Medium       |      Milestone:
Component:  metrics-lib  |        Version:
 Severity:  Normal       |     Resolution:
 Keywords:               |  Actual Points:
Parent ID:               |         Points:
  Sponsor:               |
-------------------------+-----------------------------------

Comment (by karsten):

 By the way, I already have a draft patch for the `ExitList.Entry` part.
 It needs some cleaning up, which I'm happy to do.  I'm pasting it below to
 give you the idea and to avoid that you're wasting effort writing the same
 code.

 {{{
 commit 3b54364e750401a9511582f797f458a21c2250be
 Author: Karsten Loesing <karsten.loesing at gmx.net>
 Date:   Fri Dec 11 21:11:41 2015 +0100

     Temp commit.

 diff --git a/src/org/torproject/descriptor/ExitList.java
 b/src/org/torproject/descriptor/ExitList.java
 index 09d7c25..755bed4 100644
 --- a/src/org/torproject/descriptor/ExitList.java
 +++ b/src/org/torproject/descriptor/ExitList.java
 @@ -7,10 +7,35 @@ import java.util.Set;
  /* Exit list containing all known exit scan results at a given time. */
  public interface ExitList extends Descriptor {

 +  /* Exit list entry containing results from a single exit scan. */
 +  public interface Entry {
 +
 +    /* Return the scanned relay's fingerprint. */
 +    public String getFingerprint();
 +
 +    /* Return the publication time of the scanned relay's last known
 +     * descriptor. */
 +    public long getPublishedMillis();
 +
 +    /* Return the publication time of the network status that this scan
 was
 +     * based on. */
 +    public long getLastStatusMillis();
 +
 +    /* Return the IP address that was determined in the scan. */
 +    public String getExitAddress();
 +
 +    /* Return the scan time. */
 +    public long getScanMillis();
 +  }
 +
    /* Return the download time of the exit list. */
    public long getDownloadedMillis();

    /* Return the unordered set of exit scan results. */
 +  @Deprecated
    public Set<ExitListEntry> getExitListEntries();
 +
 +  /* Return the unordered set of exit scan results. */
 +  public Set<ExitList.Entry> entrySet();
  }

 diff --git a/src/org/torproject/descriptor/ExitListEntry.java
 b/src/org/torproject/descriptor/ExitListEntry.java
 index 201a172..b47158e 100644
 --- a/src/org/torproject/descriptor/ExitListEntry.java
 +++ b/src/org/torproject/descriptor/ExitListEntry.java
 @@ -3,6 +3,7 @@
  package org.torproject.descriptor;

  /* Exit list entry containing results from a single exit scan. */
 + at Deprecated
  public interface ExitListEntry {

    /* Return the scanned relay's fingerprint. */
 diff --git a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
 b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
 index a03e373..0a5f8b6 100644
 --- a/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
 +++ b/src/org/torproject/descriptor/impl/ExitListEntryImpl.java
 @@ -3,6 +3,8 @@
  package org.torproject.descriptor.impl;

  import org.torproject.descriptor.DescriptorParseException;
 +import org.torproject.descriptor.ExitList;
 +
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Scanner;
 @@ -11,7 +13,7 @@ import java.util.TreeSet;

  import org.torproject.descriptor.ExitListEntry;

 -public class ExitListEntryImpl implements ExitListEntry {
 +public class ExitListEntryImpl implements ExitListEntry, ExitList.Entry {

    private byte[] exitListEntryBytes;
    public byte[] getExitListEntryBytes() {
 diff --git a/src/org/torproject/descriptor/impl/ExitListImpl.java
 b/src/org/torproject/descriptor/impl/ExitListImpl.java
 index 53dc112..cfa5248 100644
 --- a/src/org/torproject/descriptor/impl/ExitListImpl.java
 +++ b/src/org/torproject/descriptor/impl/ExitListImpl.java
 @@ -104,10 +104,13 @@ public class ExitListImpl extends DescriptorImpl
 implements ExitList {
      return this.downloadedMillis;
    }

 -  private Set<ExitListEntry> exitListEntries =
 -      new HashSet<ExitListEntry>();
 +  private Set<ExitListEntryImpl> exitListEntries =
 +      new HashSet<ExitListEntryImpl>();
    public Set<ExitListEntry> getExitListEntries() {
      return new HashSet<ExitListEntry>(this.exitListEntries);
    }
 +  public Set<ExitList.Entry> entrySet() {
 +    return new HashSet<ExitList.Entry>(this.exitListEntries);
 +  }
  }
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/17821#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list