mirror of
https://github.com/torproject/metrics-lib.git
synced 2025-02-11 20:37:39 +00:00
parent
81570c4dbc
commit
e2fc2cb14d
@ -3,6 +3,7 @@
|
||||
|
||||
package org.torproject.descriptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@ -223,7 +224,7 @@ public interface BandwidthFile extends Descriptor {
|
||||
*/
|
||||
List<RelayLine> relayLines();
|
||||
|
||||
interface RelayLine {
|
||||
interface RelayLine extends Serializable {
|
||||
|
||||
/**
|
||||
* Fingerprint for the relay's RSA identity key.
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
package org.torproject.descriptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.SortedMap;
|
||||
|
||||
/**
|
||||
@ -14,7 +15,7 @@ import java.util.SortedMap;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface BandwidthHistory {
|
||||
public interface BandwidthHistory extends Serializable {
|
||||
|
||||
/**
|
||||
* Return the original bandwidth history line as contained in the
|
||||
|
@ -4,6 +4,7 @@
|
||||
package org.torproject.descriptor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -12,7 +13,7 @@ import java.util.List;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface Descriptor {
|
||||
public interface Descriptor extends Serializable {
|
||||
|
||||
/**
|
||||
* Return the raw descriptor bytes.
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
package org.torproject.descriptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Contains details about an authority and its vote that contributed to a
|
||||
* consensus.
|
||||
@ -13,7 +15,7 @@ package org.torproject.descriptor;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface DirSourceEntry {
|
||||
public interface DirSourceEntry extends Serializable {
|
||||
|
||||
/**
|
||||
* Return the raw directory source entry bytes.
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
package org.torproject.descriptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Contains the signature of a network status consensus or vote.
|
||||
*
|
||||
@ -13,7 +15,7 @@ package org.torproject.descriptor;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface DirectorySignature {
|
||||
public interface DirectorySignature extends Serializable {
|
||||
|
||||
/**
|
||||
* Return the digest algorithm, which is "sha1" by default and which
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
package org.torproject.descriptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -26,7 +27,7 @@ public interface ExitList extends Descriptor {
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
interface Entry {
|
||||
interface Entry extends Serializable {
|
||||
|
||||
/**
|
||||
* Return the scanned relay's fingerprint, which is a SHA-1 digest of
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
package org.torproject.descriptor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
@ -23,7 +24,7 @@ import java.util.SortedSet;
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface NetworkStatusEntry {
|
||||
public interface NetworkStatusEntry extends Serializable {
|
||||
|
||||
/**
|
||||
* Return the raw network status entry bytes.
|
||||
|
@ -11,6 +11,8 @@ import java.util.TreeMap;
|
||||
|
||||
public class BandwidthHistoryImpl implements BandwidthHistory {
|
||||
|
||||
private static final long serialVersionUID = -5266052169817153234L;
|
||||
|
||||
protected BandwidthHistoryImpl(String line,
|
||||
String[] partsNoOpt) throws DescriptorParseException {
|
||||
boolean isValid = false;
|
||||
|
@ -11,6 +11,8 @@ import java.io.File;
|
||||
public class BridgeExtraInfoDescriptorImpl
|
||||
extends ExtraInfoDescriptorImpl implements BridgeExtraInfoDescriptor {
|
||||
|
||||
private static final long serialVersionUID = -1458417007735415506L;
|
||||
|
||||
protected BridgeExtraInfoDescriptorImpl(byte[] descriptorBytes,
|
||||
int[] offsetAndLimit, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -21,6 +21,8 @@ import java.util.TimeZone;
|
||||
public class BridgeNetworkStatusImpl extends NetworkStatusImpl
|
||||
implements BridgeNetworkStatus {
|
||||
|
||||
private static final long serialVersionUID = -6468907268677472808L;
|
||||
|
||||
protected BridgeNetworkStatusImpl(byte[] rawDescriptorBytes,
|
||||
int[] offsetAndLength, File descriptorFile, String fileName)
|
||||
throws DescriptorParseException {
|
||||
|
@ -15,6 +15,8 @@ import java.util.TreeMap;
|
||||
public class BridgePoolAssignmentImpl extends DescriptorImpl
|
||||
implements BridgePoolAssignment {
|
||||
|
||||
private static final long serialVersionUID = -8370471568586190472L;
|
||||
|
||||
protected BridgePoolAssignmentImpl(byte[] rawDescriptorBytes,
|
||||
int[] offsetAndlength, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -11,6 +11,8 @@ import java.io.File;
|
||||
public class BridgeServerDescriptorImpl extends ServerDescriptorImpl
|
||||
implements BridgeServerDescriptor {
|
||||
|
||||
private static final long serialVersionUID = -9158883686763377765L;
|
||||
|
||||
protected BridgeServerDescriptorImpl(byte[] rawDescriptorBytes,
|
||||
int[] offsetAndLength, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -20,6 +20,8 @@ import java.util.Set;
|
||||
public class BridgedbMetricsImpl extends DescriptorImpl
|
||||
implements BridgedbMetrics {
|
||||
|
||||
private static final long serialVersionUID = 3899169611574577173L;
|
||||
|
||||
private static final Set<Key> exactlyOnce = EnumSet.of(
|
||||
Key.BRIDGEDB_METRICS_END, Key.BRIDGEDB_METRICS_VERSION);
|
||||
|
||||
|
@ -17,6 +17,8 @@ import java.util.Set;
|
||||
|
||||
public class DirSourceEntryImpl implements DirSourceEntry {
|
||||
|
||||
private static final long serialVersionUID = 7276698015074138852L;
|
||||
|
||||
private DescriptorImpl parent;
|
||||
|
||||
private int offset;
|
||||
|
@ -15,6 +15,8 @@ import java.util.Set;
|
||||
public class DirectoryKeyCertificateImpl extends DescriptorImpl
|
||||
implements DirectoryKeyCertificate {
|
||||
|
||||
private static final long serialVersionUID = 1375140776886611946L;
|
||||
|
||||
protected DirectoryKeyCertificateImpl(byte[] rawDescriptorBytes,
|
||||
int[] offsetAndLength, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -15,6 +15,8 @@ import java.util.Scanner;
|
||||
|
||||
public class DirectorySignatureImpl implements DirectorySignature {
|
||||
|
||||
private static final long serialVersionUID = -1084841439595622290L;
|
||||
|
||||
private DescriptorImpl parent;
|
||||
|
||||
private int offset;
|
||||
|
@ -16,6 +16,8 @@ import java.util.TreeSet;
|
||||
|
||||
public class ExitListEntryImpl implements ExitList.Entry {
|
||||
|
||||
private static final long serialVersionUID = 9014559583423738584L;
|
||||
|
||||
private String exitListEntryString;
|
||||
|
||||
private List<String> unrecognizedLines;
|
||||
|
@ -18,6 +18,8 @@ import java.util.TimeZone;
|
||||
|
||||
public class ExitListImpl extends DescriptorImpl implements ExitList {
|
||||
|
||||
private static final long serialVersionUID = 4227448935362502463L;
|
||||
|
||||
protected ExitListImpl(byte[] rawDescriptorBytes, File descriptorfile,
|
||||
String fileName) throws DescriptorParseException {
|
||||
super(rawDescriptorBytes, new int[] { 0, rawDescriptorBytes.length },
|
||||
|
@ -0,0 +1,31 @@
|
||||
/* Copyright 2020 The Tor Project
|
||||
* See LICENSE for licensing information */
|
||||
|
||||
package org.torproject.descriptor.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ExitStatisticsPortComparator implements Comparator<String>,
|
||||
Serializable {
|
||||
|
||||
private static final long serialVersionUID = 636628160711742180L;
|
||||
|
||||
@Override
|
||||
public int compare(String arg0, String arg1) {
|
||||
int port0;
|
||||
int port1;
|
||||
try {
|
||||
port1 = Integer.parseInt(arg1);
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
try {
|
||||
port0 = Integer.parseInt(arg0);
|
||||
} catch (NumberFormatException e) {
|
||||
return 1;
|
||||
}
|
||||
return Integer.compare(port0, port1);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import java.util.TreeMap;
|
||||
public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl
|
||||
implements ExtraInfoDescriptor {
|
||||
|
||||
private static final long serialVersionUID = -4720810362228341775L;
|
||||
|
||||
private Set<Key> exactlyOnceKeys = EnumSet.of(
|
||||
Key.EXTRA_INFO, Key.PUBLISHED);
|
||||
|
||||
@ -607,22 +609,7 @@ public abstract class ExtraInfoDescriptorImpl extends DescriptorImpl
|
||||
private SortedMap<String, Long> sortByPorts(
|
||||
SortedMap<String, Long> naturalOrder) {
|
||||
SortedMap<String, Long> byPortNumber =
|
||||
new TreeMap<>((arg0, arg1) -> {
|
||||
int port0;
|
||||
int port1;
|
||||
try {
|
||||
port1 = Integer.parseInt(arg1);
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
try {
|
||||
port0 = Integer.parseInt(arg0);
|
||||
} catch (NumberFormatException e) {
|
||||
return 1;
|
||||
}
|
||||
return Integer.compare(port0, port1);
|
||||
}
|
||||
);
|
||||
new TreeMap<>(new ExitStatisticsPortComparator());
|
||||
byPortNumber.putAll(naturalOrder);
|
||||
return byPortNumber;
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ import java.util.TreeMap;
|
||||
|
||||
public class KeyValueMap<T> extends TreeMap<String, T> {
|
||||
|
||||
private static final long serialVersionUID = 1124527355143605927L;
|
||||
|
||||
private Class<T> clazz;
|
||||
|
||||
public KeyValueMap(Class<T> clazz) {
|
||||
|
@ -18,6 +18,8 @@ import java.util.Set;
|
||||
public class MicrodescriptorImpl extends DescriptorImpl
|
||||
implements Microdescriptor {
|
||||
|
||||
private static final long serialVersionUID = 7792584185486747094L;
|
||||
|
||||
protected MicrodescriptorImpl(byte[] descriptorBytes, int[] offsetAndLength,
|
||||
File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -23,6 +23,8 @@ import java.util.TreeSet;
|
||||
|
||||
public class NetworkStatusEntryImpl implements NetworkStatusEntry {
|
||||
|
||||
private static final long serialVersionUID = 8531564655041660420L;
|
||||
|
||||
private DescriptorImpl parent;
|
||||
|
||||
private int offset;
|
||||
|
@ -21,6 +21,8 @@ import java.util.TreeMap;
|
||||
* delegate the specific parts to the subclasses. */
|
||||
public abstract class NetworkStatusImpl extends DescriptorImpl {
|
||||
|
||||
private static final long serialVersionUID = -2208207369822099643L;
|
||||
|
||||
protected Map<String, Integer> flagIndexes = new HashMap<>();
|
||||
|
||||
protected Map<Integer, String> flagStrings = new HashMap<>();
|
||||
|
@ -18,6 +18,8 @@ import java.util.Set;
|
||||
public class RelayDirectoryImpl extends DescriptorImpl
|
||||
implements RelayDirectory {
|
||||
|
||||
private static final long serialVersionUID = -6770225160489757961L;
|
||||
|
||||
protected RelayDirectoryImpl(byte[] directoryBytes, int[] offsetAndLength,
|
||||
File descriptorFile) throws DescriptorParseException {
|
||||
super(directoryBytes, offsetAndLength, descriptorFile, true);
|
||||
|
@ -11,6 +11,8 @@ import java.io.File;
|
||||
public class RelayExtraInfoDescriptorImpl
|
||||
extends ExtraInfoDescriptorImpl implements RelayExtraInfoDescriptor {
|
||||
|
||||
private static final long serialVersionUID = 2526561625458492428L;
|
||||
|
||||
protected RelayExtraInfoDescriptorImpl(byte[] descriptorBytes,
|
||||
int[] offsetAndLimit, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -22,6 +22,8 @@ import java.util.TreeSet;
|
||||
public class RelayNetworkStatusConsensusImpl extends NetworkStatusImpl
|
||||
implements RelayNetworkStatusConsensus {
|
||||
|
||||
private static final long serialVersionUID = -2852336205396172171L;
|
||||
|
||||
protected RelayNetworkStatusConsensusImpl(byte[] consensusBytes,
|
||||
int[] offsetAndLimit, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -19,6 +19,8 @@ import java.util.TreeSet;
|
||||
public class RelayNetworkStatusImpl extends NetworkStatusImpl
|
||||
implements RelayNetworkStatus {
|
||||
|
||||
private static final long serialVersionUID = 2872005332125710108L;
|
||||
|
||||
protected RelayNetworkStatusImpl(byte[] statusBytes, int[] offsetAndLength,
|
||||
File descriptorFile) throws DescriptorParseException {
|
||||
super(statusBytes, offsetAndLength, descriptorFile, true);
|
||||
|
@ -23,6 +23,8 @@ import java.util.TreeSet;
|
||||
public class RelayNetworkStatusVoteImpl extends NetworkStatusImpl
|
||||
implements RelayNetworkStatusVote {
|
||||
|
||||
private static final long serialVersionUID = -39488588769922984L;
|
||||
|
||||
protected RelayNetworkStatusVoteImpl(byte[] voteBytes, int[] offsetAndLength,
|
||||
File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -11,6 +11,8 @@ import java.io.File;
|
||||
public class RelayServerDescriptorImpl extends ServerDescriptorImpl
|
||||
implements RelayServerDescriptor {
|
||||
|
||||
private static final long serialVersionUID = -8871465152198614055L;
|
||||
|
||||
protected RelayServerDescriptorImpl(byte[] descriptorBytes,
|
||||
int[] offsetAndLength, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -7,6 +7,8 @@ import org.torproject.descriptor.RouterStatusEntry;
|
||||
|
||||
public class RouterStatusEntryImpl implements RouterStatusEntry {
|
||||
|
||||
private static final long serialVersionUID = 4362115843485982121L;
|
||||
|
||||
protected RouterStatusEntryImpl(String fingerprint, String nickname,
|
||||
boolean isLive, boolean isVerified) {
|
||||
this.fingerprint = fingerprint;
|
||||
|
@ -22,6 +22,8 @@ import java.util.SortedSet;
|
||||
public abstract class ServerDescriptorImpl extends DescriptorImpl
|
||||
implements ServerDescriptor {
|
||||
|
||||
private static final long serialVersionUID = 5240701284736998121L;
|
||||
|
||||
private static final Set<Key> atMostOnce = EnumSet.of(
|
||||
Key.IDENTITY_ED25519, Key.MASTER_KEY_ED25519, Key.PLATFORM, Key.PROTO,
|
||||
Key.FINGERPRINT, Key.HIBERNATING, Key.UPTIME, Key.CONTACT, Key.FAMILY,
|
||||
|
@ -19,6 +19,8 @@ import java.util.SortedMap;
|
||||
public class SnowflakeStatsImpl extends DescriptorImpl
|
||||
implements SnowflakeStats {
|
||||
|
||||
private static final long serialVersionUID = 5588809239715099933L;
|
||||
|
||||
private static final Set<Key> atMostOnce = EnumSet.of(
|
||||
Key.SNOWFLAKE_IPS, Key.SNOWFLAKE_IPS_TOTAL, Key.SNOWFLAKE_IPS_STANDALONE,
|
||||
Key.SNOWFLAKE_IPS_BADGE, Key.SNOWFLAKE_IPS_WEBEXT,
|
||||
|
@ -21,6 +21,8 @@ import java.util.TreeMap;
|
||||
public class TorperfResultImpl extends DescriptorImpl
|
||||
implements TorperfResult {
|
||||
|
||||
private static final long serialVersionUID = 8961567618137500044L;
|
||||
|
||||
protected static List<Descriptor> parseTorperfResults(
|
||||
byte[] rawDescriptorBytes, File descriptorFile)
|
||||
throws DescriptorParseException {
|
||||
|
@ -12,6 +12,8 @@ import java.util.List;
|
||||
public class UnparseableDescriptorImpl extends DescriptorImpl
|
||||
implements UnparseableDescriptor {
|
||||
|
||||
private static final long serialVersionUID = 7750009166142114121L;
|
||||
|
||||
protected UnparseableDescriptorImpl(byte[] rawDescriptorBytes,
|
||||
int[] offsetAndLength, File descriptorFile,
|
||||
DescriptorParseException descriptorParseException) {
|
||||
|
@ -33,6 +33,8 @@ import java.util.stream.Stream;
|
||||
public class WebServerAccessLogImpl extends LogDescriptorImpl
|
||||
implements InternalWebServerAccessLog, WebServerAccessLog {
|
||||
|
||||
private static final long serialVersionUID = 7528914359452568309L;
|
||||
|
||||
private static final Logger log
|
||||
= LoggerFactory.getLogger(WebServerAccessLogImpl.class);
|
||||
|
||||
|
@ -23,6 +23,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class WebServerAccessLogLine implements WebServerAccessLog.Line {
|
||||
|
||||
private static final long serialVersionUID = 6160416810587561460L;
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(WebServerAccessLogLine.class);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user