From b84f3b67826063dfbaa01dea5bce9184d8f7b2d0 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Fri, 21 Feb 2025 12:01:46 +0300 Subject: [PATCH] feat: add get_proxy_label function to podkop init script --- .../luci-static/resources/view/podkop/podkop.js | 14 ++++++++++++++ podkop/files/etc/init.d/podkop | 14 +++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js index 7044ff5..5048098 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js @@ -35,6 +35,20 @@ function createConfigSection(section, map, network) { o.depends('proxy_config_type', 'url'); o.rows = 5; o.ucisection = s.section; + o.load = function (section_id) { + return fs.exec('/etc/init.d/podkop', ['get_proxy_label', section_id]).then(res => { + if (res.stdout) { + try { + const decodedLabel = decodeURIComponent(res.stdout.trim()); + this.description = _('Current config: ') + decodedLabel; + } catch (e) { + console.error('Error decoding label:', e); + this.description = _('Current config: ') + res.stdout.trim(); + } + } + return this.super('load', section_id); + }); + }; o.validate = function (section_id, value) { if (!value || value.length === 0) { return true; diff --git a/podkop/files/etc/init.d/podkop b/podkop/files/etc/init.d/podkop index 44ddbf5..a5584a1 100755 --- a/podkop/files/etc/init.d/podkop +++ b/podkop/files/etc/init.d/podkop @@ -7,7 +7,7 @@ script=$(readlink "$initscript") NAME="$(basename ${script:-$initscript})" config_load "$NAME" -EXTRA_COMMANDS="main list_update check_proxy check_nft check_github check_logs check_sing_box_connections check_sing_box_logs check_dnsmasq show_config show_version show_sing_box_config show_luci_version show_sing_box_version show_system_info get_status get_sing_box_status" +EXTRA_COMMANDS="main list_update check_proxy check_nft check_github check_logs check_sing_box_connections check_sing_box_logs check_dnsmasq show_config show_version show_sing_box_config show_luci_version show_sing_box_version show_system_info get_status get_sing_box_status get_proxy_label" EXTRA_HELP=" list_update Updating domain and subnet lists check_proxy Check if sing-box proxy works correctly check_nft Show PodkopTable nftables rules @@ -1836,6 +1836,18 @@ get_status() { echo "{\"running\":$running,\"enabled\":$enabled,\"status\":\"$status\"}" } +get_proxy_label() { + local section="$1" + local proxy_string + local label="" + + config_get proxy_string "$section" "proxy_string" + if [ -n "$proxy_string" ]; then + label=$(echo "$proxy_string" | sed -n 's/.*#\(.*\)$/\1/p') + echo "$label" + fi +} + sing_box_add_secure_dns_probe_domain() { local domain="httpbin.org" local override_address="numbersapi.com"