From bbf8a31143147fc1786b233a868a46ec589a4c71 Mon Sep 17 00:00:00 2001 From: gitea-action Date: Tue, 15 Oct 2024 10:00:31 +0800 Subject: [PATCH] mihomo: sync upstream last commit: https://github.com/morytyann/OpenWrt-mihomo/commit/cbe210d71cbbcd5b1147529f8b4524993d71868f --- mihomo/files/mihomo.conf | 1 + mihomo/files/mihomo.init | 12 ++++++++---- mihomo/files/nftables/hijack.nft | 3 ++- mihomo/files/uci-defaults/migrate.sh | 4 ++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mihomo/files/mihomo.conf b/mihomo/files/mihomo.conf index 235f99297..1128dc942 100644 --- a/mihomo/files/mihomo.conf +++ b/mihomo/files/mihomo.conf @@ -80,6 +80,7 @@ config mixin 'mixin' option 'geoip_asn_url' 'https://mirror.ghproxy.com/https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb' option 'geox_auto_update' '0' option 'geox_update_interval' '24' + option 'mixin_file_content' '0' config authentication option 'enabled' '1' diff --git a/mihomo/files/mihomo.init b/mihomo/files/mihomo.init index 475070df4..5c3edc132 100644 --- a/mihomo/files/mihomo.init +++ b/mihomo/files/mihomo.init @@ -108,6 +108,9 @@ start_service() { config_get geoip_asn_url "mixin" "geoip_asn_url" config_get_bool geox_auto_update "mixin" "geox_auto_update" 0 config_get geox_update_interval "mixin" "geox_update_interval" "24" + ### mixin file content + local mixin_file_content + config_get_bool mixin_file_content "mixin" "mixin_file_content" 0 # prepare local tproxy_enable; tproxy_enable=0 if [[ "$tcp_transparent_proxy_mode" == "tproxy" || "$udp_transparent_proxy_mode" == "tproxy" ]]; then @@ -195,10 +198,6 @@ start_service() { yq -M -i 'del(.dns.nameserver-policy)' "$RUN_PROFILE_PATH" config_foreach mixin_nameserver_policies "nameserver_policy" fi - # mixin file - if [ -s "$MIXIN_FILE_PATH" ]; then - yq ea -M -i '. as $item ireduce ({}; . * $item ) | ... comments=""' "$RUN_PROFILE_PATH" "$MIXIN_FILE_PATH" - fi fi yq -M -i 'del (.bind-address)' "$RUN_PROFILE_PATH" if [ -n "$outbound_interface" ]; then @@ -215,6 +214,11 @@ start_service() { if [ "$tun_enable" == 1 ]; then yq -M -i '.tun.auto-route = false | .tun.auto-redirect = false | .tun.auto-detect-interface = false | .tun.dns-hijack = []' "$RUN_PROFILE_PATH" fi + if [ "$mixin_file_content" == 1 ]; then + if [ -s "$MIXIN_FILE_PATH" ]; then + yq ea -M -i '. as $item ireduce ({}; . * $item ) | ... comments=""' "$RUN_PROFILE_PATH" "$MIXIN_FILE_PATH" + fi + fi # test profile if [ "$test_profile" == 1 ]; then log "Profile testing..." diff --git a/mihomo/files/nftables/hijack.nft b/mihomo/files/nftables/hijack.nft index c277fa294..699d7e766 100644 --- a/mihomo/files/nftables/hijack.nft +++ b/mihomo/files/nftables/hijack.nft @@ -63,7 +63,8 @@ table inet mihomo { } chain router_dns_hijack { - meta nfproto @dns_hijack_nfproto meta l4proto { tcp, udp } th dport 53 oifname lo meta skuid != $MIHOMO_USER counter redirect to :$DNS_PORT + meta skuid $MIHOMO_USER counter return + meta nfproto @dns_hijack_nfproto meta l4proto { tcp, udp } th dport 53 oifname lo counter redirect to :$DNS_PORT } chain all_dns_hijack { diff --git a/mihomo/files/uci-defaults/migrate.sh b/mihomo/files/uci-defaults/migrate.sh index 0febd30e6..9a566cf94 100644 --- a/mihomo/files/uci-defaults/migrate.sh +++ b/mihomo/files/uci-defaults/migrate.sh @@ -6,6 +6,10 @@ dns_doh_prefer_http3=$(uci -q get mihomo.mixin.dns_doh_prefer_http3); [ -z "$dns_doh_prefer_http3" ] && uci set mihomo.mixin.dns_doh_prefer_http3=0 +# since v1.8.7 + +mixin_file_content=$(uci -q get mihomo.mixin.mixin_file_content); [ -z "$mixin_file_content" ] && uci set mihomo.mixin.mixin_file_content=$(uci -q get mihomo.config.mixin) + # commit uci commit mihomo