|
@@ -178,17 +178,23 @@ ln_start_bin() {
|
|
|
${file_func:-echolog " - ${ln_name}"} "$@" >/dev/null 2>&1 &
|
|
|
}
|
|
|
|
|
|
+add_dns_into_ipset() {
|
|
|
+ case "$1" in
|
|
|
+ gfw) ipset add gfwlist ${2%:*} 2>/dev/null ;;
|
|
|
+ oversea) ipset add oversea ${2%:*} 2>/dev/null ;;
|
|
|
+ *) ipset add ss_spec_wan_ac ${2%:*} nomatch 2>/dev/null ;;
|
|
|
+ esac
|
|
|
+}
|
|
|
+
|
|
|
start_dns() {
|
|
|
local ssrplus_dns="$(uci_get_by_type global pdnsd_enable 0)"
|
|
|
local dnsserver="$(uci_get_by_type global tunnel_forward 8.8.4.4:53)"
|
|
|
local run_mode="$(uci_get_by_type global run_mode)"
|
|
|
|
|
|
if [ "$ssrplus_dns" != "0" ]; then
|
|
|
- case "$run_mode" in
|
|
|
- gfw) ipset add gfwlist ${dnsserver%:*} 2>/dev/null ;;
|
|
|
- oversea) ipset add oversea ${dnsserver%:*} 2>/dev/null ;;
|
|
|
- *) ipset add ss_spec_wan_ac ${dnsserver%:*} nomatch 2>/dev/null ;;
|
|
|
- esac
|
|
|
+ if [ -n "$dnsserver" ]; then
|
|
|
+ add_dns_into_ipset $run_mode $dnsserver
|
|
|
+ fi
|
|
|
case "$ssrplus_dns" in
|
|
|
1)
|
|
|
ln_start_bin $(first_type dns2tcp) dns2tcp -L 127.0.0.1#$dns_port -R ${dnsserver/:/#}
|
|
@@ -199,6 +205,26 @@ start_dns() {
|
|
|
ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_dns_port $dnsserver 127.0.0.1:$dns_port -q
|
|
|
pdnsd_enable_flag=2
|
|
|
;;
|
|
|
+ 3)
|
|
|
+ local mosdns_ipv6="$(uci_get_by_type global mosdns_ipv6)"
|
|
|
+ local mosdns_dnsserver="$(uci_get_by_type global tunnel_forward_mosdns)"
|
|
|
+ output=$(for i in $(echo $mosdns_dnsserver | sed "s/,/ /g"); do
|
|
|
+ dnsserver=${i%:*}
|
|
|
+ dnsserver=${i##*/}
|
|
|
+ add_dns_into_ipset $run_mode $dnsserver
|
|
|
+ echo " - addr: $i"
|
|
|
+ echo " enable_pipeline: true"
|
|
|
+ done)
|
|
|
+
|
|
|
+ awk -v line=14 -v text="$output" 'NR == line+1 {print text} 1' /etc/ssrplus/mosdns-config.yaml | sed "s/DNS_PORT/$dns_port/g" > $TMP_PATH/mosdns-config.yaml
|
|
|
+ if [ "$mosdns_ipv6" == "0" ]; then
|
|
|
+ sed -i "s/DNS_MODE/main_sequence_with_IPv6/g" $TMP_PATH/mosdns-config.yaml
|
|
|
+ else
|
|
|
+ sed -i "s/DNS_MODE/main_sequence_disable_IPv6/g" $TMP_PATH/mosdns-config.yaml
|
|
|
+ fi
|
|
|
+ ln_start_bin $(first_type mosdns) mosdns start -c $TMP_PATH/mosdns-config.yaml
|
|
|
+ pdnsd_enable_flag=3
|
|
|
+ ;;
|
|
|
esac
|
|
|
|
|
|
if [ "$run_mode" = "router" ]; then
|
|
@@ -453,6 +479,33 @@ start_udp() {
|
|
|
esac
|
|
|
}
|
|
|
|
|
|
+shunt_dns_command() {
|
|
|
+ local shunt_dns_mode="$(uci_get_by_type global shunt_dns_mode)"
|
|
|
+ local shunt_dnsserver="$(uci_get_by_type global shunt_dnsserver)"
|
|
|
+ case "$shunt_dns_mode" in
|
|
|
+ 1)
|
|
|
+ ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port $shunt_dnsserver 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ ;;
|
|
|
+ 2)
|
|
|
+ local shunt_mosdns_ipv6="$(uci_get_by_type global shunt_mosdns_ipv6)"
|
|
|
+ local shunt_mosdns_dnsserver="$(uci_get_by_type global shunt_mosdns_dnsserver)"
|
|
|
+ output=$(for i in $(echo $shunt_mosdns_dnsserver | sed "s/,/ /g"); do
|
|
|
+ echo " - addr: $i"
|
|
|
+ echo " socks5: \"127.0.0.1:$tmp_port\""
|
|
|
+ echo " enable_pipeline: true"
|
|
|
+ done)
|
|
|
+ awk -v line=14 -v text="$output" 'NR == line+1 {print text} 1' /etc/ssrplus/mosdns-config.yaml | sed "s/DNS_PORT/$tmp_shunt_dns_port/g" > $TMP_PATH/mosdns-config-shunt.yaml
|
|
|
+
|
|
|
+ if [ "$shunt_mosdns_ipv6" == "0" ]; then
|
|
|
+ sed -i "s/DNS_MODE/main_sequence_with_IPv6/g" $TMP_PATH/mosdns-config-shunt.yaml
|
|
|
+ else
|
|
|
+ sed -i "s/DNS_MODE/main_sequence_disable_IPv6/g" $TMP_PATH/mosdns-config-shunt.yaml
|
|
|
+ fi
|
|
|
+ ln_start_bin $(first_type mosdns) mosdns start -c $TMP_PATH/mosdns-config-shunt.yaml
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+}
|
|
|
+
|
|
|
start_shunt() {
|
|
|
local type=$(uci_get_by_name $SHUNT_SERVER type)
|
|
|
case "$type" in
|
|
@@ -466,14 +519,14 @@ start_shunt() {
|
|
|
local tmp_port=$tmp_shunt_local_port
|
|
|
ln_start_bin $(first_type ${type}local ${type}-local) ${type}-local -c $shunt_dns_config_file
|
|
|
fi
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
echolog "shunt:$(get_name $type) Started!"
|
|
|
;;
|
|
|
v2ray)
|
|
|
local tmp_port=${tmp_local_port:-$tmp_shunt_local_port}
|
|
|
gen_config_file $SHUNT_SERVER $type 3 $tmp_shunt_port $tmp_port
|
|
|
ln_start_bin $(first_type xray v2ray) v2ray run -config $shunt_config_file
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
echolog "shunt:$($(first_type xray v2ray) version | head -1) Started!"
|
|
|
;;
|
|
|
trojan)
|
|
@@ -485,7 +538,7 @@ start_shunt() {
|
|
|
local tmp_port=$tmp_shunt_local_port
|
|
|
ln_start_bin $(first_type trojan) $type --config $shunt_dns_config_file
|
|
|
fi
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
echolog "shunt:$($(first_type trojan) --version 2>&1 | head -1) Started!"
|
|
|
;;
|
|
|
naiveproxy)
|
|
@@ -497,7 +550,7 @@ start_shunt() {
|
|
|
local tmp_port=$tmp_shunt_local_port
|
|
|
ln_start_bin $(first_type naive) naive --config $shunt_dns_config_file
|
|
|
fi
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
echolog "shunt:$($(first_type "naive") --version 2>&1 | head -1) Started!"
|
|
|
redir_udp=0
|
|
|
;;
|
|
@@ -510,7 +563,7 @@ start_shunt() {
|
|
|
gen_config_file $SHUNT_SERVER $type 3 $tmp_shunt_port $tmp_port
|
|
|
fi
|
|
|
ln_start_bin $(first_type hysteria) hysteria client --config $shunt_config_file
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
echolog "shunt:$($(first_type hysteria) version | awk '{print $1,$3}') Started!"
|
|
|
;;
|
|
|
tuic)
|
|
@@ -522,7 +575,7 @@ start_shunt() {
|
|
|
[ -n "$tmp_local_port" ] && tmp_port=$tmp_local_port || tmp_port=$tmp_shunt_local_port
|
|
|
gen_config_file $SHUNT_SERVER $type 3 $tmp_port # make a tuic socks :304
|
|
|
ln_start_bin $(first_type tuic-client) tuic-client --config $shunt_dns_config_file
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
echolog "Netflix Separated Shunt Server:tuic-client $($(first_type tuic-client) --version) Started!"
|
|
|
# FIXME: ipt2socks cannot handle udp reply from tuic
|
|
|
#redir_udp=0
|
|
@@ -532,7 +585,7 @@ start_shunt() {
|
|
|
gen_config_file $SHUNT_SERVER $type 3 "10${tmp_shunt_port}" $tmp_port chain/$tmp_shunt_port #make a redir:303 and a socks:304
|
|
|
#echo "debug \$tmp_port=$tmp_port, \$tmp_shunt_port=${tmp_shunt_port}, \$tmp_shunt_local_port=$tmp_shunt_local_port"
|
|
|
ln_start_bin $(first_type shadow-tls) shadow-tls config --config $chain_config_file
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:"${tmp_port}" 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
local chain_type=$(uci_get_by_name $SHUNT_SERVER chain_type)
|
|
|
case ${chain_type} in
|
|
|
vmess)
|
|
@@ -558,7 +611,7 @@ start_shunt() {
|
|
|
# local tmp_port=$tmp_shunt_local_port
|
|
|
# ln_start_bin $(first_type microsocks) microsocks -i 127.0.0.1 -p $tmp_port shunt-dns-ssr-plus
|
|
|
# fi
|
|
|
- # ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ # shunt_dns_command
|
|
|
# echolog "shunt:$type REDIRECT/TPROXY Started!"
|
|
|
# ;;
|
|
|
*)
|
|
@@ -570,7 +623,7 @@ start_shunt() {
|
|
|
local tmp_port=$tmp_shunt_local_port
|
|
|
ln_start_bin $(first_type microsocks) microsocks -i 127.0.0.1 -p $tmp_port shunt-dns-ssr-plus
|
|
|
fi
|
|
|
- ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port 8.8.8.8:53 127.0.0.1:$tmp_shunt_dns_port -q
|
|
|
+ shunt_dns_command
|
|
|
echolog "shunt:$type REDIRECT/TPROXY Started!"
|
|
|
;;
|
|
|
esac
|
|
@@ -1096,6 +1149,7 @@ reset() {
|
|
|
set shadowsocksr.@global[0].switch_timeout='5'
|
|
|
set shadowsocksr.@global[0].switch_try_count='3'
|
|
|
# set shadowsocksr.@global[0].default_packet_encoding='xudp'
|
|
|
+ set shadowsocksr.@global[0].shunt_dns='1'
|
|
|
set shadowsocksr.@global[0].gfwlist_url='https://fastly.jsdelivr.net/gh/YW5vbnltb3Vz/domain-list-community@release/gfwlist.txt'
|
|
|
set shadowsocksr.@global[0].chnroute_url='https://ispip.clang.cn/all_cn.txt'
|
|
|
set shadowsocksr.@global[0].nfip_url='https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt'
|