Cleanup outgoing_interface code and help text

- Remove is_ip check as libtorrent does accept IP address for this setting.
  See: https://github.com/arvidn/libtorrent/issues/3087
- Use consistent wording for help text.
This commit is contained in:
Calum Lind 2018-10-03 21:30:38 +01:00
parent 970fad7557
commit c415b097fe
7 changed files with 25 additions and 29 deletions

View File

@ -184,14 +184,8 @@ class Core(component.Component):
self._old_outgoing_interface = None
if 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 adapter name): %s',
outgoing_interface,
)
self._old_outgoing_interface = self.config['outgoing_interface']
self.config['outgoing_interface'] = outgoing_interface
# New release check information
self.__new_release = None

View File

@ -76,14 +76,18 @@ class Daemon(object):
):
"""
Args:
listen_interface (str, optional): The IP address to listen to bittorrent connections on.
outgoing_interface (str, optional): The IP address to open outgoing BitTorrent connections on.
interface (str, optional): Adapter name the daemon will listen for UI connections on.
port (int, optional): The port the daemon will listen for UI connections on.
standalone (bool, optional): If True the client is in Standalone mode otherwise, if
False, start the daemon as separate process.
read_only_config_keys (list of str, optional): A list of config keys that will not be
altered by core.set_config() RPC method.
listen_interface (str, optional): The IP address to listen to
BitTorrent connections on.
outgoing_interface (str, optional): The network interface name or
IP address to open outgoing BitTorrent connections on.
interface (str, optional): The IP address the daemon will
listen for UI connections on.
port (int, optional): The port the daemon will listen for UI
connections on.
standalone (bool, optional): If True the client is in Standalone
mode otherwise, if False, start the daemon as separate process.
read_only_config_keys (list of str, optional): A list of config
keys that will not be altered by core.set_config() RPC method.
"""
self.standalone = standalone
self.pid_file = get_config_dir('deluged.pid')

View File

@ -49,10 +49,12 @@ def add_daemon_options(parser):
group.add_argument(
'-o',
'--outgoing-interface',
metavar='<adapter-name>',
metavar='<interface>',
dest='outgoing_interface',
action='store',
help=_('The interface adapter name for outgoing BitTorrent connections.'),
help=_(
'The network interface name or IP address for outgoing BitTorrent connections.'
),
)
group.add_argument(
'--read-only-config-keys',

View File

@ -194,10 +194,8 @@ class PreferencesManager(component.Component):
self.__set_listen_on()
def _on_set_outgoing_interface(self, key, value):
""" Set the adapter name for outgoing BitTorrent connections."""
if not value or deluge.common.is_ip(value):
value = ''
value = value.strip()
"""Set interface name or IP address for outgoing BitTorrent connections."""
value = value.strip() if value else ''
self.core.apply_session_settings({'outgoing_interfaces': value})
def _on_set_random_port(self, key, value):

View File

@ -97,8 +97,7 @@ class BasePreferencePane(BaseInputPane, BaseWindow, PopupsHandler):
conf_dict['listen_interface'] = listen_interface
elif ipt.name == 'outgoing_interface':
outgoing_interface = ipt.get_value().strip()
if not is_ip(outgoing_interface) or not outgoing_interface:
conf_dict['outgoing_interface'] = outgoing_interface
conf_dict['outgoing_interface'] = outgoing_interface
elif ipt.name.startswith('proxy_'):
if ipt.name == 'proxy_type':
conf_dict.setdefault('proxy', {})['type'] = ipt.get_value()
@ -361,7 +360,8 @@ class NetworkPane(BasePreferencePane):
self.add_text_input(
'outgoing_interface',
_(
'The interface adapter name for outgoing BitTorrent connections. (Leave empty for default.):'
'The network interface name or IP address for outgoing '
'BitTorrent connections. (Leave empty for default.):'
),
core_conf['outgoing_interface'],
)

View File

@ -2925,7 +2925,7 @@ used sparingly.</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">
The interface adapter name for outgoing BitTorrent connections. (Leave empty for default.)
The network interface name or IP address for outgoing BitTorrent connections. (Leave empty for default.)
</property>
<property name="max_length">15</property>
<property name="invisible_char">●</property>

View File

@ -680,11 +680,9 @@ class Preferences(component.Component):
incoming_address = self.builder.get_object('entry_interface').get_text().strip()
if deluge.common.is_ip(incoming_address) or not incoming_address:
new_core_config['listen_interface'] = incoming_address
outgoing_interface = (
new_core_config['outgoing_interface'] = (
self.builder.get_object('entry_outgoing_interface').get_text().strip()
)
if not deluge.common.is_ip(outgoing_interface) or not outgoing_interface:
new_core_config['outgoing_interface'] = outgoing_interface
new_core_config['peer_tos'] = self.builder.get_object(
'entry_peer_tos'
).get_text()