From d946f34094897f209bd2334c9c81fe4de3895e33 Mon Sep 17 00:00:00 2001 From: actions-user Date: Sat, 4 Jan 2025 16:15:30 +0800 Subject: [PATCH] update 2025-01-04 16:15:30 --- .../htdocs/luci-static/resources/fchomo.js | 6 +- .../resources/view/fchomo/client.js | 106 +++++++++++++++++- luci-app-fchomo/po/templates/fchomo.pot | 4 + luci-app-fchomo/po/zh_Hans/fchomo.po | 4 + luci-app-fchomo/po/zh_Hant/fchomo.po | 4 + luci-app-passwall/Makefile | 12 +- 6 files changed, 122 insertions(+), 14 deletions(-) diff --git a/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js b/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js index 961ef52a..372afc17 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js @@ -174,9 +174,9 @@ return baseclass.extend({ ], rules_logical_payload_count: { - 'AND': 2, - 'OR': 2, - 'NOT': 1, + 'AND': { req: 2, opt: undefined }, + 'OR': { req: 2, opt: undefined }, + 'NOT': { req: 1, opt: 0 }, //'SUB-RULE': 0, }, diff --git a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js index b3650a92..aca97cbd 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/client.js @@ -125,13 +125,20 @@ class RulesEntry { return this.payload[n] || {}; } - setPayload(n, obj) { + getPayloads() { + return this.payload || []; + } + + setPayload(n, obj, limit) { this.payload[n] ||= {}; Object.keys(obj).forEach((key) => { this.payload[n][key] = obj[key] || null; }); + if (limit) + this.payload.splice(limit); + return this } @@ -152,7 +159,7 @@ class RulesEntry { var logical = hm.rules_logical_type.map(e => e[0] || e).includes(this.type), factor = ''; if (logical) { - let n = hm.rules_logical_payload_count[this.type] || 0; + let n = hm.rules_logical_payload_count[this.type] ? hm.rules_logical_payload_count[this.type].opt : 0; factor = '(%s)'.format(this.payload.slice(0, n).map((payload) => { return '(%s‚%s)'.format(payload.type || '', payload.factor || ''); }).join('ꓹ')); @@ -215,8 +222,35 @@ function renderPayload(s, total, uciconfig) { o.rmempty = false; o.modalonly = true; } + var initDynamicPayload = function(o, n, key, uciconfig) { + o.load = L.bind(function(n, key, uciconfig, section_id) { + return new RulesEntry(uci.get(uciconfig, section_id, 'entry')).getPayloads().slice(n).map(e => e[key]); + }, o, n, key, uciconfig); + o.validate = function(section_id, value) { + value = this.formvalue(section_id); + var UIEl = this.section.getUIElement(section_id, 'entry'); + var rule = new RulesEntry(UIEl.getValue()); + + let n = this.option.match(/^payload(\d+)_/)[1]; + let limit = rule.getPayloads().length; + value.forEach((val) => { + rule.setPayload(n, {factor: val}); n++; + }); + rule.setPayload(limit, {factor: null}, limit); + var newvalue = rule.toString(); + + UIEl.node.previousSibling.innerText = newvalue; + UIEl.setValue(newvalue); + + return true; + } + o.write = function() {}; + o.rmempty = true; + o.modalonly = true; + } var o, prefix; + // StaticList payload for (var n=0; n { - if (n < hm.rules_logical_payload_count[key]) + if (n < hm.rules_logical_payload_count[key].req) o.depends('type', key); }) initPayload(o, n, 'type', uciconfig); @@ -297,6 +331,68 @@ function renderPayload(s, total, uciconfig) { return new RulesEntry(uci.get(uciconfig, section_id, 'entry')).getPayload(n)[key]; }, o, n, 'factor', uciconfig) } + + // DynamicList payload + var extenbox = {}; + Object.entries(hm.rules_logical_payload_count).filter(e => e[1].opt === undefined).forEach((e) => { + let n = e[1].req; + if (!Array.isArray(extenbox[n])) + extenbox[n] = []; + extenbox[n].push(e[0]); + }) + Object.keys(extenbox).forEach((n) => { + prefix = `payload${n}_`; + + o = s.option(form.DynamicList, prefix + 'type', _('Type') + ' ++'); + o.default = hm.rules_type[0][0]; + hm.rules_type.forEach((res) => { + o.value.apply(o, res); + }) + extenbox[n].forEach((type) => { + o.depends('type', type); + }) + initDynamicPayload(o, n, 'type', uciconfig); + o.validate = function(section_id, value) { + value = this.formvalue(section_id); + var UIEl = this.section.getUIElement(section_id, 'entry'); + var rule = new RulesEntry(UIEl.getValue()); + + let n = this.option.match(/^payload(\d+)_/)[1]; + value.forEach((val) => { + rule.setPayload(n, {type: val}); n++; + }); + rule.setPayload(n, {factor: null}, n); + var newvalue = rule.toString(); + + UIEl.node.previousSibling.innerText = newvalue; + UIEl.setValue(newvalue); + + return true; + } + + o = s.option(form.DynamicList, prefix + 'fused', _('Factor') + ' ++', + _('Content will not be verified, Please make sure you enter it correctly.')); + o.value('', _('-- Please choose --')); + extenbox[n].forEach((type) => { + o.depends(Object.fromEntries([['type', type], [prefix + 'type', /.+/]])); + }) + initDynamicPayload(o, n, 'factor', uciconfig); + o.load = L.bind(function(n, key, uciconfig, section_id) { + let fusedval = [ + ['', _('-- Please choose --')], + ['NETWORK', '-- NETWORK --'], + ['udp', _('UDP')], + ['tcp', _('TCP')], + ['RULESET', '-- RULE-SET --'] + ]; + hm.loadRulesetLabel.call(this, null, section_id); + this.keylist = [...fusedval.map(e => e[0]), ...this.keylist]; + this.vallist = [...fusedval.map(e => e[1]), ...this.vallist]; + this.super('load', section_id); + + return new RulesEntry(uci.get(uciconfig, section_id, 'entry')).getPayloads().slice(n).map(e => e[key]); + }, o, n, 'factor', uciconfig) + }) } function renderRules(s, uciconfig) { @@ -356,7 +452,7 @@ function renderRules(s, uciconfig) { o.rmempty = false; o.modalonly = true; - renderPayload(s, Math.max(...Object.values(hm.rules_logical_payload_count)), uciconfig); + renderPayload(s, Math.max(...Object.values(hm.rules_logical_payload_count).map(e => e.req)), uciconfig); o = s.option(form.ListValue, 'detour', _('Proxy group')); o.renderWidget = function(/* ... */) { @@ -1018,7 +1114,7 @@ return view.extend({ so.rmempty = false; so.editable = true; - so = ss.option(form.ListValue, 'proxy', _('Proxy group'), + so = ss.option(form.ListValue, 'proxy', _('Proxy group override'), _('Override the Proxy group of DNS server.')); so.renderWidget = function(/* ... */) { var frameEl = form.ListValue.prototype.renderWidget.apply(this, arguments); diff --git a/luci-app-fchomo/po/templates/fchomo.pot b/luci-app-fchomo/po/templates/fchomo.pot index bb3246ab..d2e1ff5d 100644 --- a/luci-app-fchomo/po/templates/fchomo.pot +++ b/luci-app-fchomo/po/templates/fchomo.pot @@ -1667,6 +1667,10 @@ msgstr "" msgid "Proxy group" msgstr "" +#: htdocs/luci-static/resources/view/fchomo/client.js:1117 +msgid "Proxy group override" +msgstr "" + #: htdocs/luci-static/resources/view/fchomo/global.js:450 msgid "Proxy mode" msgstr "" diff --git a/luci-app-fchomo/po/zh_Hans/fchomo.po b/luci-app-fchomo/po/zh_Hans/fchomo.po index dd317145..ee5035cd 100644 --- a/luci-app-fchomo/po/zh_Hans/fchomo.po +++ b/luci-app-fchomo/po/zh_Hans/fchomo.po @@ -1690,6 +1690,10 @@ msgstr "代理链" msgid "Proxy group" msgstr "代理组" +#: htdocs/luci-static/resources/view/fchomo/client.js:1117 +msgid "Proxy group override" +msgstr "代理组覆盖" + #: htdocs/luci-static/resources/view/fchomo/global.js:450 msgid "Proxy mode" msgstr "代理模式" diff --git a/luci-app-fchomo/po/zh_Hant/fchomo.po b/luci-app-fchomo/po/zh_Hant/fchomo.po index 8d5dfd7e..7fef86cd 100644 --- a/luci-app-fchomo/po/zh_Hant/fchomo.po +++ b/luci-app-fchomo/po/zh_Hant/fchomo.po @@ -1690,6 +1690,10 @@ msgstr "代理鏈" msgid "Proxy group" msgstr "代理組" +#: htdocs/luci-static/resources/view/fchomo/client.js:1117 +msgid "Proxy group override" +msgstr "代理組覆蓋" + #: htdocs/luci-static/resources/view/fchomo/global.js:450 msgid "Proxy mode" msgstr "代理模式" diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 6653f5f7..18cdd8de 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -12,6 +12,7 @@ PKG_RELEASE:=1 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ CONFIG_PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy \ + CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Geoview \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy \ @@ -26,7 +27,6 @@ PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_Plus \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_tuic_client \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geoview \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Plugin \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray_Plugin @@ -64,6 +64,11 @@ config PACKAGE_$(PKG_NAME)_Nftables_Transparent_Proxy select PACKAGE_kmod-nft-nat default y if PACKAGE_firewall4 +config PACKAGE_$(PKG_NAME)_INCLUDE_Geoview + bool "Include Geoview" + select PACKAGE_geoview + default y if aarch64||arm||i386||x86_64 + config PACKAGE_$(PKG_NAME)_INCLUDE_Haproxy bool "Include Haproxy" select PACKAGE_haproxy @@ -141,11 +146,6 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geodata select PACKAGE_v2ray-geosite default n -config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Geoview - bool "Include V2ray_Geoview" - select PACKAGE_geoview - default y if aarch64||arm||i386||x86_64 - config PACKAGE_$(PKG_NAME)_INCLUDE_V2ray_Plugin bool "Include V2ray-Plugin (Shadowsocks Plugin)" select PACKAGE_v2ray-plugin