From c765616b1b03e2285c2a63af4326542f28e4c53b Mon Sep 17 00:00:00 2001 From: Aidaho Date: Sat, 26 Apr 2025 22:33:15 +0300 Subject: [PATCH] v8.1.8: Remove unused code and improve variable naming. Removed the obsolete `Reconfigure` function from UDP.js and cleaned up unused parameters in config.py. Enhanced logging by simplifying error messages in auth.py and clarified variable naming for HA routes. These changes improve readability and maintainability. --- app/modules/config/config.py | 2 +- app/modules/roxywi/auth.py | 2 +- app/routes/ha/routes.py | 4 ++-- app/static/js/udp.js | 18 +----------------- app/templates/udp/listener.html | 2 +- 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/app/modules/config/config.py b/app/modules/config/config.py index ba41611a..819b21db 100644 --- a/app/modules/config/config.py +++ b/app/modules/config/config.py @@ -159,7 +159,6 @@ def _create_config_version(server_id: int, server_ip: str, service: str, config_ :param server_ip: The IP address of the server. :param service: The service name. :param config_path: The path to the configuration file. - :param login: The login of the user. :param cfg: The new configuration string. :param old_cfg: The path to the old configuration file. :param tmp_file: A temporary file name. @@ -442,6 +441,7 @@ def show_config(server_ip: str, service: str, config_file_name: str, configver: """ Get and display the configuration file for a given server. + :param edit_section: :param claims: :param server_ip: The IP address of the server. :param service: The name of the service. diff --git a/app/modules/roxywi/auth.py b/app/modules/roxywi/auth.py index 0ab6dd09..34031937 100644 --- a/app/modules/roxywi/auth.py +++ b/app/modules/roxywi/auth.py @@ -124,7 +124,7 @@ def check_user_password(login: str, password: str) -> dict: try: user = user_sql.get_user_by_username(login) except Exception as e: - roxywi_common.logging('Roxy-WI server', f'error: Cannot login user {e}', roxywi=1) + roxywi_common.logging('Roxy-WI server', f'error: Cannot login user {e}') raise Exception('ban') if user.enabled == 0: raise Exception('Your login is disabled') diff --git a/app/routes/ha/routes.py b/app/routes/ha/routes.py index 77a1296a..8b235cce 100644 --- a/app/routes/ha/routes.py +++ b/app/routes/ha/routes.py @@ -165,8 +165,8 @@ def check_cluster_status(service: str, cluster_id: int): statuses = [] cmd = f'systemctl is-active keepalived.service' for slave in slaves: - status = server_mod.ssh_command(slave[2], cmd) - statuses.append(status.replace('\n', '').replace('\r', '')) + output = server_mod.ssh_command(slave[2], cmd) + statuses.append(output.replace('\n', '').replace('\r', '')) if 'inactive' in statuses and 'active' in statuses: status = 'warning' elif 'inactive' in statuses and 'active' not in statuses: diff --git a/app/static/js/udp.js b/app/static/js/udp.js index c9ca485d..68d454ed 100644 --- a/app/static/js/udp.js +++ b/app/static/js/udp.js @@ -377,22 +377,6 @@ function saveUdpListener(jsonData, dialog_id, listener_id=0, edited=0, reconfigu } }); } -function Reconfigure(listener_id) { - return $.ajax({ - url: "/install/udp", - data: JSON.stringify({listener_id: listener_id}), - contentType: "application/json; charset=utf-8", - async: false, - type: "POST", - success: function (data) { - if (data.status === 'failed') { - toastr.error(data.error); - } else { - parseAnsibleJsonOutput(data, 'UDP listener', ''); - } - } - }); -} function getUDPListener(listener_id, new_listener=false) { $.ajax({ url: "/udp/listener/" + listener_id, @@ -610,7 +594,7 @@ function checkUdpBackendStatus(listener_id, backend_ip) { toastr.error(data.error); return false; } else { - let server_div = $('#backend_server_status_' + backend_ip.replaceAll('.', '')); + let server_div = $('#backend_server_status_' +listener_id+ '_' + backend_ip.replaceAll('.', '')); if (data.data === 'yes') { server_div.removeClass('serverNone'); server_div.removeClass('serverDown'); diff --git a/app/templates/udp/listener.html b/app/templates/udp/listener.html index 19977808..1f54c007 100644 --- a/app/templates/udp/listener.html +++ b/app/templates/udp/listener.html @@ -41,7 +41,7 @@ {% set config = listener.config|string_to_dict %} {% for c in config %}
- + {{ lang.words.server|title() }}: {{ copy_to_clipboard(value=c.backend_ip) }}, {{ lang.words.port }}: {{ c.port }}, {{ lang.words.weight }}: {{ c.weight }}