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

[tor-commits] [onionoo/master] Add transport names to bridge details documents.



commit 655a63dc1da746b4ebf98f8315c12b3d9f1c8873
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Dec 2 11:31:53 2014 +0100

    Add transport names to bridge details documents.
    
    Implements #11052.
---
 .../torproject/onionoo/docs/DetailsDocument.java   |    9 ++++++++
 .../org/torproject/onionoo/docs/DetailsStatus.java |   19 ++++++++++++++++
 .../torproject/onionoo/server/ResponseBuilder.java |    2 ++
 .../onionoo/updater/NodeDetailsStatusUpdater.java  |   24 ++++++++++++++++++++
 .../onionoo/writer/DetailsDocumentWriter.java      |    1 +
 web/protocol.html                                  |   10 ++++++++
 6 files changed, 65 insertions(+)

diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
index 86abf9f..9e0a067 100644
--- a/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
+++ b/src/main/java/org/torproject/onionoo/docs/DetailsDocument.java
@@ -356,5 +356,14 @@ public class DetailsDocument extends Document {
   public String getPoolAssignment() {
     return this.pool_assignment;
   }
+
+  private List<String> transports;
+  public void setTransports(List<String> transports) {
+    this.transports = (transports != null && !transports.isEmpty()) ?
+        transports : null;
+  }
+  public List<String> getTransports() {
+    return this.transports;
+  }
 }
 
diff --git a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java
index 967e493..085ce8d 100644
--- a/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java
+++ b/src/main/java/org/torproject/onionoo/docs/DetailsStatus.java
@@ -130,6 +130,25 @@ public class DetailsStatus extends Document {
     return this.hibernating;
   }
 
+  /* From most recently published extra-info descriptor: */
+
+  private Long extra_info_desc_published;
+  public void setExtraInfoDescPublished(Long extraInfoDescPublished) {
+    this.extra_info_desc_published = extraInfoDescPublished;
+  }
+  public Long getExtraInfoDescPublished() {
+    return this.extra_info_desc_published;
+  }
+
+  private List<String> transports;
+  public void setTransports(List<String> transports) {
+    this.transports = (transports != null && !transports.isEmpty()) ?
+        transports : null;
+  }
+  public List<String> getTransports() {
+    return this.transports;
+  }
+
   /* From network status entries: */
 
   private boolean is_relay;
diff --git a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
index d2239aa..ee92e95 100644
--- a/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
+++ b/src/main/java/org/torproject/onionoo/server/ResponseBuilder.java
@@ -266,6 +266,8 @@ public class ResponseBuilder {
             dd.setHibernating(detailsDocument.getHibernating());
           } else if (field.equals("pool_assignment")) {
             dd.setPoolAssignment(detailsDocument.getPoolAssignment());
+          } else if (field.equals("transports")) {
+            dd.setTransports(detailsDocument.getTransports());
           }
         }
         /* Don't escape HTML characters, like < and >, contained in
diff --git a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
index 0ce17e4..102c6df 100644
--- a/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
+++ b/src/main/java/org/torproject/onionoo/updater/NodeDetailsStatusUpdater.java
@@ -20,6 +20,7 @@ import org.torproject.descriptor.BridgePoolAssignment;
 import org.torproject.descriptor.Descriptor;
 import org.torproject.descriptor.ExitList;
 import org.torproject.descriptor.ExitListEntry;
+import org.torproject.descriptor.ExtraInfoDescriptor;
 import org.torproject.descriptor.NetworkStatusEntry;
 import org.torproject.descriptor.RelayNetworkStatusConsensus;
 import org.torproject.descriptor.ServerDescriptor;
@@ -113,6 +114,8 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
     this.descriptorSource.registerDescriptorListener(this,
         DescriptorType.BRIDGE_SERVER_DESCRIPTORS);
     this.descriptorSource.registerDescriptorListener(this,
+        DescriptorType.BRIDGE_EXTRA_INFOS);
+    this.descriptorSource.registerDescriptorListener(this,
         DescriptorType.BRIDGE_POOL_ASSIGNMENTS);
     this.descriptorSource.registerDescriptorListener(this,
         DescriptorType.EXIT_LISTS);
@@ -132,6 +135,9 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
           (RelayNetworkStatusConsensus) descriptor);
     } else if (descriptor instanceof ServerDescriptor && !relay) {
       this.processBridgeServerDescriptor((ServerDescriptor) descriptor);
+    } else if (descriptor instanceof ExtraInfoDescriptor && !relay) {
+      this.processBridgeExtraInfoDescriptor(
+          (ExtraInfoDescriptor) descriptor);
     } else if (descriptor instanceof BridgePoolAssignment) {
       this.processBridgePoolAssignment((BridgePoolAssignment) descriptor);
     } else if (descriptor instanceof BridgeNetworkStatus) {
@@ -289,6 +295,24 @@ public class NodeDetailsStatusUpdater implements DescriptorListener,
     this.updatedNodes.add(fingerprint);
   }
 
+  private void processBridgeExtraInfoDescriptor(
+      ExtraInfoDescriptor descriptor) {
+    String fingerprint = descriptor.getFingerprint();
+    DetailsStatus detailsStatus = this.documentStore.retrieve(
+        DetailsStatus.class, true, fingerprint);
+    if (detailsStatus == null) {
+      detailsStatus = new DetailsStatus();
+    } else if (null == detailsStatus.getExtraInfoDescPublished() ||
+        descriptor.getPublishedMillis() >
+        detailsStatus.getExtraInfoDescPublished()) {
+      detailsStatus.setExtraInfoDescPublished(
+          descriptor.getPublishedMillis());
+      detailsStatus.setTransports(descriptor.getTransports());
+      this.documentStore.store(detailsStatus, fingerprint);
+      this.updatedNodes.add(fingerprint);
+    }
+  }
+
   private Map<String, String> bridgePoolAssignments =
       new HashMap<String, String>();
 
diff --git a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
index 7f464b6..59bb269 100644
--- a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
@@ -151,6 +151,7 @@ public class DetailsDocumentWriter implements DocumentWriter {
         detailsStatus.getAdvertisedBandwidth());
     detailsDocument.setPlatform(detailsStatus.getPlatform());
     detailsDocument.setPoolAssignment(detailsStatus.getPoolAssignment());
+    detailsDocument.setTransports(detailsStatus.getTransports());
     this.documentStore.store(detailsDocument, fingerprint);
   }
 
diff --git a/web/protocol.html b/web/protocol.html
index fed1c36..3766d90 100644
--- a/web/protocol.html
+++ b/web/protocol.html
@@ -1394,6 +1394,16 @@ available.
 </p>
 </li>
 
+<li>
+<b><font color="blue">transports</font></b>
+<code class="typeof">array of strings</code>
+<span class="required-false">optional</span>
+<p>
+Array of (pluggable) transport names supported by this bridge.
+<font color="blue">Added on December 2, 2014.</font>
+</p>
+</li>
+
 </ul>
 
 </div> <!-- box -->



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