Skip to content

Commit

Permalink
[UI][core] Fix interface not being updated in thinclient
Browse files Browse the repository at this point in the history
When changing the interface in both `GTK` and `ConsoleUI`, we call
directly to `deluge.common.is_interface`, which checks the interface on
the local machine and not on the daemon's machine.

The `WebUI` does not seem to have any validation on input.

closes: https://dev.deluge-torrent.org/ticket/3540
  • Loading branch information
DjLegolas committed Jun 3, 2023
1 parent a9044df commit 5eda643
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions deluge/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,11 @@ def set_config(self, config: Dict[str, Any]):
continue
self.config[key] = config[key]

@export
def is_valid_interface(self, interface: str) -> bool:
"""Returns True is valid interface"""
return deluge.common.is_interface(interface)

@export
def get_listen_port(self) -> int:
"""Returns the active listen port"""
Expand Down
13 changes: 10 additions & 3 deletions deluge/ui/console/modes/preferences/preference_panes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import logging

from deluge.common import is_interface
from deluge.decorators import overrides
from deluge.i18n import get_languages
from deluge.ui.client import client
Expand Down Expand Up @@ -91,11 +90,19 @@ def add_config_values(self, conf_dict):
)
elif ipt.name == 'listen_interface':
listen_interface = ipt.get_value().strip()
if is_interface(listen_interface) or not listen_interface:
if (
client.is_daemon_version_equal_or_greater('2.1.1')
and client.core.is_valid_interface(listen_interface)
or not listen_interface
):
conf_dict['listen_interface'] = listen_interface
elif ipt.name == 'outgoing_interface':
outgoing_interface = ipt.get_value().strip()
if is_interface(outgoing_interface) or not outgoing_interface:
if (
client.is_daemon_version_equal_or_greater('2.1.1')
and client.core.is_valid_interface(outgoing_interface)
or not outgoing_interface
):
conf_dict['outgoing_interface'] = outgoing_interface
elif ipt.name.startswith('proxy_'):
if ipt.name == 'proxy_type':
Expand Down
16 changes: 11 additions & 5 deletions deluge/ui/gtk3/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,15 +676,21 @@ def set_config(self, hide=False):
'chk_random_outgoing_ports'
).get_active()
incoming_address = self.builder.get_object('entry_interface').get_text().strip()
if deluge.common.is_interface(incoming_address) or not incoming_address:
if (
client.is_daemon_version_equal_or_greater('2.1.1')
and client.core.is_valid_interface(incoming_address)
or not incoming_address
):
new_core_config['listen_interface'] = incoming_address
outgoing_address = (
self.builder.get_object('entry_outgoing_interface').get_text().strip()
)
if deluge.common.is_interface(outgoing_address) or not outgoing_address:
new_core_config['outgoing_interface'] = (
self.builder.get_object('entry_outgoing_interface').get_text().strip()
)
if (
client.is_daemon_version_equal_or_greater('2.1.1')
and client.core.is_valid_interface(outgoing_address)
or not outgoing_address
):
new_core_config['outgoing_interface'] = outgoing_address
new_core_config['peer_tos'] = self.builder.get_object(
'entry_peer_tos'
).get_text()
Expand Down
2 changes: 1 addition & 1 deletion deluge/ui/web/js/deluge-all/preferences/NetworkPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
fieldset = this.add({
xtype: 'fieldset',
border: false,
title: _('Incoming Address'),
title: _('Incoming Interface'),
style: 'margin-bottom: 5px; padding-bottom: 0px;',
autoHeight: true,
labelWidth: 1,
Expand Down

0 comments on commit 5eda643

Please sign in to comment.