浏览代码

luci-app-ssr-plus: Add dns2socks `Rust version` parse.

zxlhhyccc 6 月之前
父节点
当前提交
b85a122ebd

+ 13 - 1
luci-app-ssr-plus/Makefile

@@ -9,6 +9,8 @@ PKG_CONFIG_DEPENDS:= \
 	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_V2ray \
 	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Xray \
 	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG \
+	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_DNS2SOCKS \
+	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_DNS2SOCKS_RUST \
 	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_MosDNS \
 	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria \
 	CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_Tuic_Client \
@@ -32,7 +34,7 @@ PKG_CONFIG_DEPENDS:= \
 LUCI_TITLE:=SS/SSR/V2Ray/Trojan/NaiveProxy/Tuic/ShadowTLS/Hysteria/Socks5/Tun LuCI interface
 LUCI_PKGARCH:=all
 LUCI_DEPENDS:= \
-	+coreutils +coreutils-base64 +dns2socks +dns2tcp +dnsmasq-full +@PACKAGE_dnsmasq_full_ipset +ipset +kmod-ipt-nat +jq \
+	+coreutils +coreutils-base64 +dns2tcp +dnsmasq-full +@PACKAGE_dnsmasq_full_ipset +ipset +kmod-ipt-nat +jq \
 	+ip-full +iptables +iptables-mod-tproxy +lua +lua-neturl +libuci-lua +microsocks \
 	+tcping +resolveip +shadowsocksr-libev-ssr-check +wget-ssl \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:curl \
@@ -40,6 +42,8 @@ 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_DNS2SOCKS:dns2socks \
+	+PACKAGE_$(PKG_NAME)_INCLUDE_DNS2SOCKS_RUST:dns2socks-rust \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_MosDNS:mosdns \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Hysteria:hysteria \
 	+PACKAGE_$(PKG_NAME)_INCLUDE_Tuic_Client:tuic-client \
@@ -118,6 +122,14 @@ config PACKAGE_$(PKG_NAME)_INCLUDE_ChinaDNS_NG
 	bool "Include ChinaDNS-NG"
 	default n
 
+config PACKAGE_$(PKG_NAME)_INCLUDE_DNS2SOCKS
+	bool "Include DNS2socks"
+	default y
+
+config PACKAGE_$(PKG_NAME)_INCLUDE_DNS2SOCKS_RUST
+	bool "Include DNS2socks-Rust"
+	default n
+
 config PACKAGE_$(PKG_NAME)_INCLUDE_MosDNS
 	bool "Include MosDNS"
 	default y if aarch64||arm||i386||x86_64

+ 11 - 8
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua

@@ -78,8 +78,9 @@ 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 DNS2SOCKS-RUST query and cache"))
 if is_finded("mosdns") then
-o:value("2", translate("Use MOSDNS query"))
+	o:value("3", translate("Use MosDNS query"))
 end
 o:depends("netflix_enable", "1")
 o.default = 1
@@ -97,6 +98,7 @@ 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", "1")
+o:depends("shunt_dns_mode", "2")
 o.description = translate("Custom DNS Server format as IP:PORT (default: 8.8.4.4:53)")
 o.datatype = "ip4addrport"
 
