diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2014-02-18 19:23:55 +0000 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2014-02-18 19:34:31 +0000 |
commit | 29d3e72f49a64cb2f355438995c871645ba443d9 (patch) | |
tree | 81f8d2fdd11a993c6d70fa09c4fe59c7a30b0c56 | |
parent | d04af1e3926baeba55104bc8fc588c1bbdb9273b (diff) | |
download | deluge-29d3e72f49a64cb2f355438995c871645ba443d9.tar.gz deluge-29d3e72f49a64cb2f355438995c871645ba443d9.tar.bz2 deluge-29d3e72f49a64cb2f355438995c871645ba443d9.zip |
[#2082] Validate ip address for listen_interface entry
This ensures that only ip addresses are accepted for
listen_interface as libtorrent cannot accept interface
names (eth0) and will cause unexpected results for user.
-rw-r--r-- | deluge/core/core.py | 7 | ||||
-rw-r--r-- | deluge/ui/gtkui/preferences.py | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/deluge/core/core.py b/deluge/core/core.py index 1ca6f92d8..a73bb6485 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -134,8 +134,11 @@ class Core(component.Component): # store the one in the config so we can restore it on shutdown self.__old_interface = None if listen_interface: - self.__old_interface = self.config["listen_interface"] - self.config["listen_interface"] = listen_interface + if deluge.common.is_ip(listen_interface): + self.__old_interface = self.config["listen_interface"] + self.config["listen_interface"] = listen_interface + else: + log.error("Invalid listen interface (must be IP Address): %s", listen_interface) def start(self): """Starts the core""" diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 52feb5555..149208de1 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -586,7 +586,9 @@ class Preferences(component.Component): new_core_config["outgoing_ports"] = outgoing_ports new_core_config["random_outgoing_ports"] = \ self.glade.get_widget("chk_random_outgoing_ports").get_active() - new_core_config["listen_interface"] = self.glade.get_widget("entry_interface").get_text() + incoming_address = self.glade.get_widget("entry_interface").get_text().strip() + if deluge.common.is_ip(incoming_address) or not incoming_address: + new_core_config["listen_interface"] = incoming_address new_core_config["peer_tos"] = self.glade.get_widget("entry_peer_tos").get_text() new_core_config["dht"] = self.glade.get_widget("chk_dht").get_active() new_core_config["upnp"] = self.glade.get_widget("chk_upnp").get_active() |