From e31f33a58639eec07752ad569572fceb1fe9183e Mon Sep 17 00:00:00 2001 From: gitea-action Date: Sat, 15 Mar 2025 01:00:27 +0800 Subject: [PATCH] luci-app-nikki: sync upstream last commit: https://github.com/nikkinikki-org/OpenWrt-nikki/commit/a73c3678e8ec5419de69f55ba3a4f5134b55781f --- .../luci-static/resources/tools/nikki.js | 22 +++++++++---------- .../luci-static/resources/view/nikki/proxy.js | 15 +++++++++---- luci-app-nikki/po/templates/nikki.pot | 20 ++++++++++------- luci-app-nikki/po/zh_Hans/nikki.po | 20 ++++++++++------- .../root/etc/uci-defaults/40_luci-nikki | 4 ---- .../usr/share/rpcd/acl.d/luci-app-nikki.json | 2 -- .../root/usr/share/rpcd/ucode/luci.nikki | 9 ++++++++ 7 files changed, 54 insertions(+), 38 deletions(-) delete mode 100644 luci-app-nikki/root/etc/uci-defaults/40_luci-nikki 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 dc1fd7ca1..faaf71e54 100644 --- a/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js +++ b/luci-app-nikki/htdocs/luci-static/resources/tools/nikki.js @@ -38,6 +38,12 @@ const callNikkiUpdateSubscription = rpc.declare({ expect: { '': {} } }); +const callNikkiGetIdentifiers = rpc.declare({ + object: 'luci.nikki', + method: 'get_identifiers', + expect: { '': {} } +}); + const callNikkiDebug = rpc.declare({ object: 'luci.nikki', method: 'debug', @@ -136,6 +142,10 @@ return baseclass.extend({ return this.api('POST', '/upgrade/ui'); }, + getIdentifiers: function () { + return callNikkiGetIdentifiers(); + }, + listProfiles: function () { return L.resolveDefault(fs.list(this.profilesDir), []); }, @@ -167,16 +177,4 @@ return baseclass.extend({ debug: function () { return callNikkiDebug(); }, - - getUsers: function () { - return fs.lines('/etc/passwd').then(function (lines) { - return lines.map(function (line) { return line.split(/:/)[0] }).filter(function (user) { return user !== 'root' && user !== 'nikki' }); - }); - }, - - getGroups: function () { - return fs.lines('/etc/group').then(function (lines) { - return lines.map(function (line) { return line.split(/:/)[0] }).filter(function (group) { return group !== 'root' && group !== 'nikki' }); - }); - }, }) diff --git a/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js b/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js index 9c931c10e..aeb409d65 100644 --- a/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js +++ b/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js @@ -12,15 +12,15 @@ return view.extend({ uci.load('nikki'), network.getHostHints(), network.getNetworks(), - nikki.getUsers(), - nikki.getGroups() + nikki.getIdentifiers(), ]); }, render: function (data) { const hosts = data[1].hosts; const networks = data[2]; - const users = data[3]; - const groups = data[4]; + const users = data[3]?.users ?? []; + const groups = data[3]?.groups ?? []; + const cgroups = data[3]?.cgroups ?? []; let m, s, o; @@ -144,6 +144,13 @@ return view.extend({ o.value(group); }; + o = s.taboption('bypass', form.MultiValue, 'bypass_cgroup', _('Bypass cgroup')); + o.create = true; + + for (const cgroup of cgroups) { + o.value(cgroup); + }; + o = s.taboption('bypass', form.Flag, 'bypass_china_mainland_ip', _('Bypass China Mainland IP')); o.rmempty = false; diff --git a/luci-app-nikki/po/templates/nikki.pot b/luci-app-nikki/po/templates/nikki.pot index f0d93ee22..4794d5b97 100644 --- a/luci-app-nikki/po/templates/nikki.pot +++ b/luci-app-nikki/po/templates/nikki.pot @@ -17,8 +17,8 @@ msgstr "" msgid "All Mode" msgstr "" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:152 -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:157 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:159 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:164 msgid "All Port" msgstr "" @@ -65,11 +65,11 @@ msgstr "" msgid "Bypass" msgstr "" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:147 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:154 msgid "Bypass China Mainland IP" msgstr "" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:160 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:167 msgid "Bypass DSCP" msgstr "" @@ -81,6 +81,10 @@ msgstr "" msgid "Bypass User" msgstr "" +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:147 +msgid "Bypass cgroup" +msgstr "" + #: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/editor.js:29 msgid "Choose File" msgstr "" @@ -94,8 +98,8 @@ msgstr "" msgid "Clear Log" msgstr "" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:153 -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:158 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:160 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:165 msgid "Commonly Used Port" msgstr "" @@ -147,11 +151,11 @@ msgstr "" msgid "Destination Port" msgstr "" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:150 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:157 msgid "Destination TCP Port to Proxy" msgstr "" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:155 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:162 msgid "Destination UDP Port to Proxy" msgstr "" diff --git a/luci-app-nikki/po/zh_Hans/nikki.po b/luci-app-nikki/po/zh_Hans/nikki.po index 3a8a6984a..fedaf894a 100644 --- a/luci-app-nikki/po/zh_Hans/nikki.po +++ b/luci-app-nikki/po/zh_Hans/nikki.po @@ -24,8 +24,8 @@ msgstr "访问控制" msgid "All Mode" msgstr "全部模式" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:152 -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:157 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:159 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:164 msgid "All Port" msgstr "全部端口" @@ -72,11 +72,11 @@ msgstr "黑名单模式" msgid "Bypass" msgstr "绕过" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:147 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:154 msgid "Bypass China Mainland IP" msgstr "绕过中国大陆 IP" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:160 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:167 msgid "Bypass DSCP" msgstr "绕过 DSCP" @@ -88,6 +88,10 @@ msgstr "绕过用户组" msgid "Bypass User" msgstr "绕过用户" +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:147 +msgid "Bypass cgroup" +msgstr "绕过资源控制组" + #: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/editor.js:29 msgid "Choose File" msgstr "选择文件" @@ -101,8 +105,8 @@ msgstr "选择配置文件" msgid "Clear Log" msgstr "清空日志" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:153 -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:158 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:160 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:165 msgid "Commonly Used Port" msgstr "常用端口" @@ -154,11 +158,11 @@ msgstr "目标 IP(Geo)" msgid "Destination Port" msgstr "目标端口" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:150 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:157 msgid "Destination TCP Port to Proxy" msgstr "要代理的 TCP 目标端口" -#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:155 +#: applications/luci-app-nikki/htdocs/luci-static/resources/view/nikki/proxy.js:162 msgid "Destination UDP Port to Proxy" msgstr "要代理的 UDP 目标端口" diff --git a/luci-app-nikki/root/etc/uci-defaults/40_luci-nikki b/luci-app-nikki/root/etc/uci-defaults/40_luci-nikki deleted file mode 100644 index 080086891..000000000 --- a/luci-app-nikki/root/etc/uci-defaults/40_luci-nikki +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -rm -rf /var/luci-modulecache/; rm -f /var/luci-indexcache; -[ -x /etc/init.d/rpcd ] && /etc/init.d/rpcd reload; -exit 0 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 8f016c4f8..4d566f3e9 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 @@ -8,8 +8,6 @@ "luci.nikki": [ "*" ] }, "file": { - "/etc/passwd": ["read"], - "/etc/group": ["read"], "/etc/nikki/profiles/*.yaml": ["read"], "/etc/nikki/profiles/*.yml": ["read"], "/etc/nikki/subscriptions/*.yaml": ["read"], 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 d9fac6267..7f1b28cc2 100644 --- a/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki +++ b/luci-app-nikki/root/usr/share/rpcd/ucode/luci.nikki @@ -3,6 +3,7 @@ 'use strict'; import { access, popen } from 'fs'; +import { get_users, get_groups, get_cgroups } from '/etc/nikki/ucode/include.uc'; const methods = { version: { @@ -56,6 +57,14 @@ const methods = { return { success: success }; } }, + get_identifiers: { + call: function() { + const users = filter(get_users(), (x) => x != '' && x != 'root'); + const groups = filter(get_groups(), (x) => x != '' && x != 'root'); + const cgroups = filter(get_cgroups(), (x) => x != '' && x != 'nikki'); + return { users: users, groups: groups, cgroups: cgroups }; + } + }, debug: { call: function() { const success = system('/etc/nikki/scripts/debug.sh > /var/run/nikki/debug.md') == 0;