diff --git a/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js b/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js index a0c12e67a..14279492c 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js @@ -1100,8 +1100,9 @@ function textvalue2Value(section_id) { return this.vallist[i]; } -function validateCustomListIDs(hm_prefmt, disoption_list, section_id) { +function validateCustomListIDs(disoption_list, section_id) { let node; + let hm_prefmt = glossary[this.section.sectiontype].prefmt; let custom_dp_list_ids = [ 'fchomo_direct_list', 'fchomo_proxy_list' @@ -1110,7 +1111,7 @@ function validateCustomListIDs(hm_prefmt, disoption_list, section_id) { if (custom_dp_list_ids.map((v) => hm_prefmt.format(v)).includes(section_id)) { disoption_list.forEach(([typ, opt]) => { node = this.section.getUIElement(section_id, opt)?.node; - (typ ? node?.querySelector(typ) : node)?.setAttribute('disabled', ''); + (typ ? node?.querySelector(typ) : node)?.setAttribute(typ === 'textarea' ? 'readOnly' : 'disabled', ''); }); this.map.findElement('id', 'cbi-fchomo-' + section_id)?.lastChild.querySelector('.cbi-button-remove')?.remove(); 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 b7e3bcc65..695502134 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 @@ -1136,10 +1136,9 @@ return view.extend({ so.default = so.enabled; so.editable = true; so.validate = function(section_id, value) { - let hm_prefmt = hm.glossary[this.section.sectiontype].prefmt; let n = 0; - return hm.validateCustomListIDs.call(this, hm_prefmt, [ + return hm.validateCustomListIDs.call(this, [ ['input', this.option], ['select', 'type'], ['select', `payload${n}_` + 'rule_set'] @@ -1590,9 +1589,7 @@ return view.extend({ so.default = so.enabled; so.editable = true; so.validate = function(section_id, value) { - let hm_prefmt = hm.glossary[this.section.sectiontype].prefmt; - - return hm.validateCustomListIDs.call(this, hm_prefmt, [ + return hm.validateCustomListIDs.call(this, [ ['input', this.option], ['select', 'type'], ['', 'rule_set'] diff --git a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/ruleset.js b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/ruleset.js index ee347c930..f36bf9bde 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/ruleset.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/view/fchomo/ruleset.js @@ -254,13 +254,12 @@ return view.extend({ o.default = o.enabled; o.editable = true; o.validate = function(section_id, value) { - let hm_prefmt = hm.glossary[this.section.sectiontype].prefmt; - - return hm.validateCustomListIDs.call(this, hm_prefmt, [ + return hm.validateCustomListIDs.call(this, [ ['input', this.option], ['select', 'type'], ['select', 'behavior'], - ['select', 'format'] + ['select', 'format'], + ['textarea', '_editer'] ], ...arguments); } diff --git a/luci-app-fchomo/root/etc/init.d/fchomo b/luci-app-fchomo/root/etc/init.d/fchomo index eae2d81bd..13a7e92c2 100755 --- a/luci-app-fchomo/root/etc/init.d/fchomo +++ b/luci-app-fchomo/root/etc/init.d/fchomo @@ -193,12 +193,27 @@ start_service() { local yaml="$5" if [ -n "$yaml" ]; then - yq '.[] |= with(select(. == null); . = []) | .DOMAIN[] | sub("(^\+\.)", "") | sub("(^.+\*)", "")' "$src" | \ + yq '.[] |= with(select(. == null); . = []) | .DOMAIN[]' "$src" | \ sed "s|^|nftset=/|;s|$|/${family}#inet#fchomo#${set_name}|" > "$dst" else sed "s|^|nftset=/|;s|$|/${family}#inet#fchomo#${set_name}|" "$src" > "$dst" fi } + # + write_runtime_customlist_file() { + local src="$1" + local dst="$2" + + yq '.[] |= with(select(. == null); . = []) + | with(.DOMAIN[]; . = "DOMAIN-SUFFIX,\(.)") + | with(.IPCIDR[]; . = "IP-CIDR,\(.)") + | with(.IPCIDR6[]; . = "IP-CIDR6,\(.)") + | {"payload": [.DOMAIN[], .IPCIDR[], .IPCIDR6[]]}' "$src" > "$dst" + } + + # runtiming custom direct/proxy list ruleset + write_runtime_customlist_file "$HM_DIR/resources/direct_list.yaml" "$RUN_DIR/direct_list.yaml" + write_runtime_customlist_file "$HM_DIR/resources/proxy_list.yaml" "$RUN_DIR/proxy_list.yaml" # IP-sets if [ -n "$(opmc list-installed dnsmasq-full)" ]; then @@ -435,6 +450,10 @@ stop_client() { nft delete table inet fchomo 2>"/dev/null" echo 2>"/dev/null" > "$RUN_DIR/fchomo_post.nft" + # Remove runtime ruleset + echo 2>"/dev/null" > "$RUN_DIR/direct_list.yaml" + echo 2>"/dev/null" > "$RUN_DIR/proxy_list.yaml" + # Remove DNSMasq servers rm -rf "$DNSMASQ_DIR/../dnsmasq-fchomo.conf" "$DNSMASQ_DIR/../00-dnsmasq-fchomo.conf" "$DNSMASQ_DIR" # no bash, no {,00-}dnsmasq-fchomo.conf diff --git a/luci-app-fchomo/root/etc/uci-defaults/99_luci-app-fchomo b/luci-app-fchomo/root/etc/uci-defaults/99_luci-app-fchomo index 000d54c93..35705ea17 100755 --- a/luci-app-fchomo/root/etc/uci-defaults/99_luci-app-fchomo +++ b/luci-app-fchomo/root/etc/uci-defaults/99_luci-app-fchomo @@ -22,7 +22,7 @@ if [ ! -s "/etc/fchomo/resources/direct_list.yaml" ]; then EOF fi # ruleset symlink -ln -sf /etc/fchomo/resources/direct_list.yaml /etc/fchomo/ruleset/rule_fchomo_direct_list +ln -sf /var/run/fchomo/direct_list.yaml /etc/fchomo/ruleset/rule_fchomo_direct_list # ruleset config if ! uci -q get fchomo.rule_fchomo_direct_list >/dev/null; then uci -q batch <<-EOF >/dev/null @@ -47,14 +47,14 @@ if ! uci -q get fchomo.fchomo_direct_list_domain >/dev/null; then uci commit fchomo fi # rules config -if ! uci -q get fchomo.fchomo_direct_list_host >/dev/null; then - uci -q batch <<-EOF >/dev/null - set fchomo.fchomo_direct_list_host=rules - set fchomo.fchomo_direct_list_host.label='Custom Direct List (Preset)' - set fchomo.fchomo_direct_list_host.entry='{"type":"RULE-SET","payload":[{"type":"RULE-SET","factor":"rule_fchomo_direct_list"}],"detour":"DIRECT"}' - EOF - uci commit fchomo -fi +#if ! uci -q get fchomo.fchomo_direct_list_host >/dev/null; then +# uci -q batch <<-EOF >/dev/null +# set fchomo.fchomo_direct_list_host=rules +# set fchomo.fchomo_direct_list_host.label='Custom Direct List (Debug)' +# set fchomo.fchomo_direct_list_host.entry='{"type":"RULE-SET","payload":[{"type":"RULE-SET","factor":"rule_fchomo_direct_list"}],"detour":"DIRECT"}' +# EOF +# uci commit fchomo +#fi # Initialize the default proxy list if [ ! -s "/etc/fchomo/resources/proxy_list.yaml" ]; then @@ -83,7 +83,7 @@ if [ ! -s "/etc/fchomo/resources/proxy_list.yaml" ]; then EOF fi # ruleset symlink -ln -sf /etc/fchomo/resources/proxy_list.yaml /etc/fchomo/ruleset/rule_fchomo_proxy_list +ln -sf /var/run/fchomo/proxy_list.yaml /etc/fchomo/ruleset/rule_fchomo_proxy_list # ruleset config if ! uci -q get fchomo.rule_fchomo_proxy_list >/dev/null; then uci -q batch <<-EOF >/dev/null diff --git a/natflow/Makefile b/natflow/Makefile index 77d9d33e6..fbc525ef4 100644 --- a/natflow/Makefile +++ b/natflow/Makefile @@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=natflow -PKG_VERSION:=20250914 +PKG_VERSION:=20250915 PKG_SOURCE_URL:=https://codeload.github.com/ptpt52/natflow/tar.gz/$(PKG_VERSION)? -PKG_HASH:=23fa34d9d7336507b354f72584caa0cab9d41ee7b2cbe667396304596a575fab +PKG_HASH:=f293db9cd25cac3004e346caf8e7d89165a51315628504f44e117d22618f5fc7 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_MAINTAINER:=Chen Minqiang