From ef1cf031f5e1187d1ac6316fd317fa618a58dd30 Mon Sep 17 00:00:00 2001 From: gitea-action Date: Sun, 23 Mar 2025 17:30:27 +0800 Subject: [PATCH] luci-app-nikki: sync upstream last commit: https://github.com/nikkinikki-org/OpenWrt-nikki/commit/277a7d97d9b95ee0132a045a0488d06994c58c52 --- .../htdocs/luci-static/resources/tools/nikki.js | 2 ++ .../htdocs/luci-static/resources/view/nikki/log.js | 4 ++-- .../root/usr/share/rpcd/acl.d/luci-app-nikki.json | 3 +-- luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki | 12 ++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js b/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js index a8e3d2f4c..0af6c5c14 100644 --- a/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js +++ b/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js @@ -62,6 +62,7 @@ const proxyProvidersDir = `${providersDir}/proxy`; const logDir = `/var/log/nikki`; const appLogPath = `${logDir}/app.log`; const coreLogPath = `${logDir}/core.log`; +const debugLogPath = `${logDir}/debug.log`; const nftDir = `${homeDir}/nftables`; const reservedIPNFT = `${nftDir}/reserved_ip.nft`; const reservedIP6NFT = `${nftDir}/reserved_ip6.nft`; @@ -76,6 +77,7 @@ return baseclass.extend({ runDir: runDir, appLogPath: appLogPath, coreLogPath: coreLogPath, + debugLogPath: debugLogPath, runProfilePath: runProfilePath, reservedIPNFT: reservedIPNFT, reservedIP6NFT: reservedIP6NFT, diff --git a/luci-app-nikki/htdocs/luci-static/resources/view/nikki/log.js b/luci-app-nikki/htdocs/luci-static/resources/view/nikki/log.js index 9bbf386bb..6d732a697 100644 --- a/luci-app-nikki/htdocs/luci-static/resources/view/nikki/log.js +++ b/luci-app-nikki/htdocs/luci-static/resources/view/nikki/log.js @@ -97,13 +97,13 @@ return view.extend({ o.inputtitle = _('Generate & Download'); o.onclick = function () { return nikki.debug().then(function () { - fs.read_direct('/var/run/nikki/debug.md', 'blob').then(function (data) { + fs.read_direct(nikki.debugLogPath, 'blob').then(function (data) { // create url const url = window.URL.createObjectURL(data, { type: 'text/markdown' }); // create link const link = document.createElement('a'); link.href = url; - link.download = 'debug.md'; + link.download = 'debug.log'; // append to body document.body.appendChild(link); // download diff --git a/luci-app-nikki/root/usr/share/rpcd/acl.d/luci-app-nikki.json b/luci-app-nikki/root/usr/share/rpcd/acl.d/luci-app-nikki.json index 4d566f3e9..580d08dd3 100644 --- a/luci-app-nikki/root/usr/share/rpcd/acl.d/luci-app-nikki.json +++ b/luci-app-nikki/root/usr/share/rpcd/acl.d/luci-app-nikki.json @@ -18,8 +18,7 @@ "/etc/nikki/run/providers/proxy/*": ["read"], "/etc/nikki/nftables/reserved_ip.nft": ["read"], "/etc/nikki/nftables/reserved_ip6.nft": ["read"], - "/var/log/nikki/*.log": ["read"], - "/var/run/nikki/debug.md": ["read"] + "/var/log/nikki/*.log": ["read"] } }, "write": { diff --git a/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki b/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki index 7f1b28cc2..bdf6063fd 100644 --- a/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki +++ b/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki @@ -12,20 +12,20 @@ const methods = { let app = ''; if (system('command -v opkg') == 0) { process = popen('opkg list-installed luci-app-nikki | cut -d " " -f 3'); - if (process != null) { + if (process) { app = trim(process.read('all')); process.close(); } } else if (system('command -v apk') == 0) { process = popen('apk list -I luci-app-nikki | cut -d " " -f 1 | cut -d "-" -f 4'); - if (process != null) { + if (process) { app = trim(process.read('all')); process.close(); } } let core = ''; process = popen('mihomo -v | grep Mihomo | cut -d " " -f 3'); - if (process != null) { + if (process) { core = trim(process.read('all')); process.close(); } @@ -38,8 +38,8 @@ const methods = { const filepath = '/etc/nikki/run/config.yaml'; if (access(filepath, 'r')) { const process = popen(`yq -p yaml -o json < ${filepath}`); - if (process != null) { - profile = json(process.read('all')); + if (process) { + profile = json(trim(process.read('all'))); process.close(); } } @@ -67,7 +67,7 @@ const methods = { }, debug: { call: function() { - const success = system('/etc/nikki/scripts/debug.sh > /var/run/nikki/debug.md') == 0; + const success = system('/etc/nikki/scripts/debug.sh > /var/log/nikki/debug.log') == 0; return { success: success }; } }