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 self._old_outgoing_interface = None
if outgoing_interface: if outgoing_interface:
if not deluge.common.is_ip(outgoing_interface): self._old_outgoing_interface = self.config['outgoing_interface']
self._old_outgoing_interface = self.config['outgoing_interface'] self.config['outgoing_interface'] = outgoing_interface
self.config['outgoing_interface'] = outgoing_interface
else:
log.error(
'Invalid outgoing interface (must be adapter name): %s',
outgoing_interface,
)
# New release check information # New release check information
self.__new_release = None self.__new_release = None

View File

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

View File

@ -49,10 +49,12 @@ def add_daemon_options(parser):
group.add_argument( group.add_argument(
'-o', '-o',
'--outgoing-interface', '--outgoing-interface',
metavar='<adapter-name>', metavar='<interface>',
dest='outgoing_interface', dest='outgoing_interface',
action='store', 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( group.add_argument(
'--read-only-config-keys', '--read-only-config-keys',

View File

@ -194,10 +194,8 @@ class PreferencesManager(component.Component):
self.__set_listen_on() self.__set_listen_on()
def _on_set_outgoing_interface(self, key, value): def _on_set_outgoing_interface(self, key, value):
""" Set the adapter name for outgoing BitTorrent connections.""" """Set interface name or IP address for outgoing BitTorrent connections."""
if not value or deluge.common.is_ip(value): value = value.strip() if value else ''
value = ''
value = value.strip()
self.core.apply_session_settings({'outgoing_interfaces': value}) self.core.apply_session_settings({'outgoing_interfaces': value})
def _on_set_random_port(self, key, 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 conf_dict['listen_interface'] = listen_interface
elif ipt.name == 'outgoing_interface': elif ipt.name == 'outgoing_interface':
outgoing_interface = ipt.get_value().strip() 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_'): elif ipt.name.startswith('proxy_'):
if ipt.name == 'proxy_type': if ipt.name == 'proxy_type':
conf_dict.setdefault('proxy', {})['type'] = ipt.get_value() conf_dict.setdefault('proxy', {})['type'] = ipt.get_value()
@ -361,7 +360,8 @@ class NetworkPane(BasePreferencePane):
self.add_text_input( self.add_text_input(
'outgoing_interface', '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'], core_conf['outgoing_interface'],
) )

View File

@ -2925,7 +2925,7 @@ used sparingly.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes"> <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>
<property name="max_length">15</property> <property name="max_length">15</property>
<property name="invisible_char">●</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() incoming_address = self.builder.get_object('entry_interface').get_text().strip()
if deluge.common.is_ip(incoming_address) or not incoming_address: if deluge.common.is_ip(incoming_address) or not incoming_address:
new_core_config['listen_interface'] = 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() 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( new_core_config['peer_tos'] = self.builder.get_object(
'entry_peer_tos' 'entry_peer_tos'
).get_text() ).get_text()