From 7b2522438c8445ff188d43bf6bf4237e518281ee Mon Sep 17 00:00:00 2001 From: Vxrtrauter <101264710+Vxrtrauter@users.noreply.github.com> Date: Fri, 6 Feb 2026 23:50:18 +0100 Subject: [PATCH] feat: add network interface binding to settings dialog and update save_settings function --- core/interface/dialogs/settings.py | 43 ++++++++++++++++++++++++++++-- core/utils/config/settings.py | 4 ++- main.py | 4 +-- test.py | 35 ------------------------ 4 files changed, 46 insertions(+), 40 deletions(-) delete mode 100644 test.py diff --git a/core/interface/dialogs/settings.py b/core/interface/dialogs/settings.py index 4ff7e1c..b60d408 100644 --- a/core/interface/dialogs/settings.py +++ b/core/interface/dialogs/settings.py @@ -13,6 +13,7 @@ from PySide6.QtWidgets import ( QSpinBox, QCheckBox, QFileDialog, + QComboBox ) import platform @@ -56,7 +57,6 @@ def settings_dialog(self): autoresume_layout.addStretch() autoresume_checkbox.setChecked(state.autoresume) - autoresume_checkbox.toggled.connect(lambda checked: setattr(state, 'autoresume', checked)) autoresume_layout.addWidget(autoresume_checkbox) dialog.layout().addWidget(autoresume_container) @@ -206,6 +206,35 @@ def settings_dialog(self): max_downloads.setFixedHeight(30) dialog.layout().addWidget(max_downloads_container) + ##################### + # INTERFACE BINDING # + ##################### + + interface_container = QWidget() + interface_layout = QHBoxLayout() + + interface_label = QLabel("Network Interface:") + interface_layout.addWidget(interface_label) + interface_select = QComboBox() + interface_select.addItems(["None"] + state.interfaces) + + target = state.bound_interface if state.bound_interface else "None" + + index = interface_select.findText(target) + if index >= 0: + interface_select.setCurrentIndex(index) + else: + interface_select.setCurrentIndex(0) + + interface_select.setFixedWidth(180) + interface_select.setFixedHeight(30) + interface_select.setFixedWidth(180) + interface_select.setFixedHeight(30) + interface_layout.addWidget(interface_select) + interface_container.setLayout(interface_layout) + dialog.layout().addWidget(interface_container) + + ############### # SAVE/CANCEL # ############### @@ -214,7 +243,17 @@ def settings_dialog(self): save_btn = QPushButton("Save") cancel_btn = QPushButton("Cancel") - save_btn.clicked.connect(lambda: save_settings(close_settings, api_url.text(), download_path.text(), down_speed_limit.value(), up_speed_limit.value(), image_path.text(), None, max_connections.value(), max_downloads.value())) + save_btn.clicked.connect(lambda: save_settings( + close_settings, + api_url.text(), + download_path.text(), + down_speed_limit.value(), + up_speed_limit.value(), + image_path.text(), + autoresume_checkbox.isChecked(), + max_connections.value(), + max_downloads.value(), + interface_select.currentText())) cancel_btn.clicked.connect(dialog.reject) layout.addWidget(cancel_btn) diff --git a/core/utils/config/settings.py b/core/utils/config/settings.py index 1181b16..5550cd2 100644 --- a/core/utils/config/settings.py +++ b/core/utils/config/settings.py @@ -4,7 +4,7 @@ from core.utils.general.logs import consoleLog from .config import create_config -def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None): +def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None, bound_interface=None): if apiurl is not None: state.api_url = apiurl if download_path is not None: @@ -21,6 +21,8 @@ def save_settings(close=lambda: None, apiurl=None, download_path=None, down_spee state.max_connections = max_connections if max_downloads is not None: state.max_downloads = max_downloads + if bound_interface is not None: + state.bound_interface = None if bound_interface == "None" else bound_interface update_settings() diff --git a/main.py b/main.py index f6823c0..d5bd4b3 100644 --- a/main.py +++ b/main.py @@ -54,9 +54,9 @@ if __name__ == "__main__": init_interfaces() consoleLog(f"Current Bound: {state.bound_interface}") run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True)) - consoleLog("Started send_notification thread") + consoleLog("Started Thread: send_notification") run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True)) - consoleLog("Started update_log thread") + consoleLog("Started Thread: update_log") run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume))) consoleLog("Launching GUI") run_gui() diff --git a/test.py b/test.py deleted file mode 100644 index 5e40c63..0000000 --- a/test.py +++ /dev/null @@ -1,35 +0,0 @@ -import psutil - -addrs = psutil.net_if_addrs() -stats = psutil.net_if_stats() - - -def get_active_interfaces(): - active = [] - - for interface, addr_list in addrs.items(): - up = stats[interface].isup - for addr in addr_list: - if addr.family == 2: # ipv4 - ipv4 = addr.address - if not ipv4.startswith("127.") and not ipv4.startswith("169.254") and up == True: - print(f'"{interface}": True') - active.append(interface) - print(active) - return active - - - -print(list(addrs.keys())) - -# print(addrs) -# print() -# sigmer = list() - - - -# for interface in stats.keys(): -# print(f"{interface}: UP = {stats[interface].isup}") -# sigmer.append(f"{interface}: {stats[interface].isup}") - -# print(sigmer) \ No newline at end of file