mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
[#2786] [GTKUI] Fix showing connection manager with malformed ip
This commit is contained in:
parent
dd08cb29e5
commit
08c03d7678
2 changed files with 20 additions and 4 deletions
|
@ -39,7 +39,7 @@ import urlparse
|
||||||
import time
|
import time
|
||||||
import hashlib
|
import hashlib
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from socket import gethostbyname
|
from socket import gaierror, gethostbyname
|
||||||
|
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -204,6 +204,11 @@ class ConnectionManager(component.Component):
|
||||||
if [entry[HOSTLIST_COL_HOST], entry[HOSTLIST_COL_PORT], entry[HOSTLIST_COL_USER]] == [host, port, username]:
|
if [entry[HOSTLIST_COL_HOST], entry[HOSTLIST_COL_PORT], entry[HOSTLIST_COL_USER]] == [host, port, username]:
|
||||||
raise Exception("Host already in list!")
|
raise Exception("Host already in list!")
|
||||||
|
|
||||||
|
try:
|
||||||
|
gethostbyname(host)
|
||||||
|
except gaierror as ex:
|
||||||
|
raise Exception("Host '%s': %s" % (host, ex.args[1]))
|
||||||
|
|
||||||
# Host isn't in the list, so lets add it
|
# Host isn't in the list, so lets add it
|
||||||
row = self.liststore.append()
|
row = self.liststore.append()
|
||||||
import time
|
import time
|
||||||
|
@ -304,8 +309,14 @@ class ConnectionManager(component.Component):
|
||||||
user = row[HOSTLIST_COL_USER]
|
user = row[HOSTLIST_COL_USER]
|
||||||
password = row[HOSTLIST_COL_PASS]
|
password = row[HOSTLIST_COL_PASS]
|
||||||
|
|
||||||
|
try:
|
||||||
|
ip = gethostbyname(host)
|
||||||
|
except gaierror as ex:
|
||||||
|
log.error("Error resolving host %s to ip: %s", host, ex.args[1])
|
||||||
|
continue
|
||||||
|
|
||||||
if client.connected() and (
|
if client.connected() and (
|
||||||
gethostbyname(host),
|
ip,
|
||||||
port,
|
port,
|
||||||
"localclient" if not user and host in ("127.0.0.1", "localhost") else user
|
"localclient" if not user and host in ("127.0.0.1", "localhost") else user
|
||||||
) == client.connection_info():
|
) == client.connection_info():
|
||||||
|
@ -510,8 +521,7 @@ that you forgot to install the deluged package or it's not in your PATH.")).run(
|
||||||
try:
|
try:
|
||||||
self.add_host(hostname, port_spinbutton.get_value_as_int(), username, password)
|
self.add_host(hostname, port_spinbutton.get_value_as_int(), username, password)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
from deluge.ui.gtkui.dialogs import ErrorDialog
|
dialogs.ErrorDialog(_("Error Adding Host"), e, parent=dialog).run()
|
||||||
ErrorDialog(_("Error Adding Host"), e).run()
|
|
||||||
|
|
||||||
username_entry.set_text("")
|
username_entry.set_text("")
|
||||||
password_entry.set_text("")
|
password_entry.set_text("")
|
||||||
|
|
|
@ -42,6 +42,7 @@ import shutil
|
||||||
import logging
|
import logging
|
||||||
import hashlib
|
import hashlib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from socket import gaierror, gethostbyname
|
||||||
from urlparse import urljoin
|
from urlparse import urljoin
|
||||||
from urllib import unquote_plus
|
from urllib import unquote_plus
|
||||||
|
|
||||||
|
@ -916,6 +917,11 @@ class WebApi(JSONComponent):
|
||||||
if (entry[0], entry[1], entry[2]) == (host, port, username):
|
if (entry[0], entry[1], entry[2]) == (host, port, username):
|
||||||
return (False, "Host already in the list")
|
return (False, "Host already in the list")
|
||||||
|
|
||||||
|
try:
|
||||||
|
gethostbyname(host)
|
||||||
|
except gaierror as ex:
|
||||||
|
return (False, "Hostname error: %s" % ex.args[1])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
port = int(port)
|
port = int(port)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue