update 2023-11-07 14:11:44

This commit is contained in:
github-actions[bot] 2023-11-07 14:11:44 +08:00
parent 8b9fbf736c
commit 01dc5a8f36
3 changed files with 29 additions and 22 deletions

View File

@ -38,6 +38,7 @@ tmp_shunt_port="303" #shunt temporary port
tmp_shunt_local_port="304" #shunt socks temporary port tmp_shunt_local_port="304" #shunt socks temporary port
tmp_shunt_dns_port="305" #shunt dns2socks temporary port tmp_shunt_dns_port="305" #shunt dns2socks temporary port
tmp_tcp_local_port="306" #tcp socks temporary port tmp_tcp_local_port="306" #tcp socks temporary port
mosdns_config_file=
server_count=0 server_count=0
redir_tcp=0 redir_tcp=0
@ -218,70 +219,72 @@ start_dns() {
local mosdns_dnsleak="$(uci_get_by_type global mosdns_dnsleak)" local mosdns_dnsleak="$(uci_get_by_type global mosdns_dnsleak)"
local netflix_enable="$(uci_get_by_type global netflix_enable)" local netflix_enable="$(uci_get_by_type global netflix_enable)"
if [ "$run_mode" = "router" ] && [ -n "$chinadns_mosdns" ]; then if [ "$run_mode" = "router" ] && [ -n "$chinadns_mosdns" ]; then
cp /etc/ssrplus/mosdns-config-chinadns.yaml $TMP_PATH/mosdns-config-chinadns.yaml mosdns_config_file="$TMP_PATH/mosdns-config-chinadns.yaml"
cp /etc/ssrplus/mosdns-config-chinadns.yaml $mosdns_config_file
tmp=$(for i in $(echo $mosdns_dnsserver | sed "s/,/ /g"); do tmp=$(for i in $(echo $mosdns_dnsserver | sed "s/,/ /g"); do
dnsserver=${i%:*} dnsserver=${i%:*}
dnsserver=${i##*/} dnsserver=${i##*/}
add_dns_into_ipset $run_mode $dnsserver add_dns_into_ipset $run_mode $dnsserver
yq_ssr '.plugins[4].args.upstreams += [{"addr":"'"${i}"'","enable_pipeline":"true"}]' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[4].args.upstreams += [{"addr":"'"${i}"'","enable_pipeline":"true"}]' $mosdns_config_file
done) done)
if [ "$chinadns_mosdns" = "wan" ]; then if [ "$chinadns_mosdns" = "wan" ]; then
wandns=$(ifstatus wan | jsonfilter -e '@["dns-server"]' | sed 's/\[//g; s/\]//g' | sed 's/"//g' | sed 's/ //g' | sed 's/,/ /g') wandns=$(ifstatus wan | jsonfilter -e '@["dns-server"]' | sed 's/\[//g; s/\]//g' | sed 's/"//g' | sed 's/ //g' | sed 's/,/ /g')
tmp=$(for i in $(echo $wandns); do tmp=$(for i in $(echo $wandns); do
i="udp://$i:53" i="udp://$i:53"
yq_ssr '.plugins[5].args.upstreams += [{"addr":"'"${i}"'"}]' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[5].args.upstreams += [{"addr":"'"${i}"'"}]' $mosdns_config_file
done) done)
else else
tmp=$(for i in $(echo $chinadns_mosdns | sed "s/,/ /g"); do tmp=$(for i in $(echo $chinadns_mosdns | sed "s/,/ /g"); do
yq_ssr '.plugins[5].args.upstreams += [{"addr":"'"${i}"'"}]' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[5].args.upstreams += [{"addr":"'"${i}"'"}]' $mosdns_config_file
done) done)
fi fi
if [ "$mosdns_disable_ipv6" == "0" ]; then if [ "$mosdns_disable_ipv6" == "0" ]; then
yq_ssr '.plugins[10].args[0].exec="$remote_sequence_with_IPv6" | .plugins[12].args[0].exec="$remote_sequence_with_IPv6"' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[10].args[0].exec="$remote_sequence_with_IPv6" | .plugins[12].args[0].exec="$remote_sequence_with_IPv6"' $mosdns_config_file
else else
yq_ssr '.plugins[10].args[0].exec="$remote_sequence_disable_IPv6" | .plugins[12].args[0].exec="$remote_sequence_disable_IPv6"' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[10].args[0].exec="$remote_sequence_disable_IPv6" | .plugins[12].args[0].exec="$remote_sequence_disable_IPv6"' $mosdns_config_file
fi fi
if [ "$mosdns_dnsleak" != "0" ]; then if [ "$mosdns_dnsleak" != "0" ]; then
yq_ssr '.plugins[13].args.primary="query_is_remote_ip"' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[13].args.primary="query_is_remote_ip"' $mosdns_config_file
fi fi
yq_ssr '.plugins[16].args.listen="0.0.0.0:'${dns_port}'" | .plugins[17].args.listen="0.0.0.0:'${dns_port}'"' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[16].args.listen="0.0.0.0:'${dns_port}'" | .plugins[17].args.listen="0.0.0.0:'${dns_port}'"' $mosdns_config_file
if [ "$netflix_enable" == 1 ]; then if [ "$netflix_enable" == 1 ]; then
yq_ssr '.plugins |= (.[:4] + [{"tag": "netflix_domain", "type": "domain_set", "args": {"files": ["/etc/ssrplus/netflix.list"]}}] + .[4:])' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins |= (.[:4] + [{"tag": "netflix_domain", "type": "domain_set", "args": {"files": ["/etc/ssrplus/netflix.list"]}}] + .[4:])' $mosdns_config_file
yq_ssr '.plugins |= (.[:7] + [{"tag": "forward_netflix", "type": "forward", "args": {"upstreams": [{"addr":"udp://127.0.0.1:'"${tmp_shunt_dns_port}"'"}]}}] + .[7:])' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins |= (.[:7] + [{"tag": "forward_netflix", "type": "forward", "args": {"upstreams": [{"addr":"udp://127.0.0.1:'"${tmp_shunt_dns_port}"'"}]}}] + .[7:])' $mosdns_config_file
yq_ssr '.plugins |= (.[:11] + [{"tag": "netflix_sequence", "type": "sequence", "args": [{"exec": "$forward_netflix"}]}] + .[11:])' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins |= (.[:11] + [{"tag": "netflix_sequence", "type": "sequence", "args": [{"exec": "$forward_netflix"}]}] + .[11:])' $mosdns_config_file
yq_ssr '.plugins |= (.[:14] + [{"tag": "query_is_netflix_domain", "type": "sequence", "args": [{"matches": "qname $netflix_domain", "exec": "$netflix_sequence"}, {"exec": "ipset netflix,inet,24"}]}] + .[14:])' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins |= (.[:14] + [{"tag": "query_is_netflix_domain", "type": "sequence", "args": [{"matches": "qname $netflix_domain", "exec": "$netflix_sequence"}, {"exec": "ipset netflix,inet,24"}]}] + .[14:])' $mosdns_config_file
yq_ssr '.plugins[19].args |= (.[:3] + [{"exec": "$query_is_netflix_domain"}, {"exec": "jump has_resp_sequence"}] + .[3:])' $TMP_PATH/mosdns-config-chinadns.yaml yq_ssr '.plugins[19].args |= (.[:3] + [{"exec": "$query_is_netflix_domain"}, {"exec": "jump has_resp_sequence"}] + .[3:])' $mosdns_config_file
fi fi
pdnsd_enable_flag=3 pdnsd_enable_flag=3
ln_start_bin $(first_type mosdns) mosdns start -c $TMP_PATH/mosdns-config-chinadns.yaml ln_start_bin $(first_type mosdns) mosdns start -c $mosdns_config_file
cat <<-EOF >> "$TMP_DNSMASQ_PATH/chinadns_fixed_server.conf" cat <<-EOF >> "$TMP_DNSMASQ_PATH/chinadns_fixed_server.conf"
no-poll no-poll
no-resolv no-resolv
server=127.0.0.1#$dns_port server=127.0.0.1#$dns_port
EOF EOF
else else
cp /etc/ssrplus/mosdns-config.yaml $TMP_PATH/mosdns-config.yaml mosdns_config_file="$TMP_PATH/mosdns-config.yaml"
cp /etc/ssrplus/mosdns-config.yaml $mosdns_config_file
tmp=$(for i in $(echo $mosdns_dnsserver | sed "s/,/ /g"); do tmp=$(for i in $(echo $mosdns_dnsserver | sed "s/,/ /g"); do
dnsserver=${i%:*} dnsserver=${i%:*}
dnsserver=${i##*/} dnsserver=${i##*/}
add_dns_into_ipset $run_mode $dnsserver add_dns_into_ipset $run_mode $dnsserver
yq_ssr '.plugins[1].args.upstreams += [{"addr":"'"${i}"'","enable_pipeline":"true"}]' $TMP_PATH/mosdns-config.yaml yq_ssr '.plugins[1].args.upstreams += [{"addr":"'"${i}"'","enable_pipeline":"true"}]' $mosdns_config_file
done) done)
if [ "$mosdns_disable_ipv6" == "0" ]; then if [ "$mosdns_disable_ipv6" == "0" ]; then
yq_ssr '.plugins[4].args.entry="main_sequence_with_IPv6" | .plugins[5].args.entry="main_sequence_with_IPv6"' $TMP_PATH/mosdns-config.yaml yq_ssr '.plugins[4].args.entry="main_sequence_with_IPv6" | .plugins[5].args.entry="main_sequence_with_IPv6"' $mosdns_config_file
else else
yq_ssr '.plugins[4].args.entry="main_sequence_disable_IPv6" | .plugins[5].args.entry="main_sequence_disable_IPv6"' $TMP_PATH/mosdns-config.yaml yq_ssr '.plugins[4].args.entry="main_sequence_disable_IPv6" | .plugins[5].args.entry="main_sequence_disable_IPv6"' $mosdns_config_file
fi fi
yq_ssr '.plugins[4].args.listen="0.0.0.0:'${dns_port}'" | .plugins[5].args.listen="0.0.0.0:'${dns_port}'"' $TMP_PATH/mosdns-config.yaml yq_ssr '.plugins[4].args.listen="0.0.0.0:'${dns_port}'" | .plugins[5].args.listen="0.0.0.0:'${dns_port}'"' $mosdns_config_file
pdnsd_enable_flag=3 pdnsd_enable_flag=3
ln_start_bin $(first_type mosdns) mosdns start -c $TMP_PATH/mosdns-config.yaml ln_start_bin $(first_type mosdns) mosdns start -c $mosdns_config_file
fi fi
;; ;;
esac esac

View File

@ -1,3 +1,7 @@
# Author: sbwml
# Origin from repository: https://github.com/sbwml/luci-app-mosdns
# Reference: https://github.com/sbwml/luci-app-mosdns/blob/v5/luci-app-mosdns/root/usr/share/mosdns/default.yaml
# Modify by: XiaoliChan
log: log:
level: info level: info
plugins: plugins:

View File

@ -111,8 +111,8 @@ while [ "1" == "1" ]; do #死循环
logger -t "$NAME" "mosdns tunnel error.restart!" logger -t "$NAME" "mosdns tunnel error.restart!"
echolog "mosdns tunnel error.restart!" echolog "mosdns tunnel error.restart!"
dnsserver=$(uci_get_by_type global tunnel_forward 8.8.4.4:53) dnsserver=$(uci_get_by_type global tunnel_forward 8.8.4.4:53)
kill -9 $(busybox ps -w | grep $TMP_BIN_PATH/mosdns | grep -v grep | awk '{print $1}') >/dev/null 2>&1 kill -9 $(busybox ps -w | grep $TMP_BIN_PATH/mosdns | grep -v grep | grep $mosdns_config_file | awk '{print $1}') >/dev/null 2>&1
ln_start_bin $(first_type mosdns) mosdns start -c /etc/mosdns/config.yaml ln_start_bin $(first_type mosdns) mosdns start -c $mosdns_config_file
fi fi
fi fi
#chinadns-ng #chinadns-ng