[Pkg-privacy-commits] [onioncircuits] 01/01: Display circuit details when using bridges

Sascha Steinbiss sascha at steinbiss.name
Sun May 15 16:40:53 UTC 2016


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to tag list
in repository onioncircuits.

commit 488805160c373f2b5eeff87b3b8b5acd76f92861
Author: Alan <alan at boum.org>
Date:   Fri Apr 1 20:05:48 2016 +0200

    Display circuit details when using bridges
    
    When using a bridge, the first node in the path doesn't have a
    ServerDescriptor. We now handle this case gracefully.
---
 onioncircuits | 45 +++++++++++++++++++++++++++++++++------------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/onioncircuits b/onioncircuits
index 02858cc..76a2bef 100755
--- a/onioncircuits
+++ b/onioncircuits
@@ -536,14 +536,13 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
 
         self._path.show_all()
 
-    def display_node(self, status_entry):
-        """Display details for a node
+    def get_country(self, address):
+        """Returns the country in which address is in
 
-        :var stem.descriptor.router_status_entry.RouterStatusEntryMicroV3
-        status_entry: the status entry for the node
+        :var str address: an ip address
         """
         try:
-            country = self.controller.get_info("ip-to-country/%s" % status_entry.address)
+            country = self.controller.get_info("ip-to-country/%s" % address)
         except stem.ProtocolError:
             country = None
             if not self._geoip_message_shown:
@@ -560,12 +559,34 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
                 # If pycountry can't find the country, just display the string
                 # returned by Tor.
                 pass
+        return country
+
+    def display_node(self, fingerprint, nickname):
+        """Display details for a node
 
-        # if we couldn't get a country, just display the IP
-        if country:
+        :var string fingerprint: the fingerprint of the node
+
+        :var string nickname: the nickname of the node
+        """
+        try:
+            status_entry = self.controller.get_network_status(fingerprint)
+        except stem.DescriptorUnavailable:
+            status_entry = None
+
+        if status_entry:
+            country = self.get_country(status_entry.address)
+            if country:
+                ip_with_country = _("%s (%s)") % (status_entry.address, country)
+            else: # we couldn't get a country, just display the IP
+                ip_with_country = str(status_entry.address)
+
+            published = status_entry.published
             ip_with_country = _("%s (%s)") % (status_entry.address, country)
+            bandwidth = _("%.2f Mb/s") % (status_entry.bandwidth/1024.)
         else:
-            ip_with_country = str(status_entry.address)
+            published = _("Unknown")
+            ip_with_country = _("Unknown")
+            bandwidth = _("Unknown")
 
         grid = Gtk.Grid()
         grid.set_property('row-spacing', 6)
@@ -573,15 +594,15 @@ class OnionCircuitsWindow(Gtk.ApplicationWindow):
         grid.set_property('margin', 12)
 
         title = Gtk.Label()
-        title.set_markup("<b>%s</b>" % status_entry.nickname)
+        title.set_markup("<b>%s</b>" % nickname)
         title.set_halign(Gtk.Align.START)
         grid.attach(title, 0, 0, 2, 1)
 
         line = 1
-        for l, v in [(_("Fingerprint:"), status_entry.fingerprint),
-                     (_("Published:"), status_entry.published),
+        for l, v in [(_("Fingerprint:"), fingerprint),
+                     (_("Published:"), published),
                      (_("IP:"), ip_with_country),
-                     (_("Bandwidth:"), _("%.2f Mb/s") % (status_entry.bandwidth/1024.)),
+                     (_("Bandwidth:"), bandwidth),
                     ]:
             label = Gtk.Label(l)
             label.set_halign(Gtk.Align.START)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncircuits.git



More information about the Pkg-privacy-commits mailing list