Fix #2171 : Add Peer dialog stops responding if empty or invalid values entered

This commit is contained in:
Calum Lind 2012-09-30 18:23:51 +01:00
parent 610cd7dd33
commit e5f56e2fdd
1 changed files with 12 additions and 11 deletions

View File

@ -386,16 +386,17 @@ class PeersTab(Tab):
response = peer_dialog.run()
if response:
value = txt_ip.get_text()
if ']' in value:
#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):
log.debug("adding peer %s to %s", value, self.torrent_id)
client.core.connect_peer(self.torrent_id, ip, port)
if value and ':' in value:
if ']' in value:
#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):
log.debug("adding peer %s to %s", value, self.torrent_id)
client.core.connect_peer(self.torrent_id, ip, port)
peer_dialog.destroy()
return True