@@ -107,11 +109,11 @@ o:value("tcp://209.244.0.3:53,tcp://209.244.0.4:53", translate("Level 3 Public D
 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:depends("shunt_dns_mode", "3")
+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 = s:option(Flag, "shunt_mosdns_ipv6", translate("Disable IPv6 In MosDNS Query Mode (Shunt Mode)"))
+o:depends("shunt_dns_mode", "3")
 o.rmempty = false
 o.default = "0"
 
@@ -172,7 +174,7 @@ o.cfgvalue = function(self, section)
     if enabled == "0" then
         return m:get(section, "old_server")
     end
-    return Value.cfgvalue(self, section) -- Default to `same` when enabled
+    return Value.cfgvalue(self, section)-- Default to `same` when enabled
 end
 
 o.write = function(self, section, value)
@@ -203,7 +205,7 @@ for key, server_type in pairs(type_table) do
         o:depends("server", key)
     end
 end
-o:depends({server = "same", disable = true}) 
+o:depends({server = "same", disable = true})
 
 -- Socks User
 o = s:option(Value, "socks5_user", translate("Socks5 User"), translate("Only when Socks5 Auth Mode is password valid, Mandatory."))
@@ -226,7 +228,7 @@ for key, server_type in pairs(type_table) do
         o:depends("server", key)
     end
 end
-o:depends({server = "same", disable = true}) 
+o:depends({server = "same", disable = true})
 end
 
 -- Local Port
@@ -290,6 +292,7 @@ o = s:option(ListValue, "type", translate("Type"))
 o.default = "base64"
 o:value("rand", "rand")
 o:value("str", "str")
+o:value("hex", "hex")
 o:value("base64", "base64")
 
 o = s:option(Value, "domainStrategy", translate("Domain Strategy"))

+ 18 - 15
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client.lua

@@ -49,19 +49,19 @@ for _, key in pairs(key_table) do
 end
 
 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"))
-for _, key in pairs(key_table) do
-	o:value(key, server_table[key])
-end
-o.default = "nil"
-o.rmempty = false
+	o = s:option(ListValue, "netflix_server", translate("Netflix Node"))
+	o:value("nil", translate("Disable"))
+	o:value("same", translate("Same as Global Server"))
+	for _, key in pairs(key_table) do
+		o:value(key, server_table[key])
+	end
+	o.default = "nil"
+	o.rmempty = false
 
-o = s:option(Flag, "netflix_proxy", translate("External Proxy Mode"))
-o.rmempty = false
-o.description = translate("Forward Netflix Proxy through Main Proxy")
-o.default = "0"
+	o = s:option(Flag, "netflix_proxy", translate("External Proxy Mode"))
+	o.rmempty = false
+	o.description = translate("Forward Netflix Proxy through Main Proxy")
+	o.default = "0"
 end
 
 o = s:option(ListValue, "threads", translate("Multi Threads Option"))
@@ -96,8 +96,9 @@ 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 DNS2SOCKS-RUST query and cache"))
 if is_finded("mosdns") then
-o:value("3", translate("Use MOSDNS query (Not Support Oversea Mode)"))
+	o:value("4", translate("Use MOSDNS query (Not Support Oversea Mode)"))
 end
 o:value("0", translate("Use Local DNS Service listen port 5335"))
 o.default = 1
@@ -118,6 +119,7 @@ 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"
 
@@ -128,11 +130,11 @@ o:value("tcp://209.244.0.3:53,tcp://209.244.0.4:53", translate("Level 3 Public D
 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:depends("pdnsd_enable", "4")
 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", "4")
 o.rmempty = false
 o.default = "1"
 
@@ -150,6 +152,7 @@ if is_finded("chinadns-ng") then
 	o:value("1.2.4.8:53", translate("CNNIC SDNS (1.2.4.8)"))
 	o:depends({pdnsd_enable = "1", run_mode = "router"})
 	o:depends({pdnsd_enable = "2", run_mode = "router"})
+	o:depends({pdnsd_enable = "3", run_mode = "router"})
 	o.description = translate("Custom DNS Server format as IP:PORT (default: disabled)")
 	o.validate = function(self, value, section)
 		if (section and value) then

+ 1 - 1
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/status.lua

@@ -92,7 +92,7 @@ if Process_list:find("ssr.server") then
 	server_run = 1
 end
 
-if Process_list:find("ssrplus/bin/dns2tcp") or Process_list:find("ssrplus/bin/mosdns") or (Process_list:find("ssrplus.dns") and Process_list:find("dns2socks.127.0.0.1.*127.0.0.1.5335")) then
+if Process_list:find("ssrplus/bin/dns2tcp") or Process_list:find("ssrplus/bin/mosdns") or (Process_list:find("ssrplus.dns") and Process_list:find("dns2socks*.*127.0.0.1.*127.0.0.1.5335")) then
 	pdnsd_run = 1
 end
 

+ 7 - 4
luci-app-ssr-plus/po/zh_Hans/ssr-plus.po

@@ -615,6 +615,9 @@ msgstr "使用 DNS2TCP 查询"
 msgid "Use DNS2SOCKS query and cache"
 msgstr "使用 DNS2SOCKS 查询并缓存"
 
+msgid "Use DNS2SOCKS-RUST query and cache"
+msgstr "使用 DNS2SOCKS-RUST 查询并缓存"
+
 msgid "Use MOSDNS query (Not Support Oversea Mode)"
 msgstr "使用 MOSDNS 查询 (不支持海外用户回国模式)"
 
@@ -630,11 +633,11 @@ msgstr "分流模式下的访问国外域名 DNS 服务器"
 msgid "Use MOSDNS query"
 msgstr "使用 MOSDNS 查询"
 
-msgid "Custom DNS Server for mosdns"
-msgstr "MOSDNS 自定义 DNS 服务器"
+msgid "Custom DNS Server for MosDNS"
+msgstr "MosDNS 自定义 DNS 服务器"
 
-msgid "Disable IPv6 In MOSDNS Query Mode (Shunt Mode)"
-msgstr "禁止 MOSDNS 返回 IPv6 记录 (分流模式)"
+msgid "Disable IPv6 In MosDNS Query Mode (Shunt Mode)"
+msgstr "禁止 MosDNS 返回 IPv6 记录 (分流模式)"
 
 msgid "DNS Server IP:Port"
 msgstr "DNS 服务器 IP:Port"

+ 11 - 1
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -218,6 +218,12 @@ start_dns() {
 			pdnsd_enable_flag=2
 			;;
 		3)
+			ln_start_bin $(first_type microsocks) microsocks -i 127.0.0.1 -p $tmp_dns_port ssrplus-dns
+			ln_start_bin $(first_type dns2socks-rust) dns2socks-rust -s socks5://127.0.0.1:$tmp_dns_port -d $dnsserver -l 127.0.0.1:$dns_port -f -c
+			echolog "DNS2SOCKS Rust query and cache Started!"
+			pdnsd_enable_flag=3
+			;;
+		4)
 			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
@@ -235,7 +241,7 @@ start_dns() {
 				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
+			pdnsd_enable_flag=4
 			;;
 		esac
 
@@ -526,6 +532,10 @@ shunt_dns_command() {
 		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)
+		ln_start_bin $(first_type dns2socks-rust) dns2socks-rust -s socks5://127.0.0.1:$tmp_port -d $shunt_dnsserver -l 127.0.0.1:$tmp_shunt_dns_port -f -c
+		echolog "DNS2SOCKS Rust Shunt query Started!"
+		;;
+	3)
 		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

+ 13 - 1
luci-app-ssr-plus/root/usr/bin/ssr-monitor

@@ -104,8 +104,20 @@ 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
+	#dns2socks-rust
 	elif [ "$pdnsd_process" -eq 3 ]; then
+		icount=$(busybox ps -w | grep -e ssrplus-dns -e "dns2socks-rust -s socks5://127.0.0.1 $tmp_dns_port" | grep -v grep | wc -l)
+		if [ "$icount" -lt 2 ]; then #如果进程挂掉就重启它
+			logger -t "$NAME" "dns2socks-rust $dnsserver tunnel error.restart!"
+			echolog "dns2socks-rust $dnsserver tunnel error.restart!"
+			dnsserver=$(uci_get_by_type global tunnel_forward 8.8.4.4:53)
+			kill -9 $(busybox ps -w | grep ssrplus-dns | grep -v grep | awk '{print $1}') >/dev/null 2>&1
+			kill -9 $(busybox ps -w | grep "dns2socks-rust -s socks5://127.0.0.1 $tmp_dns_port" | grep -v grep | awk '{print $1}') >/dev/null 2>&1
+			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-rust -s socks5://127.0.0.1:$tmp_dns_port -d $dnsserver -l 127.0.0.1:$dns_port -f -c
+		fi
+	#mosdns
+	elif [ "$pdnsd_process" -eq 4 ]; 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!"