From 43db9a20fc47826ecc774fe61acc7d5279c91f2a Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Mon, 15 Sep 2025 16:29:22 +0800 Subject: [PATCH] update 2025-09-15 16:29:22 --- alist/Makefile | 6 +- .../htdocs/luci-static/resources/fchomo.js | 12 ++-- .../resources/view/fchomo/client.js | 6 +- .../resources/view/fchomo/ruleset.js | 3 +- luci-app-fchomo/root/etc/init.d/fchomo | 48 +++++++++---- .../root/etc/uci-defaults/99_luci-app-fchomo | 72 +++++++++++++++++++ 6 files changed, 118 insertions(+), 29 deletions(-) diff --git a/alist/Makefile b/alist/Makefile index 3f31f15c7..5607b0482 100644 --- a/alist/Makefile +++ b/alist/Makefile @@ -12,7 +12,7 @@ PKG_WEB_VERSION:=3.53.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)? +PKG_SOURCE_URL:=https://codeload.github.com/AlistGo/alist/tar.gz/v$(PKG_VERSION)? PKG_HASH:=eb54f08392feac9b313dbf2088fe83f637dd14c350f1d35ee4fa7c5a8f2959a5 PKG_LICENSE:=GPL-3.0 @@ -22,7 +22,7 @@ PKG_MAINTAINER:=sbwml define Download/$(PKG_NAME)-web FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz URL_FILE:=dist.tar.gz - URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/ + URL:=https://github.com/AlistGo/alist-web/releases/download/$(PKG_WEB_VERSION)/ HASH:=755459065b69ceb353d46c5f51fa79c3ddefacdbd3a08894311190cebe8bb99e endef @@ -31,7 +31,7 @@ PKG_BUILD_PARALLEL:=1 PKG_USE_MIPS16:=0 PKG_BUILD_FLAGS:=no-mips16 -GO_PKG:=github.com/alist-org/alist +GO_PKG:=github.com/AlistGo/alist GO_PKG_LDFLAGS:= \ -X '$(GO_PKG)/v3/internal/conf.BuiltAt=$(shell date '+%Y-%m-%d %H:%M:%S %z')' \ -X '$(GO_PKG)/v3/internal/conf.GoVersion=$(shell $(STAGING_DIR_HOSTPKG)/bin/go version | sed 's/go version //')' \ diff --git a/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js b/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js index b2d7fb550..48dd4ee37 100644 --- a/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js +++ b/luci-app-fchomo/htdocs/luci-static/resources/fchomo.js @@ -1102,15 +1102,17 @@ function textvalue2Value(section_id) { return this.vallist[i]; } -function validateCustomListIDs(disoption_list, section_id) { +function validatePresetIDs(disoption_list, section_id) { let node; let hm_prefmt = glossary[this.section.sectiontype].prefmt; - let custom_dp_list_ids = [ + let preset_ids = [ 'fchomo_direct_list', - 'fchomo_proxy_list' + 'fchomo_proxy_list', + 'fchomo_china_list', + 'fchomo_gfw_list' ]; - if (custom_dp_list_ids.map((v) => hm_prefmt.format(v)).includes(section_id)) { + if (preset_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(typ === 'textarea' ? 'readOnly' : 'disabled', ''); @@ -1477,7 +1479,7 @@ return baseclass.extend({ handleReload, handleRemoveIdles, textvalue2Value, - validateCustomListIDs, + validatePresetIDs, validateAuth, validateAuthUsername, validateAuthPassword, 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 695502134..77d6b05b9 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 @@ -1138,8 +1138,7 @@ return view.extend({ so.validate = function(section_id, value) { let n = 0; - return hm.validateCustomListIDs.call(this, [ - ['input', this.option], + return hm.validatePresetIDs.call(this, [ ['select', 'type'], ['select', `payload${n}_` + 'rule_set'] ], ...arguments); @@ -1589,8 +1588,7 @@ return view.extend({ so.default = so.enabled; so.editable = true; so.validate = function(section_id, value) { - return hm.validateCustomListIDs.call(this, [ - ['input', this.option], + return hm.validatePresetIDs.call(this, [ ['select', 'type'], ['', 'rule_set'] ], ...arguments); 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 f36bf9bde..fdb8596f1 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,8 +254,7 @@ return view.extend({ o.default = o.enabled; o.editable = true; o.validate = function(section_id, value) { - return hm.validateCustomListIDs.call(this, [ - ['input', this.option], + return hm.validatePresetIDs.call(this, [ ['select', 'type'], ['select', 'behavior'], ['select', 'format'], diff --git a/luci-app-fchomo/root/etc/init.d/fchomo b/luci-app-fchomo/root/etc/init.d/fchomo index 13a7e92c2..62e719afd 100755 --- a/luci-app-fchomo/root/etc/init.d/fchomo +++ b/luci-app-fchomo/root/etc/init.d/fchomo @@ -158,6 +158,37 @@ start_service() { mv "$RUN_DIR/"*-gh-pages/ "$RUN_DIR/ui/" fi + # Generate runtime ruleset + # [domainOnlay] + write_runtime_ruleset_file() { + local format="$1" + local src="$2" + local dst="$3" + local domainOnlay="$4" + + if [ "$format" = "fchmclist" ]; then + if [ -n "$domainOnlay" ]; then + yq '.[] |= with(select(. == null); . = []) + | with(.DOMAIN[]; . = "DOMAIN-SUFFIX,\(.)") + | {"payload": .DOMAIN}' "$src" > "$dst" + else + yq '.[] |= with(select(. == null); . = []) + | with(.DOMAIN[]; . = "DOMAIN-SUFFIX,\(.)") + | with(.IPCIDR[]; . = "IP-CIDR,\(.)") + | with(.IPCIDR6[]; . = "IP-CIDR6,\(.)") + | {"payload": [.DOMAIN[], .IPCIDR[], .IPCIDR6[]]}' "$src" > "$dst" + fi + elif [ "$format" = "domain" ]; then + sed -E 's|^([^\.])|+.\1|' "$src" > "$dst" + fi + } + + # runtime ruleset + write_runtime_ruleset_file fchmclist "$HM_DIR/resources/direct_list.yaml" "$RUN_DIR/direct_list.yaml" domainOnlay + write_runtime_ruleset_file fchmclist "$HM_DIR/resources/proxy_list.yaml" "$RUN_DIR/proxy_list.yaml" + write_runtime_ruleset_file domain "$HM_DIR/resources/china_list.txt" "$RUN_DIR/china_list.txt" + write_runtime_ruleset_file domain "$HM_DIR/resources/gfw_list.txt" "$RUN_DIR/gfw_list.txt" + # Setup DNSMasq servers and IP-sets local global_ipv6 dns_ipv6 config_get_bool global_ipv6 "global" "ipv6" "1" @@ -199,21 +230,6 @@ start_service() { 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 @@ -453,6 +469,8 @@ stop_client() { # Remove runtime ruleset echo 2>"/dev/null" > "$RUN_DIR/direct_list.yaml" echo 2>"/dev/null" > "$RUN_DIR/proxy_list.yaml" + echo 2>"/dev/null" > "$RUN_DIR/china_list.txt" + echo 2>"/dev/null" > "$RUN_DIR/gfw_list.txt" # 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 2f137ca2c..c8c76a120 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 @@ -117,6 +117,78 @@ if ! uci -q get fchomo.fchomo_proxy_list_host >/dev/null; then uci commit fchomo fi +# Initialize the default china list +# ruleset symlink +ln -sf /var/run/fchomo/china_list.txt /etc/fchomo/ruleset/rule_fchomo_china_list +# ruleset config +if ! uci -q get fchomo.rule_fchomo_china_list >/dev/null; then + uci -q batch <<-EOF >/dev/null + set fchomo.rule_fchomo_china_list=ruleset + set fchomo.rule_fchomo_china_list.label='China List (Preset)' + set fchomo.rule_fchomo_china_list.type='file' + set fchomo.rule_fchomo_china_list.behavior='domain' + set fchomo.rule_fchomo_china_list.format='text' + EOF + uci commit fchomo +fi +# dns_policy config +if ! uci -q get fchomo.fchomo_china_list_domain >/dev/null; then + uci -q batch <<-EOF >/dev/null + set fchomo.fchomo_china_list_domain=dns_policy + set fchomo.fchomo_china_list_domain.label='China List (Preset)' + set fchomo.fchomo_china_list_domain.type='rule_set' + add_list fchomo.fchomo_china_list_domain.server='default-dns' + add_list fchomo.fchomo_china_list_domain.rule_set='rule_fchomo_china_list' + set fchomo.fchomo_china_list_domain.proxy='DIRECT' + EOF + uci commit fchomo +fi +# rules config +if ! uci -q get fchomo.fchomo_china_list_host >/dev/null; then + uci -q batch <<-EOF >/dev/null + set fchomo.fchomo_china_list_host=rules + set fchomo.fchomo_china_list_host.label='China List (Preset)' + set fchomo.fchomo_china_list_host.entry='{"type":"RULE-SET","payload":[{"type":"RULE-SET","factor":"rule_fchomo_china_list"}],"detour":"DIRECT"}' + EOF + uci commit fchomo +fi + +# Initialize the default gfw list +# ruleset symlink +ln -sf /var/run/fchomo/gfw_list.txt /etc/fchomo/ruleset/rule_fchomo_gfw_list +# ruleset config +if ! uci -q get fchomo.rule_fchomo_gfw_list >/dev/null; then + uci -q batch <<-EOF >/dev/null + set fchomo.rule_fchomo_gfw_list=ruleset + set fchomo.rule_fchomo_gfw_list.label='GFW List (Preset)' + set fchomo.rule_fchomo_gfw_list.type='file' + set fchomo.rule_fchomo_gfw_list.behavior='domain' + set fchomo.rule_fchomo_gfw_list.format='text' + EOF + uci commit fchomo +fi +# dns_policy config +if ! uci -q get fchomo.fchomo_gfw_list_domain >/dev/null; then + uci -q batch <<-EOF >/dev/null + set fchomo.fchomo_gfw_list_domain=dns_policy + set fchomo.fchomo_gfw_list_domain.label='GFW List (Preset)' + set fchomo.fchomo_gfw_list_domain.type='rule_set' + add_list fchomo.fchomo_gfw_list_domain.server='default-dns' + add_list fchomo.fchomo_gfw_list_domain.rule_set='rule_fchomo_gfw_list' + set fchomo.fchomo_gfw_list_domain.proxy='GLOBAL' + EOF + uci commit fchomo +fi +# rules config +if ! uci -q get fchomo.fchomo_gfw_list_host >/dev/null; then + uci -q batch <<-EOF >/dev/null + set fchomo.fchomo_gfw_list_host=rules + set fchomo.fchomo_gfw_list_host.label='GFW List (Preset)' + set fchomo.fchomo_gfw_list_host.entry='{"type":"RULE-SET","payload":[{"type":"RULE-SET","factor":"rule_fchomo_gfw_list"}],"detour":"GLOBAL"}' + EOF + uci commit fchomo +fi + # Initialize the default hosts if [ ! -s "/etc/fchomo/templates/hosts.yaml" ]; then cat <<- EOF > "/etc/fchomo/templates/hosts.yaml"