account for ipv6 brackets [ip:ip:ip]:port

This commit is contained in:
Marcos Pinto 2008-10-18 04:48:38 +00:00
parent 37618e4a13
commit 219be3f440
1 changed files with 8 additions and 2 deletions

View File

@ -154,8 +154,14 @@ def add_peer_dialog():
response = peer_dialog.run() response = peer_dialog.run()
if response: if response:
value = txt_ip.get_text() value = txt_ip.get_text()
ip = value.split(":")[0] if ']' in value:
port = value.split(":")[1] #ipv6
ip = value.split("]")[0][1:]
port = value.split("]")[1][1:]
else:
#ipv4
ip = value.split(":")[0]
port = value.split(":")[1]
if deluge.common.is_ip(ip): if deluge.common.is_ip(ip):
id = component.get("TorrentView").get_selected_torrent() id = component.get("TorrentView").get_selected_torrent()
log.debug("adding peer %s to %s", value, id) log.debug("adding peer %s to %s", value, id)