diff --git a/luci-app-mosdns/Makefile b/luci-app-mosdns/Makefile index 3112203..e3c4293 100644 --- a/luci-app-mosdns/Makefile +++ b/luci-app-mosdns/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-mosdns -PKG_VERSION:=1.5.10 +PKG_VERSION:=1.5.11 PKG_RELEASE:=1 LUCI_TITLE:=LuCI Support for mosdns diff --git a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua index 225ea7b..bfd6cba 100644 --- a/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua +++ b/luci-app-mosdns/luasrc/model/cbi/mosdns/basic.lua @@ -50,6 +50,11 @@ o.default = true o = s:taboption("basic", Flag, "custom_local_dns", translate("Local DNS"), translate("Follow WAN interface DNS if not enabled")) o:depends( "configfile", "/etc/mosdns/config.yaml") o.default = false + +o = s:taboption("basic", Flag, "apple_optimization", translate("Apple domains optimization"), translate("For Apple domains equipped with Chinese mainland CDN, always responsive to Chinese CDN IP addresses")) +o:depends("custom_local_dns", "1") +o.default = true + o = s:taboption("basic", DynamicList, "local_dns", translate("Upstream DNS servers")) o:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)") o:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)") diff --git a/luci-app-mosdns/po/zh-cn/mosdns.po b/luci-app-mosdns/po/zh-cn/mosdns.po index 64954cb..dbdeaf5 100644 --- a/luci-app-mosdns/po/zh-cn/mosdns.po +++ b/luci-app-mosdns/po/zh-cn/mosdns.po @@ -160,6 +160,12 @@ msgstr "本地 DNS" msgid "Follow WAN interface DNS if not enabled" msgstr "不启用则使用 WAN 接口 DNS" +msgid "Apple domains optimization" +msgstr "Apple 域名解析优化" + +msgid "For Apple domains equipped with Chinese mainland CDN, always responsive to Chinese CDN IP addresses" +msgstr "配备中国大陆 CDN 的 Apple 域名,始终应答中国大陆 CDN 地址" + msgid "Upstream DNS servers" msgstr "上游 DNS 服务器" diff --git a/luci-app-mosdns/root/etc/init.d/mosdns b/luci-app-mosdns/root/etc/init.d/mosdns index 013cd36..47158a8 100755 --- a/luci-app-mosdns/root/etc/init.d/mosdns +++ b/luci-app-mosdns/root/etc/init.d/mosdns @@ -52,6 +52,7 @@ get_config() { config_get redirect $1 redirect 0 config_get remote_dns $1 remote_dns "tls://8.8.8.8 tls://1.1.1.1" config_get custom_local_dns $1 custom_local_dns 0 + config_get apple_optimization $1 apple_optimization 0 config_get bootstrap_dns $1 bootstrap_dns "119.29.29.29" config_get listen_port_api $1 listen_port_api 9091 config_get concurrent $1 concurrent 1 @@ -92,6 +93,8 @@ init_yaml() { s,maximum_ttl_custom,$maximum_ttl_custom,g; \ s,concurrent_num,$concurrent,g;s,api_port,$listen_port_api,g; \ s,remote_dns_pipeline,$enable_pipeline,g" $DEFAULT_CONF > $CONF + # Apple optimization + [ "$apple_optimization" != 1 ] && sed -i '/- exec: \$query_is_apple_domain/,+1d' $CONF # Adlist adlist=$($MOSDNS_SCRIPT adlist) echo "${adlist}" > $TMPDIR/adlist_files.txt diff --git a/luci-app-mosdns/root/usr/share/mosdns/default.yaml b/luci-app-mosdns/root/usr/share/mosdns/default.yaml index 2d326bf..1e0feb7 100644 --- a/luci-app-mosdns/root/usr/share/mosdns/default.yaml +++ b/luci-app-mosdns/root/usr/share/mosdns/default.yaml @@ -20,6 +20,12 @@ plugins: files: - "/var/mosdns/geoip_cn.txt" + - tag: geosite_apple + type: domain_set + args: + files: + - "/var/mosdns/geosite_apple.txt" + - tag: geosite_no_cn type: domain_set args: @@ -86,6 +92,22 @@ plugins: size: cache_size lazy_cache_ttl: cache_survival_time + - tag: forward_dnspod_udp + type: forward + args: + concurrent: 2 + upstreams: + - addr: "119.29.29.29" + - addr: "119.28.28.28" + + - tag: forward_xinfeng_udp + type: forward + args: + concurrent: 2 + upstreams: + - addr: "114.114.114.114" + - addr: "114.114.115.115" + - tag: forward_local type: forward args: @@ -154,6 +176,16 @@ plugins: threshold: 500 always_standby: true + - tag: query_is_apple_domain + type: sequence + args: + - matches: qname $geosite_apple + exec: $forward_dnspod_udp + - matches: "!resp_ip $geoip_cn" + exec: drop_resp + - matches: "!has_resp" + exec: $forward_xinfeng_udp + - tag: query_is_ddns_domain type: sequence args: @@ -211,6 +243,8 @@ plugins: exec: $lazy_cache - exec: $redirect - exec: jump has_resp_sequence + - exec: $query_is_apple_domain + - exec: jump has_resp_sequence - exec: $query_is_ddns_domain - exec: jump has_resp_sequence - exec: $query_is_whitelist_domain diff --git a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh index 6625276..0889f26 100755 --- a/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh +++ b/luci-app-mosdns/root/usr/share/mosdns/mosdns.sh @@ -147,7 +147,7 @@ v2dat_dump() { if [ "$configfile" = "/etc/mosdns/config.yaml" ]; then # default config v2dat unpack geoip -o /var/mosdns -f cn $v2dat_dir/geoip.dat - v2dat unpack geosite -o /var/mosdns -f cn -f 'geolocation-!cn' $v2dat_dir/geosite.dat + v2dat unpack geosite -o /var/mosdns -f cn -f apple -f 'geolocation-!cn' $v2dat_dir/geosite.dat [ "$adblock" -eq 1 ] && [ $(echo $ad_source | grep -c geosite.dat) -ge '1' ] && v2dat unpack geosite -o /var/mosdns -f category-ads-all $v2dat_dir/geosite.dat else # custom config