Fix #1232: Improve display of Peers Tab IPv6 addresses
This commit is contained in:
parent
a79520e3ee
commit
420447e386
|
@ -226,7 +226,13 @@ class Command(BaseCommand):
|
||||||
s += "%sPeer\t{!input!}" % colors.state_color["Downloading"]
|
s += "%sPeer\t{!input!}" % colors.state_color["Downloading"]
|
||||||
|
|
||||||
s += peer["country"] + "\t"
|
s += peer["country"] + "\t"
|
||||||
s += peer["ip"]
|
|
||||||
|
if peer["ip"].count(":") == 1:
|
||||||
|
# IPv4
|
||||||
|
s += peer["ip"]
|
||||||
|
else:
|
||||||
|
# IPv6
|
||||||
|
s += "[%s]:%s" % (":".join(peer["ip"].split(":")[:-1]), peer["ip"].split(":")[-1])
|
||||||
|
|
||||||
c = peer["client"]
|
c = peer["client"]
|
||||||
s += "\t" + c
|
s += "\t" + c
|
||||||
|
|
|
@ -317,6 +317,7 @@ class PeersTab(Tab):
|
||||||
# This is an IPv4 address
|
# This is an IPv4 address
|
||||||
ip_int = sum([int(byte) << shift
|
ip_int = sum([int(byte) << shift
|
||||||
for byte, shift in izip(peer["ip"].split(":")[0].split("."), (24, 16, 8, 0))])
|
for byte, shift in izip(peer["ip"].split(":")[0].split("."), (24, 16, 8, 0))])
|
||||||
|
peer_ip = peer["ip"]
|
||||||
else:
|
else:
|
||||||
# This is an IPv6 address
|
# This is an IPv6 address
|
||||||
import socket
|
import socket
|
||||||
|
@ -324,6 +325,7 @@ class PeersTab(Tab):
|
||||||
# Split out the :port
|
# Split out the :port
|
||||||
ip = ":".join(peer["ip"].split(":")[:-1])
|
ip = ":".join(peer["ip"].split(":")[:-1])
|
||||||
ip_int = long(binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16)
|
ip_int = long(binascii.hexlify(socket.inet_pton(socket.AF_INET6, ip)), 16)
|
||||||
|
peer_ip = "[%s]:%s" % (ip, peer["ip"].split(":")[-1])
|
||||||
|
|
||||||
if peer["seed"]:
|
if peer["seed"]:
|
||||||
icon = self.seed_pixbuf
|
icon = self.seed_pixbuf
|
||||||
|
@ -332,7 +334,7 @@ class PeersTab(Tab):
|
||||||
|
|
||||||
row = self.liststore.append([
|
row = self.liststore.append([
|
||||||
self.get_flag_pixbuf(peer["country"]),
|
self.get_flag_pixbuf(peer["country"]),
|
||||||
peer["ip"],
|
peer_ip,
|
||||||
peer["client"],
|
peer["client"],
|
||||||
peer["down_speed"],
|
peer["down_speed"],
|
||||||
peer["up_speed"],
|
peer["up_speed"],
|
||||||
|
|
|
@ -38,7 +38,12 @@
|
||||||
return String.format('<img src="flag/{0}" />', value);
|
return String.format('<img src="flag/{0}" />', value);
|
||||||
}
|
}
|
||||||
function peerAddressRenderer(value, p, record) {
|
function peerAddressRenderer(value, p, record) {
|
||||||
var seed = (record.data['seed'] == 1024) ? 'x-deluge-seed' : 'x-deluge-peer'
|
var seed = (record.data['seed'] == 1024) ? 'x-deluge-seed' : 'x-deluge-peer';
|
||||||
|
if (peer_ip.length > 2) {
|
||||||
|
var port = peer_ip.pop();
|
||||||
|
var ip = peer_ip.join(":");
|
||||||
|
value = "[" + ip + "]:" + port;
|
||||||
|
}
|
||||||
return String.format('<div class="{0}">{1}</div>', seed, value);
|
return String.format('<div class="{0}">{1}</div>', seed, value);
|
||||||
}
|
}
|
||||||
function peerProgressRenderer(value) {
|
function peerProgressRenderer(value) {
|
||||||
|
|
Loading…
Reference in New Issue