[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [metrics-lib/master] Looks like $fingerprint=nickname is a valid family line entry.
commit 6a46f46bd0e6e8e155812d6e2593d936e287d7ba
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Mon Jan 16 12:42:25 2012 +0100
Looks like $fingerprint=nickname is a valid family line entry.
---
.../torproject/descriptor/ServerDescriptor.java | 6 +++---
.../descriptor/impl/ServerDescriptorImpl.java | 14 +++++++++++---
.../descriptor/impl/ServerDescriptorImplTest.java | 11 +++++++++++
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/src/org/torproject/descriptor/ServerDescriptor.java b/src/org/torproject/descriptor/ServerDescriptor.java
index 98a0f02..631779e 100644
--- a/src/org/torproject/descriptor/ServerDescriptor.java
+++ b/src/org/torproject/descriptor/ServerDescriptor.java
@@ -62,9 +62,9 @@ public interface ServerDescriptor extends Descriptor {
* information is included in the descriptor. */
public String getContact();
- /* Return the nicknames or ($-prefixed) fingerprints contained in the
- * family line of this relay, or null if the descriptor does not contain
- * a family line. */
+ /* Return the nicknames, ($-prefixed) fingerprints, or
+ * $fingerprint=nickname tuples contained in the family line of this
+ * relay, or null if the descriptor does not contain a family line. */
public List<String> getFamilyEntries();
/* Return the relay's read history. (Current Tor versions include their
diff --git a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
index 411e8c9..9fbcd84 100644
--- a/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
+++ b/src/org/torproject/descriptor/impl/ServerDescriptorImpl.java
@@ -287,9 +287,17 @@ public class ServerDescriptorImpl extends DescriptorImpl
this.familyEntries = new ArrayList<String>();
for (int i = 1; i < partsNoOpt.length; i++) {
if (partsNoOpt[i].startsWith("$")) {
- this.familyEntries.add("$"
- + ParseHelper.parseTwentyByteHexString(line,
- partsNoOpt[i].substring(1)));
+ if (partsNoOpt[i].contains("=")) {
+ String fingerprint = ParseHelper.parseTwentyByteHexString(line,
+ partsNoOpt[i].substring(1, partsNoOpt[i].indexOf("=")));
+ String nickname = ParseHelper.parseNickname(line,
+ partsNoOpt[i].substring(partsNoOpt[i].indexOf("=") + 1));
+ this.familyEntries.add("$" + fingerprint + "=" + nickname);
+ } else {
+ this.familyEntries.add("$"
+ + ParseHelper.parseTwentyByteHexString(line,
+ partsNoOpt[i].substring(1)));
+ }
} else {
this.familyEntries.add(ParseHelper.parseNickname(line,
partsNoOpt[i]));
diff --git a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
index f699694..6a3ba3a 100644
--- a/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
+++ b/test/org/torproject/descriptor/impl/ServerDescriptorImplTest.java
@@ -836,6 +836,17 @@ public class ServerDescriptorImplTest {
}
@Test()
+ public void testFamilyFingerprintNickname()
+ throws DescriptorParseException {
+ ServerDescriptor descriptor = DescriptorBuilder.
+ createWithFamilyLine("family "
+ + "$D8733048FC8EC9102466AD8F3098622BF1BF71FD=saberrider2008");
+ assertEquals(Arrays.asList(new String[]
+ { "$D8733048FC8EC9102466AD8F3098622BF1BF71FD=saberrider2008" }),
+ descriptor.getFamilyEntries());
+ }
+
+ @Test()
public void testWriteHistory() throws DescriptorParseException {
String writeHistoryLine = "write-history 2012-01-01 03:51:44 (900 s) "
+ "4345856,261120,7591936,1748992";
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits