[#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.
This commit is contained in:
Calum Lind 2014-02-18 19:23:55 +00:00
parent d04af1e392
commit 29d3e72f49
2 changed files with 8 additions and 3 deletions

View file

@ -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"""

View file

@ -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()