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

[tor-commits] [onionoo/master] Make sure primary OR address is first in array.



commit 15bfda64605a2bd355506f2a830dadd7aab2cbae
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon May 27 11:49:18 2013 +0200

    Make sure primary OR address is first in array.
    
    Right now, relays and bridges have exactly one IPv4 address and at most
    one IPv6 address.  Due to alphanumerical ordering the primary OR address
    is first in the OR address array anyway.  But the requirements to IPv4 or
    IPv6 addresses might change in the future, so make sure the ordering stays
    this way.
---
 src/org/torproject/onionoo/DetailDataWriter.java |    8 ++++----
 src/org/torproject/onionoo/ResourceServlet.java  |   12 +++++++++---
 web/index.html                                   |    7 +++++++
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/org/torproject/onionoo/DetailDataWriter.java b/src/org/torproject/onionoo/DetailDataWriter.java
index 8236d8b..8239de9 100644
--- a/src/org/torproject/onionoo/DetailDataWriter.java
+++ b/src/org/torproject/onionoo/DetailDataWriter.java
@@ -562,9 +562,9 @@ public class DetailDataWriter {
       Node entry = relay.getValue();
       String nickname = entry.getNickname();
       String address = entry.getAddress();
-      SortedSet<String> orAddresses = new TreeSet<String>(
-          entry.getOrAddressesAndPorts());
+      List<String> orAddresses = new ArrayList<String>();
       orAddresses.add(address + ":" + entry.getOrPort());
+      orAddresses.addAll(entry.getOrAddressesAndPorts());
       StringBuilder orAddressesAndPortsBuilder = new StringBuilder();
       int addressesWritten = 0;
       for (String orAddress : orAddresses) {
@@ -835,9 +835,9 @@ public class DetailDataWriter {
           entry.getFirstSeenMillis());
       String running = entry.getRunning() ? "true" : "false";
       String address = entry.getAddress();
-      SortedSet<String> orAddresses = new TreeSet<String>(
-          entry.getOrAddressesAndPorts());
+      List<String> orAddresses = new ArrayList<String>();
       orAddresses.add(address + ":" + entry.getOrPort());
+      orAddresses.addAll(entry.getOrAddressesAndPorts());
       StringBuilder orAddressesAndPortsBuilder = new StringBuilder();
       int addressesWritten = 0;
       for (String orAddress : orAddresses) {
diff --git a/src/org/torproject/onionoo/ResourceServlet.java b/src/org/torproject/onionoo/ResourceServlet.java
index 1ddb364..8a1bd0c 100644
--- a/src/org/torproject/onionoo/ResourceServlet.java
+++ b/src/org/torproject/onionoo/ResourceServlet.java
@@ -206,10 +206,16 @@ public class ResourceServlet extends HttpServlet {
         entry.getNickname() : null;
     String fingerprint = entry.getFingerprint();
     String running = entry.getRunning() ? "true" : "false";
-    SortedSet<String> addresses = new TreeSet<String>();
+    List<String> addresses = new ArrayList<String>();
     addresses.add(entry.getAddress());
-    addresses.addAll(entry.getOrAddresses());
-    addresses.addAll(entry.getExitAddresses());
+    for (String orAddress : entry.getOrAddresses()) {
+      addresses.add(orAddress);
+    }
+    for (String exitAddress : entry.getExitAddresses()) {
+      if (!addresses.contains(exitAddress)) {
+        addresses.add(exitAddress);
+      }
+    }
     StringBuilder addressesBuilder = new StringBuilder();
     int written = 0;
     for (String address : addresses) {
diff --git a/web/index.html b/web/index.html
index b726bd2..1264825 100755
--- a/web/index.html
+++ b/web/index.html
@@ -61,6 +61,8 @@ Required field.</li>
 <li><b>"a":</b> Array of IPv4 or IPv6 addresses where the relay accepts
 onion-routing connections or which the relay used to exit to the Internet
 in the past 24 hours.
+The first address is the primary onion-routing address that the relay used
+to register in the network, subsequent addresses are in arbitrary order.
 IPv6 hex characters are all lower-case.
 Required field.</li>
 <li><b>"r":</b> Boolean field saying whether this relay was listed as
@@ -114,6 +116,8 @@ hexadecimal characters.
 Required field.</li>
 <li><b>"or_addresses":</b> Array of IPv4 or IPv6 addresses and TCP ports
 or port lists where the relay accepts onion-routing connections.
+The first address is the primary onion-routing address that the relay used
+to register in the network, subsequent addresses are in arbitrary order.
 IPv6 hex characters are all lower-case.
 Required field.</li>
 <li><b>"exit_addresses":</b> Array of IPv4 or IPv6 addresses that the
@@ -325,6 +329,9 @@ Required field.</li>
 <li><b>"or_addresses":</b> Array of sanitized IPv4 or IPv6 addresses and
 TCP ports or port lists where the bridge accepts onion-routing
 connections.
+The first address is the primary onion-routing address that the bridge
+used to register in the network, subsequent addresses are in arbitrary
+order.
 IPv6 hex characters are all lower-case.
 Sanitized IP addresses are always in <i>10/8</i> or
 <i>[fd9f:2e19:3bcf/48]</i> IP networks and are only useful to learn which



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