[tor-commits] [metrics-lib/release] Properly parse hostname in v2 network status.
karsten at torproject.org
karsten at torproject.org
Wed Jan 15 21:46:57 UTC 2020
commit ca37fd616c1e6464829e4ef64d6252944ccb69f5
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Wed Nov 20 17:53:54 2019 +0100
Properly parse hostname in v2 network status.
---
CHANGELOG.md | 2 ++
.../java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java | 1 +
.../java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java | 1 +
3 files changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 568f115..ad91d5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,8 @@
* Minor changes
- Fix a NullPointerException when parsing an invalid crypto block
starting with "-----END " rather than "-----BEGIN ".
+ - Properly parse an authority's hostname from the "dir-source" line
+ in a v2 network status.
# Changes in version 2.9.1 - 2019-11-09
diff --git a/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java b/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
index 1af9503..9860df0 100644
--- a/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
+++ b/src/main/java/org/torproject/descriptor/impl/RelayNetworkStatusImpl.java
@@ -181,6 +181,7 @@ public class RelayNetworkStatusImpl extends NetworkStatusImpl
throw new DescriptorParseException("Illegal hostname in '" + line
+ "'.");
}
+ this.hostname = parts[1];
this.address = ParseHelper.parseIpv4Address(line, parts[2]);
this.dirPort = ParseHelper.parsePort(line, parts[3]);
}
diff --git a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
index 9ecf391..80d46da 100644
--- a/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
+++ b/src/test/java/org/torproject/descriptor/impl/RelayNetworkStatusImplTest.java
@@ -60,6 +60,7 @@ public class RelayNetworkStatusImplTest {
new int[] { 0, statusBytes.length }, null);
assertEquals(rnsi.getContactLine(),
"1024R/8D56913D Alex de Joode <adejoode at sabotage.org>");
+ assertEquals("194.109.206.212", rnsi.getHostname());
}
}
More information about the tor-commits
mailing list