summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Resch <andrewresch@gmail.com>2009-04-13 18:02:49 +0000
committerAndrew Resch <andrewresch@gmail.com>2009-04-13 18:02:49 +0000
commitd742f394f007d813f050fcf41c9aaf4a3b2d20c5 (patch)
tree69ff4bdee08edb8b4e0fc0ffc331dd21d6c07812
parent1693bc7373de005bbd2ed7385ff30fdcee00df3e (diff)
downloaddeluge-d742f394f007d813f050fcf41c9aaf4a3b2d20c5.tar.gz
deluge-d742f394f007d813f050fcf41c9aaf4a3b2d20c5.tar.bz2
deluge-d742f394f007d813f050fcf41c9aaf4a3b2d20c5.zip
Fix displaying IPv6 peers in the Peers tab
-rw-r--r--ChangeLog1
-rw-r--r--deluge/ui/gtkui/peers_tab.py17
2 files changed, 14 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index cc2a0eb55..9da422650 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
==== GtkUI ====
* Fix #883 segfault if locale is not using UTF-8 encoding
* Fix for adding torrents with invalid filename encodings
+ * Fix displaying IPv6 peers in the Peers tab
=== Deluge 1.1.6 - (06 April 2009) ===
==== Core ====
diff --git a/deluge/ui/gtkui/peers_tab.py b/deluge/ui/gtkui/peers_tab.py
index 230717cba..cd07e978c 100644
--- a/deluge/ui/gtkui/peers_tab.py
+++ b/deluge/ui/gtkui/peers_tab.py
@@ -73,7 +73,7 @@ class PeersTab(Tab):
self.listview = glade.get_widget("peers_listview")
self.listview.connect("button-press-event", self._on_button_press_event)
# country pixbuf, ip, client, downspeed, upspeed, country code, int_ip, seed/peer icon, progress
- self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, int, int, str, gobject.TYPE_UINT, gtk.gdk.Pixbuf, float)
+ self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str, int, int, str, float, gtk.gdk.Pixbuf, float)
self.cached_flag_pixbufs = {}
self.seed_pixbuf = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("seeding16.png"))
@@ -308,8 +308,17 @@ class PeersTab(Tab):
# Peer is not in list so we need to add it
# Create an int IP address for sorting purposes
- ip_int = sum([int(byte) << shift
- for byte, shift in izip(peer["ip"].split(":")[0].split("."), (24, 16, 8, 0))])
+ if peer["ip"].count(":") == 1:
+ # This is an IPv4 address
+ ip_int = sum([int(byte) << shift
+ for byte, shift in izip(peer["ip"].split(":")[0].split("."), (24, 16, 8, 0))])
+ else:
+ # This is an IPv6 address
+ import socket
+ import binascii
+ # Split out the :port
+ ip = ":".join(peer["ip"].split(":")[:-1])
+ ip_int = long(binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16)
if peer["seed"]:
icon = self.seed_pixbuf
@@ -323,7 +332,7 @@ class PeersTab(Tab):
peer["down_speed"],
peer["up_speed"],
peer["country"],
- ip_int,
+ float(ip_int),
icon,
peer["progress"]])