diff options
author | Calum Lind <calumlind@gmail.com> | 2018-06-02 19:03:12 +0100 |
---|---|---|
committer | Calum Lind <calumlind@gmail.com> | 2018-06-02 21:32:56 +0100 |
commit | 21b5a15e5df0f4aefd37d7f2a6c46b72e4c652aa (patch) | |
tree | 19ae236dc4fa636beb3f84455d3e8da7cc2b5f2f /deluge/core/core.py | |
parent | edd431a304e9053d46c7a61261efefa0b9dd17a4 (diff) | |
download | deluge-21b5a15e5df0f4aefd37d7f2a6c46b72e4c652aa.tar.gz deluge-21b5a15e5df0f4aefd37d7f2a6c46b72e4c652aa.tar.bz2 deluge-21b5a15e5df0f4aefd37d7f2a6c46b72e4c652aa.zip |
Fix and cleanup outgoing interface code
There was a misunderstand about outgoing interface setting in libtorrent
and instead of being able to take both IP and adapater names, it only
accepts adapter names and errors with an IP address, which was the
default of '0.0.0.0' in code.
This fixes the code to not accept IP address and use empty string if it
is given one.
Also includes a bit of code cleanup.
Diffstat (limited to 'deluge/core/core.py')
-rw-r--r-- | deluge/core/core.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/deluge/core/core.py b/deluge/core/core.py index 80c14f6a2..db20f6d29 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -157,20 +157,24 @@ class Core(component.Component): # If there was an interface value from the command line, use it, but # store the one in the config so we can restore it on shutdown - self.__old_interface = None + self._old_listen_interface = None if listen_interface: if deluge.common.is_ip(listen_interface): - self.__old_interface = self.config['listen_interface'] + self._old_listen_interface = self.config['listen_interface'] self.config['listen_interface'] = listen_interface else: log.error('Invalid listen interface (must be IP Address): %s', listen_interface) - self.__old_outgoing_interface = None + + self._old_outgoing_interface = None if outgoing_interface: - if deluge.common.is_ip(outgoing_interface): - self.__old_outgoing_interface = self.config['outgoing_interface'] + if not deluge.common.is_ip(outgoing_interface): + self._old_outgoing_interface = self.config['outgoing_interface'] self.config['outgoing_interface'] = outgoing_interface else: - log.error('Invalid outgoing interface (must be IP Address): %s', outgoing_interface) + log.error( + 'Invalid outgoing interface (must be adapter name): %s', + outgoing_interface, + ) # New release check information self.__new_release = None @@ -202,11 +206,11 @@ class Core(component.Component): self._save_session_state() # We stored a copy of the old interface value - if self.__old_interface: - self.config['listen_interface'] = self.__old_interface + if self._old_listen_interface is None: + self.config['listen_interface'] = self._old_listen_interface - if self.__old_outgoing_interface: - self.config['outgoing_interface'] = self.__old_outgoing_interface + if self._old_outgoing_interface is None: + self.config['outgoing_interface'] = self._old_outgoing_interface # Make sure the config file has been saved self.config.save() |