[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [onionoo/release] Add "unreachable_or_addresses" field.



commit 7aca1ca996bcfd75a275a799fd42a29c8cb0080b
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed Oct 18 09:20:33 2017 +0200

    Add "unreachable_or_addresses" field.
    
    Implements #21637.
---
 CHANGELOG.md                                                   |  2 ++
 src/main/java/org/torproject/onionoo/docs/DetailsDocument.java | 10 ++++++++++
 src/main/java/org/torproject/onionoo/docs/DetailsStatus.java   | 10 ++++++++++
 .../torproject/onionoo/updater/NodeDetailsStatusUpdater.java   |  1 +
 .../org/torproject/onionoo/writer/DetailsDocumentWriter.java   | 10 ++++++++++
 5 files changed, 33 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 76243ef..c48075e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@
    - Skip unrecognized descriptors when importing archives rather than
      aborting the entire import.
    - Add new "host_name" parameter to filter by host name.
+   - Add new "unreachable_or_addresses" field with declared but
+     unreachable OR addresses.
 
 
 # Changes in version 4.2-1.6.1 - 2017-10-26
diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
index 97fc703..bde3cae 100644
--- a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
+++ b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
@@ -473,5 +473,15 @@ public class DetailsDocument extends Document {
   public Boolean getMeasured() {
     return this.measured;
   }
+
+  private List<String> unreachable_or_addresses;
+
+  public void setUnreachableOrAddresses(List<String> unreachableOrAddresses) {
+    this.unreachable_or_addresses = unreachableOrAddresses;
+  }
+
+  public List<String> getUnreachableOrAddresses() {
+    return this.unreachable_or_addresses;
+  }
 }
 
diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java
index faec117..77ff75f 100644
--- a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java
@@ -530,5 +530,15 @@ public class DetailsStatus extends Document {
   public String getHostName() {
     return unescapeJson(this.host_name);
   }
+
+  private List<String> advertised_or_addresses;
+
+  public void setAdvertisedOrAddresses(List<String> advertisedOrAddresses) {
+    this.advertised_or_addresses = advertisedOrAddresses;
+  }
+
+  public List<String> getAdvertisedOrAddresses() {
+    return this.advertised_or_addresses;
+  }
 }
 
diff --git a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
index 73e826a..fa3f3af 100644
--- a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
+++ b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
@@ -199,6 +199,7 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
     }
     detailsStatus.setHibernating(descriptor.isHibernating() ? true :
         null);
+    detailsStatus.setAdvertisedOrAddresses(descriptor.getOrAddresses());
     this.documentStore.store(detailsStatus, fingerprint);
   }
 
diff --git a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
index e3f638d..9538cba 100644
--- a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
@@ -155,6 +155,16 @@ public class DetailsDocumentWriter implements DocumentWriter {
           exitAddressesWithoutOrAddresses));
     }
     detailsDocument.setMeasured(detailsStatus.getMeasured());
+    List<String> unreachableOrAddresses = new ArrayList<>();
+    if (null != detailsStatus.getAdvertisedOrAddresses()) {
+      unreachableOrAddresses.addAll(detailsStatus.getAdvertisedOrAddresses());
+    }
+    if (null != detailsStatus.getOrAddressesAndPorts()) {
+      unreachableOrAddresses.removeAll(detailsStatus.getOrAddressesAndPorts());
+    }
+    if (!unreachableOrAddresses.isEmpty()) {
+      detailsDocument.setUnreachableOrAddresses(unreachableOrAddresses);
+    }
     this.documentStore.store(detailsDocument, fingerprint);
   }
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits