[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionoo/master] Index relays with no known country or AS
commit 641a939cde75fa3a5cddd32ee29a6508fd66b4c4
Author: Iain R. Learmonth <irl@xxxxxxxx>
Date: Tue Jul 10 11:51:23 2018 +0100
Index relays with no known country or AS
Indexes are created for relays with no known country code or
autonomous system number using the special values "xz" and "AS0"
respectively.
No changes are made to the summary or details documents.
Fixes: #26665
---
CHANGELOG.md | 4 ++
.../org/torproject/onionoo/server/NodeIndexer.java | 43 ++++++++++++++--------
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c9c9aba..ca0142b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@
- Provide more accurate DNS results in "verified_host_names" and
"unverified_host_names".
+ * Minor changes
+ - Index relays with no known country code or autonomous system
+ number using the special values "xz" and "AS0" respectively.
+
# Changes in version 6.0-1.14.0 - 2018-05-29
diff --git a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
index c95818d..f6b84b8 100644
--- a/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
+++ b/src/main/java/org/torproject/onionoo/server/NodeIndexer.java
@@ -198,23 +198,36 @@ public class NodeIndexer implements ServletContextListener, Runnable {
.toUpperCase();
newRelayFingerprintSummaryLines.put(fingerprint, entry);
newRelayFingerprintSummaryLines.put(hashedFingerprint, entry);
- if (entry.getCountryCode() != null) {
- String countryCode = entry.getCountryCode();
- if (!newRelaysByCountryCode.containsKey(countryCode)) {
- newRelaysByCountryCode.put(countryCode,
- new HashSet<String>());
- }
- newRelaysByCountryCode.get(countryCode).add(fingerprint);
- newRelaysByCountryCode.get(countryCode).add(hashedFingerprint);
+ String countryCode;
+ if (null != entry.getCountryCode()) {
+ countryCode = entry.getCountryCode();
+ } else {
+ /* The country code xz will never be assigned for use with ISO 3166-1
+ * and is "user-assigned". Fun fact: UN/LOCODE assigns XZ to represent
+ * installations in international waters. */
+ countryCode = "xz";
}
- if (entry.getAsNumber() != null) {
- String asNumber = entry.getAsNumber();
- if (!newRelaysByAsNumber.containsKey(asNumber)) {
- newRelaysByAsNumber.put(asNumber, new HashSet<String>());
- }
- newRelaysByAsNumber.get(asNumber).add(fingerprint);
- newRelaysByAsNumber.get(asNumber).add(hashedFingerprint);
+ if (!newRelaysByCountryCode.containsKey(countryCode)) {
+ newRelaysByCountryCode.put(countryCode,
+ new HashSet<String>());
+ }
+ newRelaysByCountryCode.get(countryCode).add(fingerprint);
+ newRelaysByCountryCode.get(countryCode).add(hashedFingerprint);
+ String asNumber;
+ if (null != entry.getAsNumber()) {
+ asNumber = entry.getAsNumber();
+ } else {
+ /* Autonomous system number 0 is reserved by RFC6707, to be used for
+ * networks that are not routed. The use of this number should be,
+ * and in the majority of cases probably is, filtered and so it
+ * shouldn't appear in any lookup databases. */
+ asNumber = "AS0";
+ }
+ if (!newRelaysByAsNumber.containsKey(asNumber)) {
+ newRelaysByAsNumber.put(asNumber, new HashSet<String>());
}
+ newRelaysByAsNumber.get(asNumber).add(fingerprint);
+ newRelaysByAsNumber.get(asNumber).add(hashedFingerprint);
for (String flag : entry.getRelayFlags()) {
String flagLowerCase = flag.toLowerCase();
if (!newRelaysByFlag.containsKey(flagLowerCase)) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits