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

[tor-commits] [atlas/master] Refactors Additional Flag generation and display



commit 003f6a9ec7619b5d9d6ae68dc5aa8c8bd005708c
Author: Iain R. Learmonth <irl@xxxxxxxx>
Date:   Wed Nov 22 14:02:59 2017 +0000

    Refactors Additional Flag generation and display
---
 js/models/relay.js            | 27 ++++++++++++++++++++++++---
 templates/details/bridge.html | 18 ++++++++----------
 templates/details/router.html | 35 +++++++++--------------------------
 templates/search/do.html      | 14 +-------------
 4 files changed, 42 insertions(+), 52 deletions(-)

diff --git a/js/models/relay.js b/js/models/relay.js
index 1c0f89f..6169955 100644
--- a/js/models/relay.js
+++ b/js/models/relay.js
@@ -57,6 +57,22 @@ define([
             });
             return output;
         },
+        parseadditionalflags: function(flags) {
+            var output = [];
+            var model = this;
+            _.each(flags, function(flag) {
+                if (flag == "Not Recommended") {
+                    output.push([flag,"not_recommended_16x16", "This relay is running a Tor version that is not recommended by the directory authorities and may contain known issues."]);
+                }
+                if (flag == "Unmeasured") {
+                    output.push([flag,"unmeasured_16x16", "This relay has not been measured by at least 3 bandwidth authorities and so its consensus weight is currently capped. This is expected for new relays."]);
+                }
+                if (flag == "FallbackDir") {
+                    output.push([flag,"fallbackdir_16x16", "Tor clients contact fallback directory mirrors during bootstrap, and download the consensus and authority certificates from them. We include a default list of mirrors in the Tor source code. These default mirrors need to be long-term stable, and on the same IPv4 and IPv6 addresses and ports."]);
+                }
+            });
+            return output;
+        },
         parsedate: function(utctime) {
             var hr_magic = [10];
             var t = utctime.split(" ");
@@ -158,9 +174,6 @@ define([
         processRelay: function(options, model, relay) {
                     relay.contact = relay.contact ? relay.contact : 'undefined';
                     relay.platform = relay.platform ? relay.platform : null;
-                    relay.recommended_version = (typeof relay.recommended_version !== 'undefined') ? relay.recommended_version : null;
-                    relay.measured = (typeof relay.measured !== 'undefined') ? relay.measured : null;
-                    relay.fallback_dir = IsFallbackDir(relay.fingerprint);
                     relay.nickname = relay.nickname ? relay.nickname : "Unnamed";
                     relay.dir_address = relay.dir_address ? relay.dir_address : null;
                     relay.exit_policy = relay.exit_policy ? relay.exit_policy : null;
@@ -205,6 +218,14 @@ define([
                     model.set({badexit: false});
                     var size = ['16x16', '14x16', '8x16'];
                     relay.flags = model.parseflags(relay.flags, size);
+
+                    /* Synthetic Additional Flags */
+                    var additional_flags = []
+                    if (!((typeof relay.recommended_version !== 'undefined') ? relay.recommended_version : true)) additional_flags.push("Not Recommended");
+                    if (!((typeof relay.measured !== 'undefined') ? relay.measured : true)) additional_flags.push("Unmeasured");
+                    if (IsFallbackDir(relay.fingerprint)) additional_flags.push("FallbackDir");
+                    relay.additional_flags = model.parseadditionalflags(additional_flags);
+
                     model.set(relay, options);
 
         },
diff --git a/templates/details/bridge.html b/templates/details/bridge.html
index 7b8a40a..e74ce93 100644
--- a/templates/details/bridge.html
+++ b/templates/details/bridge.html
@@ -58,16 +58,14 @@
     
     <dt><span class="tip" title="Flags that have been generated by Relay Search to provide extra useful information. These flags do not appear in the directory consensus.">Additional Flags</span></dt>
     <dd>
-    <% var propertyCount = 0; %>
-    <% if (relay.get('recommended_version') === false) {
-        propertyCount++;
-        %>
-        <span class="tip flags" title="This bridge is running a Tor version that is not recommended by the directory authorities and may contain known issues.">
-            <img class="inline" alt="" src="img/properties/not_recommended_16x16.png"/>
-            <span class="inline">Outdated Tor version</span>
-        </span>
-    <% } %>
-    <%=propertyCount==0?'none':''%>
+        <% var propertyCount = 0; %>
+        <% _.each(relay.get('additional_flags'), function(flag) { propertyCount++; %>
+            <span class="tip flags" title="<%= flag[2] %>">
+                <img class="inline" alt="" src="img/properties/<%= flag[1] %>.png"/>
+                <span class="inline"><%= flag[0] %></span>
+            </span>
+        <% }); %>
+        <%= propertyCount==0 ? 'none' : '' %>
     </dd>
 
     <dt><span class="tip" title="The first time that this relay was seen online.">First Seen</span></dt>
diff --git a/templates/details/router.html b/templates/details/router.html
index ef22d90..e646937 100644
--- a/templates/details/router.html
+++ b/templates/details/router.html
@@ -112,32 +112,15 @@
     
     <dt><span class="tip" title="Flags that have been generated by Relay Search to provide extra useful information. These flags do not appear in the directory consensus.">Additional Flags</span></dt>
     <dd>
-    <% var propertyCount = 0; %>
-    <% if (relay.get('recommended_version') === false) {
-        propertyCount++;
-        %>
-        <span class="tip flags" title="This relay is running a Tor version that is not recommended by the directory authorities and may contain known issues.">
-            <img class="inline" alt="" src="img/properties/not_recommended_16x16.png"/>
-            <span class="inline">Outdated Tor version</span>
-        </span>
-    <% } %>
-    <% if (relay.get('measured') === false) {
-        propertyCount++;
-        %>
-        <span class="tip flags" title="This relay has not been measured by at least 3 bandwidth authorities and so its consensus weight is currently capped. This is expected for new relays.">
-            <img class="inline" alt="" src="img/properties/unmeasured_16x16.png"/>
-            <span class="inline">Unmeasured</span>
-        </span>
-    <% } %>
-    <% if (relay.get('fallback_dir') === true) {
-        propertyCount++;
-        %>
-        <span class="tip flags" title="Tor clients contact fallback directory mirrors during bootstrap, and download the consensus and authority certificates from them. We include a default list of mirrors in the Tor source code. These default mirrors need to be long-term stable, and on the same IPv4 and IPv6 addresses and ports.">
-            <img class="inline" alt="" src="img/properties/fallbackdir_16x16.png"/>
-            <span class="inline">FallbackDir</span>
-        </span>
-    <% } %>
-    <%=propertyCount==0?'none':''%>
+    <dd>
+        <% var propertyCount = 0; %>
+        <% _.each(relay.get('additional_flags'), function(flag) { propertyCount++; %>
+            <span class="tip flags" title="<%= flag[2] %>">
+                <img class="inline" alt="" src="img/properties/<%= flag[1] %>.png"/>
+                <span class="inline"><%= flag[0] %></span>
+            </span>
+        <% }); %>
+        <%= propertyCount==0 ? 'none' : '' %>
     </dd>
 
     <dt><span class="tip" title="Host name as found in a reverse DNS lookup of the relay's primary IP address. This field is updated at most once in 12 hours, unless the relay IP address changes. Omitted if the relay IP address was not looked up, if no lookup request was successful yet or if no A record was found matching the PTR record.">Host Name</span></dt>
diff --git a/templates/search/do.html b/templates/search/do.html
index 1b24d21..fb32fdb 100644
--- a/templates/search/do.html
+++ b/templates/search/do.html
@@ -102,19 +102,7 @@
             <% _.each(relay.get('flags'), function(flag) { %><img class="tip flags" src="img/flags/<%= flag[1] %>.png" alt="<%= flag[0] %>" title="<%= flag[0] %><br /><%= flag[2] %>"/><% }); %>
             </td>
             <td>
-            <% if (relay.get('recommended_version') === false) { %>
-                <% if (relay.get('is_bridge')) { %>
-                <img class="tip" src="img/properties/not_recommended_16x16.png" alt="Outdated Tor version" title="Outdated Tor version<br />This bridge is running a Tor version that is not recommended by the directory authorities and may contain known issues."/>
-                <% } else { %>
-                <img class="tip" src="img/properties/not_recommended_16x16.png" alt="Outdated Tor version" title="Outdated Tor version<br />This relay is running a Tor version that is not recommended by the directory authorities and may contain known issues."/>
-                <% } %>
-            <% } %>
-           <% if (relay.get('measured') === false) { %>
-                <img class="tip" src="img/properties/unmeasured_16x16.png" alt="Unmeasured" title="Unmeasured<br />This relay has not been measured by at least 3 bandwidth authorities and so its consensus weight is currently capped. This is expected for new relays.">
-          <% } %>
-           <% if (relay.get('fallback_dir') === true) { %>
-                <img class="tip" src="img/properties/fallbackdir_16x16.png" alt="Unmeasured" title="FallbackDir<br />Tor clients contact fallback directory mirrors during bootstrap, and download the consensus and authority certificates from them. We include a default list of mirrors in the Tor source code. These default mirrors need to be long-term stable, and on the same IPv4 and IPv6 addresses and ports.">
-          <% } %>
+            <% _.each(relay.get('additional_flags'), function(flag) { %><img class="tip flags" src="img/properties/<%= flag[1] %>.png" alt="<%= flag[0] %>" title="<%= flag[0] %><br /><%= flag[2] %>"/><% }); %>
             </td>
 			<td><%= relay.get('or_port') %></td>
 			<td><%= relay.get('dir_port') %></td>



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