From 786d552d2f3368a78d7de18851450d1a257becaa Mon Sep 17 00:00:00 2001 From: Xiaoli Chan <2209553467@qq.com> Date: Wed, 25 Oct 2023 17:00:45 +0800 Subject: [PATCH 1/7] [DNS] Add mosdns support Signed-off-by: Xiaoli Chan <2209553467@qq.com> --- .../model/cbi/shadowsocksr/advanced.lua | 26 ++++++++++ .../luasrc/model/cbi/shadowsocksr/client.lua | 9 +++- .../luasrc/model/cbi/shadowsocksr/status.lua | 4 +- luci-app-ssr-plus/po/zh-cn/ssr-plus.po | 15 ++++++ .../root/etc/init.d/shadowsocksr | 51 +++++++++++++++---- .../root/etc/ssrplus/mosdns-config-shunt.yaml | 35 +++++++++++++ .../root/etc/ssrplus/mosdns-config.yaml | 34 +++++++++++++ luci-app-ssr-plus/root/usr/bin/ssr-monitor | 10 ++++ 8 files changed, 172 insertions(+), 12 deletions(-) create mode 100644 luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml create mode 100644 luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua index cfb2ea4e2a4..602ab9b74dd 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua @@ -57,6 +57,32 @@ o:value("https://ispip.clang.cn/all_cn_cidr.txt", translate("Clang.CN.CIDR")) o:value("https://fastly.jsdelivr.net/gh/gaoyifan/china-operator-ip@ip-lists/china.txt", translate("china-operator-ip")) o.default = "https://ispip.clang.cn/all_cn.txt" +o = s:option(ListValue, "shunt_dns_mode", translate("DNS Query Mode For Shunt Mode")) +o:value("1", translate("Use DNS2SOCKS query and cache")) +o:value("2", translate("Use MOSDNS query")) +o.default = 1 + +o = s:option(Value, "shunt_dns_server", translate("Anti-pollution DNS Server For Shunt Mode")) +o:value("8.8.4.4:53", translate("Google Public DNS (8.8.4.4)")) +o:value("8.8.8.8:53", translate("Google Public DNS (8.8.8.8)")) +o:value("208.67.222.222:53", translate("OpenDNS (208.67.222.222)")) +o:value("208.67.220.220:53", translate("OpenDNS (208.67.220.220)")) +o:value("209.244.0.3:53", translate("Level 3 Public DNS (209.244.0.3)")) +o:value("209.244.0.4:53", translate("Level 3 Public DNS (209.244.0.4)")) +o:value("4.2.2.1:53", translate("Level 3 Public DNS (4.2.2.1)")) +o:value("4.2.2.2:53", translate("Level 3 Public DNS (4.2.2.2)")) +o:value("4.2.2.3:53", translate("Level 3 Public DNS (4.2.2.3)")) +o:value("4.2.2.4:53", translate("Level 3 Public DNS (4.2.2.4)")) +o:value("1.1.1.1:53", translate("Cloudflare DNS (1.1.1.1)")) +o:depends("shunt_dns_mode") +o.description = translate("Custom DNS Server format as IP:PORT (default: 8.8.4.4:53)") +o.datatype = "ip4addrport" + +o = s:option(Flag, "shunt_mosdns_ipv6", translate("Disable IPv6 In MOSDNS Query Mode (Shunt Mode)")) +o:depends({shunt_dns_mode = "2"}) +o.rmempty = false +o.default = "0" + o = s:option(Flag, "netflix_enable", translate("Enable Netflix Mode")) o.rmempty = false diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua index 482949c54a6..8e66f4f7f12 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua @@ -48,7 +48,7 @@ for _, key in pairs(key_table) do o:value(key, server_table[key]) end -if uci:get_first("shadowsocksr", 'global', 'netflix_enable', '0') ~= '0' then +if uci:get_first("shadowsocksr", 'global', 'netflix_enable', '0') == '1' then o = s:option(ListValue, "netflix_server", translate("Netflix Node")) o:value("nil", translate("Disable")) o:value("same", translate("Same as Global Server")) @@ -92,6 +92,7 @@ o.default = 1 o = s:option(ListValue, "pdnsd_enable", translate("Resolve Dns Mode")) o:value("1", translate("Use DNS2TCP query")) o:value("2", translate("Use DNS2SOCKS query and cache")) +o:value("3", translate("Use MOSDNS query")) o:value("0", translate("Use Local DNS Service listen port 5335")) o.default = 1 @@ -111,9 +112,15 @@ o:value("114.114.114.114:53", translate("Oversea Mode DNS-1 (114.114.114.114)")) o:value("114.114.115.115:53", translate("Oversea Mode DNS-2 (114.114.115.115)")) o:depends("pdnsd_enable", "1") o:depends("pdnsd_enable", "2") +o:depends("pdnsd_enable", "3") o.description = translate("Custom DNS Server format as IP:PORT (default: 8.8.4.4:53)") o.datatype = "ip4addrport" +o = s:option(Flag, "mosdns_ipv6", translate("Disable IPv6 in MOSDNS query mode")) +o:depends({pdnsd_enable = "3"}) +o.rmempty = false +o.default = "0" + if is_finded("chinadns-ng") then o = s:option(Value, "chinadns_forward", translate("Domestic DNS Server")) o:value("", translate("Disable ChinaDNS-NG")) diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua index 1400c91495d..dfe2a1b085b 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua @@ -112,7 +112,7 @@ else s.value = style_blue .. bold_on .. translate("Not Running") .. bold_off .. font_off end -if uci:get_first("shadowsocksr", 'global', 'pdnsd_enable', '0') ~= '0' then +if uci:get_first("shadowsocksr", 'global', 'pdnsd_enable', '0') == '1' then s = m:field(DummyValue, "pdnsd_run", translate("DNS Anti-pollution")) s.rawhtml = true if pdnsd_run == 1 then @@ -169,7 +169,7 @@ s.rawhtml = true s.template = "shadowsocksr/refresh" s.value = ip_count .. " " .. translate("Records") -if uci:get_first("shadowsocksr", 'global', 'netflix_enable', '0') ~= '0' then +if uci:get_first("shadowsocksr", 'global', 'netflix_enable', '0') == '1' then s = m:field(DummyValue, "nfip_data", translate("Netflix IP Data")) s.rawhtml = true s.template = "shadowsocksr/refresh" diff --git a/luci-app-ssr-plus/po/zh-cn/ssr-plus.po b/luci-app-ssr-plus/po/zh-cn/ssr-plus.po index aa317d88b64..70b18dca4f3 100644 --- a/luci-app-ssr-plus/po/zh-cn/ssr-plus.po +++ b/luci-app-ssr-plus/po/zh-cn/ssr-plus.po @@ -531,6 +531,21 @@ msgstr "使用 DNS2TCP 查询" msgid "Use DNS2SOCKS query and cache" msgstr "使用 DNS2SOCKS 查询并缓存" +msgid "Use MOSDNS query" +msgstr "使用 MOSDNS 查询" + +msgid "Disable IPv6 in MOSDNS query mode" +msgstr "禁止 MOSDNS 返回 IPv6 记录" + +msgid "DNS Query Mode For Shunt Mode" +msgstr "分流模式下的 DNS 查询模式" + +msgid "Anti-pollution DNS Server For Shunt Mode" +msgstr "分流模式下的访问国外域名 DNS 服务器" + +msgid "Disable IPv6 In MOSDNS Query Mode (Shunt Mode)" +msgstr "禁止 MOSDNS 返回 IPv6 记录 (分流模式)" + msgid "DNS Server IP:Port" msgstr "DNS 服务器 IP:Port" diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 932febedba0..70d55bc807d 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -199,6 +199,17 @@ 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)" + cat /etc/ssrplus/mosdns-config.yaml | sed "s/DNS_SERVER/$dnsserver/g" | 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 +464,27 @@ start_udp() { esac } +shunt_dns_command() { + local shunt_dns_mode="$(uci_get_by_type global shunt_dns_mode)" + local shunt_dns_server="$(uci_get_by_type global shunt_dns_server)" + local shunt_mosdns_ipv6="$(uci_get_by_type global shunt_mosdns_ipv6)" + case "$shunt_dns_mode" in + 1) + ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_port $shunt_dns_server 127.0.0.1:$tmp_shunt_dns_port -q + ;; + 2) + cat /etc/ssrplus/mosdns-config-shunt.yaml | sed "s/DNS_SERVER/$shunt_dns_server/g" | sed "s/SOCKS_PORT/$tmp_port/g" | 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 +498,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 +517,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 +529,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 +542,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 +554,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 +564,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 +590,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 +602,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 +1128,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' diff --git a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml new file mode 100644 index 00000000000..b173103983a --- /dev/null +++ b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml @@ -0,0 +1,35 @@ +log: + level: info +plugins: + - tag: forward_google + type: forward + args: + upstreams: + - addr: tcp://DNS_SERVER + socks5: "127.0.0.1:SOCKS_PORT" + + - tag: main_sequence_disable_IPv6 + type: sequence + args: + - exec: prefer_ipv4 + - exec: $forward_google + - matches: + - qtype 28 65 + exec: reject 0 + + - tag: main_sequence_with_IPv6 + type: sequence + args: + - exec: $forward_google + + - tag: udp_server + type: udp_server + args: + entry: DNS_MODE + listen: 0.0.0.0:DNS_PORT + + - tag: tcp_server + type: tcp_server + args: + entry: DNS_MODE + listen: 0.0.0.0:DNS_PORT \ No newline at end of file diff --git a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml new file mode 100644 index 00000000000..ad9e6b0aa98 --- /dev/null +++ b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml @@ -0,0 +1,34 @@ +log: + level: info +plugins: + - tag: forward_google + type: forward + args: + upstreams: + - addr: tcp://DNS_SERVER + + - tag: main_sequence_disable_IPv6 + type: sequence + args: + - exec: prefer_ipv4 + - exec: $forward_google + - matches: + - qtype 28 65 + exec: reject 0 + + - tag: main_sequence_with_IPv6 + type: sequence + args: + - exec: $forward_google + + - tag: udp_server + type: udp_server + args: + entry: DNS_MODE + listen: 0.0.0.0:DNS_PORT + + - tag: tcp_server + type: tcp_server + args: + entry: DNS_MODE + listen: 0.0.0.0:DNS_PORT \ No newline at end of file diff --git a/luci-app-ssr-plus/root/usr/bin/ssr-monitor b/luci-app-ssr-plus/root/usr/bin/ssr-monitor index fb9ed57e77d..f637d5090a9 100755 --- a/luci-app-ssr-plus/root/usr/bin/ssr-monitor +++ b/luci-app-ssr-plus/root/usr/bin/ssr-monitor @@ -104,6 +104,16 @@ while [ "1" == "1" ]; do #死循环 ln_start_bin $(first_type microsocks) microsocks -i 127.0.0.1 -p $tmp_dns_port ssrplus-dns ln_start_bin $(first_type dns2socks) dns2socks 127.0.0.1:$tmp_dns_port $dnsserver 127.0.0.1:$dns_port -q fi + #mosdns + elif [ "$pdnsd_process" -eq 3 ]; then + icount=$(busybox ps -w | grep $TMP_BIN_PATH/mosdns | grep -v grep | wc -l) + if [ "$icount" -lt 1 ]; then #如果进程挂掉就重启它 + logger -t "$NAME" "mosdns tunnel error.restart!" + echolog "mosdns tunnel error.restart!" + 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 + ln_start_bin $(first_type mosdns) mosdns start -c /etc/mosdns/config.yaml + fi fi #chinadns-ng if [ "$(uci -q get "dhcp.@dnsmasq[0]._unused_ssrp_changed")" = "1" ]; then From 81df8d93bbbad627904348cc8bdaf8f9b51d5c89 Mon Sep 17 00:00:00 2001 From: Xiaoli Chan <2209553467@qq.com> Date: Wed, 25 Oct 2023 19:23:53 +0800 Subject: [PATCH 2/7] [DNS] Add mosdns in luci app makefile Signed-off-by: Xiaoli Chan <2209553467@qq.com> --- luci-app-ssr-plus/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/luci-app-ssr-plus/Makefile b/luci-app-ssr-plus/Makefile index 135c38b6716..e6339807397 100644 --- a/luci-app-ssr-plus/Makefile +++ b/luci-app-ssr-plus/Makefile @@ -40,6 +40,7 @@ LUCI_DEPENDS:= \ +PACKAGE_$(PKG_NAME)_INCLUDE_Xray:curl \ +PACKAGE_$(PKG_NAME)_INCLUDE_Xray:xray-core \ +PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG:chinadns-ng \ + +PACKAGE_$(PKG_NAME)_INCLUDE_MosDNS:mosdns \ +PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria:hysteria \ +PACKAGE_$(PKG_NAME)_INCLUDE_Tuic_Client:tuic-client \ +PACKAGE_$(PKG_NAME)_INCLUDE_Shadow_TLS:shadow-tls \ @@ -116,6 +117,10 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG bool "Include ChinaDNS-NG" default y +config PACKAGE_$(PKG_NAME)_INCLUDE_MosDNS + bool "Include MosDNS" + default n + config PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria bool "Include Hysteria" select PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG From 80fb03aa83e686e74004dc6340764cea944c41a7 Mon Sep 17 00:00:00 2001 From: Xiaoli Chan <2209553467@qq.com> Date: Wed, 25 Oct 2023 21:19:44 +0800 Subject: [PATCH 3/7] [DNS] self review Signed-off-by: Xiaoli Chan <2209553467@qq.com> --- luci-app-ssr-plus/root/etc/init.d/shadowsocksr | 5 ++--- .../root/etc/ssrplus/mosdns-config-shunt.yaml | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 70d55bc807d..1279ba0c567 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -475,16 +475,15 @@ shunt_dns_command() { 2) cat /etc/ssrplus/mosdns-config-shunt.yaml | sed "s/DNS_SERVER/$shunt_dns_server/g" | sed "s/SOCKS_PORT/$tmp_port/g" | 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 + sed -i "s/DNS_MODE/shunt_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 + sed -i "s/DNS_MODE/shunt_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 diff --git a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml index b173103983a..865d352d638 100644 --- a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml +++ b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml @@ -1,26 +1,26 @@ log: level: info plugins: - - tag: forward_google + - tag: forward_google_shunt type: forward args: upstreams: - addr: tcp://DNS_SERVER socks5: "127.0.0.1:SOCKS_PORT" - - tag: main_sequence_disable_IPv6 + - tag: shunt_sequence_disable_IPv6 type: sequence args: - exec: prefer_ipv4 - - exec: $forward_google + - exec: $forward_google_shunt - matches: - qtype 28 65 exec: reject 0 - - tag: main_sequence_with_IPv6 + - tag: shunt_sequence_with_IPv6 type: sequence args: - - exec: $forward_google + - exec: $forward_google_shunt - tag: udp_server type: udp_server From 108fd1ddfe97b657c27cf1a1830475bd2fc87c5a Mon Sep 17 00:00:00 2001 From: Xiaoli Chan <2209553467@qq.com> Date: Thu, 26 Oct 2023 14:24:15 +0800 Subject: [PATCH 4/7] [DNS] enable MosDNS features Signed-off-by: Xiaoli Chan <2209553467@qq.com> --- luci-app-ssr-plus/Makefile | 5 ++- .../model/cbi/shadowsocksr/advanced.lua | 37 ++++++++++++------- .../luasrc/model/cbi/shadowsocksr/client.lua | 15 ++++++-- luci-app-ssr-plus/po/zh-cn/ssr-plus.po | 4 +- .../root/etc/init.d/shadowsocksr | 23 +++++++++--- .../root/etc/ssrplus/mosdns-config-shunt.yaml | 14 +++++-- .../root/etc/ssrplus/mosdns-config.yaml | 13 ++++++- 7 files changed, 81 insertions(+), 30 deletions(-) diff --git a/luci-app-ssr-plus/Makefile b/luci-app-ssr-plus/Makefile index e6339807397..4ea0f97091b 100644 --- a/luci-app-ssr-plus/Makefile +++ b/luci-app-ssr-plus/Makefile @@ -1,8 +1,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus -PKG_VERSION:=187 -PKG_RELEASE:=2 +PKG_VERSION:=188 +PKG_RELEASE:=3 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NONE_V2RAY \ @@ -10,6 +10,7 @@ PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ + CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_MosDNS \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Tuic_Client \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadow_TLS \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_IPT2Socks \ diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua index 602ab9b74dd..ea08f58bda5 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua @@ -57,12 +57,23 @@ o:value("https://ispip.clang.cn/all_cn_cidr.txt", translate("Clang.CN.CIDR")) o:value("https://fastly.jsdelivr.net/gh/gaoyifan/china-operator-ip@ip-lists/china.txt", translate("china-operator-ip")) o.default = "https://ispip.clang.cn/all_cn.txt" +o = s:option(Flag, "netflix_enable", translate("Enable Netflix Mode")) +o.rmempty = false + +o = s:option(Value, "nfip_url", translate("nfip_url")) +o:value("https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt", translate("Netflix IP Only")) +o:value("https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/getflix.txt", translate("Netflix and AWS")) +o.default = "https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt" +o.description = translate("Customize Netflix IP Url") +o:depends("netflix_enable", "1") + o = s:option(ListValue, "shunt_dns_mode", translate("DNS Query Mode For Shunt Mode")) o:value("1", translate("Use DNS2SOCKS query and cache")) o:value("2", translate("Use MOSDNS query")) +o:depends("netflix_enable", "1") o.default = 1 -o = s:option(Value, "shunt_dns_server", translate("Anti-pollution DNS Server For Shunt Mode")) +o = s:option(Value, "shunt_dnsserver", translate("Anti-pollution DNS Server For Shunt Mode")) o:value("8.8.4.4:53", translate("Google Public DNS (8.8.4.4)")) o:value("8.8.8.8:53", translate("Google Public DNS (8.8.8.8)")) o:value("208.67.222.222:53", translate("OpenDNS (208.67.222.222)")) @@ -74,25 +85,25 @@ o:value("4.2.2.2:53", translate("Level 3 Public DNS (4.2.2.2)")) o:value("4.2.2.3:53", translate("Level 3 Public DNS (4.2.2.3)")) o:value("4.2.2.4:53", translate("Level 3 Public DNS (4.2.2.4)")) o:value("1.1.1.1:53", translate("Cloudflare DNS (1.1.1.1)")) -o:depends("shunt_dns_mode") +o:depends("shunt_dns_mode", "1") o.description = translate("Custom DNS Server format as IP:PORT (default: 8.8.4.4:53)") o.datatype = "ip4addrport" +o = s:option(ListValue, "shunt_mosdns_dnsserver", translate("Anti-pollution DNS Server")) +o:value("tcp://8.8.4.4:53,tcp://8.8.8.8:53", translate("Google Public DNS")) +o:value("tcp://208.67.222.222:53,tcp://208.67.220.220:53", translate("OpenDNS")) +o:value("tcp://209.244.0.3:53,tcp://209.244.0.4:53", translate("Level 3 Public DNS-1 (209.244.0.3-4)")) +o:value("tcp://4.2.2.1:53,tcp://4.2.2.2:53", translate("Level 3 Public DNS-2 (4.2.2.1-2)")) +o:value("tcp://4.2.2.3:53,tcp://4.2.2.4:53", translate("Level 3 Public DNS-3 (4.2.2.3-4)")) +o:value("tcp://1.1.1.1:53,tcp://1.0.0.1:53", translate("Cloudflare DNS")) +o:depends("shunt_dns_mode", "2") +o.description = translate("Custom DNS Server for mosdns") + o = s:option(Flag, "shunt_mosdns_ipv6", translate("Disable IPv6 In MOSDNS Query Mode (Shunt Mode)")) -o:depends({shunt_dns_mode = "2"}) +o:depends("shunt_dns_mode", "2") o.rmempty = false o.default = "0" -o = s:option(Flag, "netflix_enable", translate("Enable Netflix Mode")) -o.rmempty = false - -o = s:option(Value, "nfip_url", translate("nfip_url")) -o:value("https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt", translate("Netflix IP Only")) -o:value("https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/getflix.txt", translate("Netflix and AWS")) -o.default = "https://fastly.jsdelivr.net/gh/QiuSimons/Netflix_IP/NF_only.txt" -o.description = translate("Customize Netflix IP Url") -o:depends("netflix_enable", "1") - o = s:option(Flag, "adblock", translate("Enable adblock")) o.rmempty = false diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua index 8e66f4f7f12..339efb0b58d 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua @@ -92,7 +92,7 @@ o.default = 1 o = s:option(ListValue, "pdnsd_enable", translate("Resolve Dns Mode")) o:value("1", translate("Use DNS2TCP query")) o:value("2", translate("Use DNS2SOCKS query and cache")) -o:value("3", translate("Use MOSDNS query")) +o:value("3", translate("Use MOSDNS query (Not Support Oversea Mode)")) o:value("0", translate("Use Local DNS Service listen port 5335")) o.default = 1 @@ -112,12 +112,21 @@ o:value("114.114.114.114:53", translate("Oversea Mode DNS-1 (114.114.114.114)")) o:value("114.114.115.115:53", translate("Oversea Mode DNS-2 (114.114.115.115)")) o:depends("pdnsd_enable", "1") o:depends("pdnsd_enable", "2") -o:depends("pdnsd_enable", "3") o.description = translate("Custom DNS Server format as IP:PORT (default: 8.8.4.4:53)") o.datatype = "ip4addrport" +o = s:option(ListValue, "tunnel_forward_mosdns", translate("Anti-pollution DNS Server")) +o:value("tcp://8.8.4.4:53,tcp://8.8.8.8:53", translate("Google Public DNS")) +o:value("tcp://208.67.222.222:53,tcp://208.67.220.220:53", translate("OpenDNS")) +o:value("tcp://209.244.0.3:53,tcp://209.244.0.4:53", translate("Level 3 Public DNS-1 (209.244.0.3-4)")) +o:value("tcp://4.2.2.1:53,tcp://4.2.2.2:53", translate("Level 3 Public DNS-2 (4.2.2.1-2)")) +o:value("tcp://4.2.2.3:53,tcp://4.2.2.4:53", translate("Level 3 Public DNS-3 (4.2.2.3-4)")) +o:value("tcp://1.1.1.1:53,tcp://1.0.0.1:53", translate("Cloudflare DNS")) +o:depends("pdnsd_enable", "3") +o.description = translate("Custom DNS Server for mosdns") + o = s:option(Flag, "mosdns_ipv6", translate("Disable IPv6 in MOSDNS query mode")) -o:depends({pdnsd_enable = "3"}) +o:depends("pdnsd_enable", "3") o.rmempty = false o.default = "0" diff --git a/luci-app-ssr-plus/po/zh-cn/ssr-plus.po b/luci-app-ssr-plus/po/zh-cn/ssr-plus.po index 70b18dca4f3..1e33f7a7ae1 100644 --- a/luci-app-ssr-plus/po/zh-cn/ssr-plus.po +++ b/luci-app-ssr-plus/po/zh-cn/ssr-plus.po @@ -531,8 +531,8 @@ msgstr "使用 DNS2TCP 查询" msgid "Use DNS2SOCKS query and cache" msgstr "使用 DNS2SOCKS 查询并缓存" -msgid "Use MOSDNS query" -msgstr "使用 MOSDNS 查询" +msgid "Use MOSDNS query (Not Support Oversea Mode)" +msgstr "使用 MOSDNS 查询 (不支持海外用户回国模式)" msgid "Disable IPv6 in MOSDNS query mode" msgstr "禁止 MOSDNS 返回 IPv6 记录" diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index 1279ba0c567..bf4d953b99e 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -201,7 +201,13 @@ start_dns() { ;; 3) local mosdns_ipv6="$(uci_get_by_type global mosdns_ipv6)" - cat /etc/ssrplus/mosdns-config.yaml | sed "s/DNS_SERVER/$dnsserver/g" | sed "s/DNS_PORT/$dns_port/g" > $TMP_PATH/mosdns-config.yaml + local mosdns_dnsserver="$(uci_get_by_type global tunnel_forward_mosdns)" + output=$(for i in $(echo $mosdns_dnsserver | sed "s/,/ /g"); do + 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 @@ -466,14 +472,21 @@ start_udp() { shunt_dns_command() { local shunt_dns_mode="$(uci_get_by_type global shunt_dns_mode)" - local shunt_dns_server="$(uci_get_by_type global shunt_dns_server)" - local shunt_mosdns_ipv6="$(uci_get_by_type global shunt_mosdns_ipv6)" + 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_dns_server 127.0.0.1:$tmp_shunt_dns_port -q + 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) - cat /etc/ssrplus/mosdns-config-shunt.yaml | sed "s/DNS_SERVER/$shunt_dns_server/g" | sed "s/SOCKS_PORT/$tmp_port/g" | sed "s/DNS_PORT/$tmp_shunt_dns_port/g" > $TMP_PATH/mosdns-config-shunt.yaml + 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-shunt.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/shunt_sequence_with_IPv6/g" $TMP_PATH/mosdns-config-shunt.yaml else diff --git a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml index 865d352d638..c3d5e5b3f9d 100644 --- a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml +++ b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml @@ -1,16 +1,22 @@ log: level: info plugins: + - tag: lazy_cache + type: cache + args: + size: 8000 + lazy_cache_ttl: 86400 + - tag: forward_google_shunt type: forward args: + concurrent: 2 upstreams: - - addr: tcp://DNS_SERVER - socks5: "127.0.0.1:SOCKS_PORT" - tag: shunt_sequence_disable_IPv6 type: sequence args: + - exec: $lazy_cache - exec: prefer_ipv4 - exec: $forward_google_shunt - matches: @@ -20,6 +26,7 @@ plugins: - tag: shunt_sequence_with_IPv6 type: sequence args: + - exec: $lazy_cache - exec: $forward_google_shunt - tag: udp_server @@ -32,4 +39,5 @@ plugins: type: tcp_server args: entry: DNS_MODE - listen: 0.0.0.0:DNS_PORT \ No newline at end of file + listen: 0.0.0.0:DNS_PORT + diff --git a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml index ad9e6b0aa98..a0b9f5c5617 100644 --- a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml +++ b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config.yaml @@ -1,15 +1,22 @@ log: level: info plugins: + - tag: lazy_cache + type: cache + args: + size: 8000 + lazy_cache_ttl: 86400 + - tag: forward_google type: forward args: + concurrent: 2 upstreams: - - addr: tcp://DNS_SERVER - tag: main_sequence_disable_IPv6 type: sequence args: + - exec: $lazy_cache - exec: prefer_ipv4 - exec: $forward_google - matches: @@ -19,6 +26,7 @@ plugins: - tag: main_sequence_with_IPv6 type: sequence args: + - exec: $lazy_cache - exec: $forward_google - tag: udp_server @@ -31,4 +39,5 @@ plugins: type: tcp_server args: entry: DNS_MODE - listen: 0.0.0.0:DNS_PORT \ No newline at end of file + listen: 0.0.0.0:DNS_PORT + From 5b18dfe784af25724bd065b2991c37bd492b5061 Mon Sep 17 00:00:00 2001 From: Xiaoli Chan <2209553467@qq.com> Date: Thu, 26 Oct 2023 22:19:40 +0800 Subject: [PATCH 5/7] [MosDNS] Less file Signed-off-by: Xiaoli Chan <2209553467@qq.com> --- .../root/etc/init.d/shadowsocksr | 6 +-- .../root/etc/ssrplus/mosdns-config-shunt.yaml | 43 ------------------- 2 files changed, 3 insertions(+), 46 deletions(-) delete mode 100644 luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index bf4d953b99e..b589fbf73b0 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -485,12 +485,12 @@ shunt_dns_command() { 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-shunt.yaml | sed "s/DNS_PORT/$tmp_shunt_dns_port/g" > $TMP_PATH/mosdns-config-shunt.yaml + 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/shunt_sequence_with_IPv6/g" $TMP_PATH/mosdns-config-shunt.yaml + sed -i "s/DNS_MODE/main_sequence_with_IPv6/g" $TMP_PATH/mosdns-config-shunt.yaml else - sed -i "s/DNS_MODE/shunt_sequence_disable_IPv6/g" $TMP_PATH/mosdns-config-shunt.yaml + 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 ;; diff --git a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml b/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml deleted file mode 100644 index c3d5e5b3f9d..00000000000 --- a/luci-app-ssr-plus/root/etc/ssrplus/mosdns-config-shunt.yaml +++ /dev/null @@ -1,43 +0,0 @@ -log: - level: info -plugins: - - tag: lazy_cache - type: cache - args: - size: 8000 - lazy_cache_ttl: 86400 - - - tag: forward_google_shunt - type: forward - args: - concurrent: 2 - upstreams: - - - tag: shunt_sequence_disable_IPv6 - type: sequence - args: - - exec: $lazy_cache - - exec: prefer_ipv4 - - exec: $forward_google_shunt - - matches: - - qtype 28 65 - exec: reject 0 - - - tag: shunt_sequence_with_IPv6 - type: sequence - args: - - exec: $lazy_cache - - exec: $forward_google_shunt - - - tag: udp_server - type: udp_server - args: - entry: DNS_MODE - listen: 0.0.0.0:DNS_PORT - - - tag: tcp_server - type: tcp_server - args: - entry: DNS_MODE - listen: 0.0.0.0:DNS_PORT - From 02aa0bbf53efc517d46d998c7ea266172515c7bd Mon Sep 17 00:00:00 2001 From: Xiaoli Chan <2209553467@qq.com> Date: Fri, 27 Oct 2023 00:55:13 +0800 Subject: [PATCH 6/7] [SSRP] Beginner: review I Signed-off-by: Xiaoli Chan <2209553467@qq.com> --- luci-app-ssr-plus/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luci-app-ssr-plus/Makefile b/luci-app-ssr-plus/Makefile index 4ea0f97091b..9fcb465ab5d 100644 --- a/luci-app-ssr-plus/Makefile +++ b/luci-app-ssr-plus/Makefile @@ -2,15 +2,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-ssr-plus PKG_VERSION:=188 -PKG_RELEASE:=3 +PKG_RELEASE:=1 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_NONE_V2RAY \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG \ - CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_MosDNS \ + CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Tuic_Client \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Shadow_TLS \ CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_IPT2Socks \ From c6c6424d6b1548d7ccbe076e3020cab52eb63393 Mon Sep 17 00:00:00 2001 From: Xiaoli Chan <2209553467@qq.com> Date: Sat, 28 Oct 2023 02:31:24 +0800 Subject: [PATCH 7/7] Fix dns issues Signed-off-by: Xiaoli Chan <2209553467@qq.com> --- .../root/etc/init.d/shadowsocksr | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr index b589fbf73b0..2415b62469f 100755 --- a/luci-app-ssr-plus/root/etc/init.d/shadowsocksr +++ b/luci-app-ssr-plus/root/etc/init.d/shadowsocksr @@ -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/:/#} @@ -203,6 +209,9 @@ start_dns() { 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)