Browse Source

luci-app-ssr-plus: add Xray `sniffing`(enable/disable) `domainsExcluded` `routeOnly` (#1370)

ちか 1 year ago
parent
commit
66fa0c54ca

+ 5 - 0
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/advanced.lua

@@ -1,5 +1,8 @@
 local uci = luci.model.uci.cursor()
 local server_table = {}
+local function is_finded(e)
+	return luci.sys.exec('type -t -p "%s"' % e) ~= "" and true or false
+end
 
 uci:foreach("shadowsocksr", "servers", function(s)
 	if s.alias then
@@ -69,7 +72,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"))
+if is_finded("mosdns") then
 o:value("2", translate("Use MOSDNS query"))
+end
 o:depends("netflix_enable", "1")
 o.default = 1
 

+ 43 - 3
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

@@ -920,6 +920,7 @@ o.rmempty = true
 -- [[ Mux ]]--
 o = s:option(Flag, "mux", translate("Mux"))
 o.rmempty = false
+o.default = false
 o:depends({type = "v2ray", v2ray_protocol = "vless"})
 o:depends({type = "v2ray", v2ray_protocol = "vmess"})
 o:depends({type = "v2ray", v2ray_protocol = "trojan"})
@@ -931,13 +932,13 @@ o = s:option(Value, "concurrency", translate("concurrency"))
 o.datatype = "integer"
 o.rmempty = true
 o.default = "-1"
-o:depends("mux", "1")
+o:depends("mux", true)
 
 o = s:option(Value, "xudpConcurrency", translate("xudpConcurrency"))
 o.datatype = "integer"
 o.rmempty = true
 o.default = "16"
-o:depends("mux", "1")
+o:depends("mux", true)
 
 o = s:option(Value, "xudpProxyUDP443", translate("xudpProxyUDP443"))
 o.rmempty = true
@@ -945,11 +946,38 @@ o.default = "reject"
 o:value("reject", translate("reject"))
 o:value("allow", translate("allow"))
 o:value("skip", translate("skip"))
-o:depends("mux", "1")
+o:depends("mux", true)
 
 -- [[ MPTCP ]]--
 o = s:option(Flag, "mptcp", translate("MPTCP"))
 o.rmempty = false
+o.default = false
+o:depends({type = "v2ray", v2ray_protocol = "vless"})
+o:depends({type = "v2ray", v2ray_protocol = "vmess"})
+o:depends({type = "v2ray", v2ray_protocol = "trojan"})
+o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
+o:depends({type = "v2ray", v2ray_protocol = "socks"})
+o:depends({type = "v2ray", v2ray_protocol = "http"})
+
+-- [[ custom_tcpcongestion ]]--
+o = s:option(Value, "custom_tcpcongestion", translate("custom_tcpcongestion"))
+o.rmempty = true
+o.default = ""
+o:value("", translate("comment_tcpcongestion_disable"))
+o:value("bbr", translate("bbr"))
+o:value("cubic", translate("cubic"))
+o:value("reno", translate("reno"))
+o:depends({type = "v2ray", v2ray_protocol = "vless"})
+o:depends({type = "v2ray", v2ray_protocol = "vmess"})
+o:depends({type = "v2ray", v2ray_protocol = "trojan"})
+o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
+o:depends({type = "v2ray", v2ray_protocol = "socks"})
+o:depends({type = "v2ray", v2ray_protocol = "http"})
+
+-- [[ custom_sniffing ]]--
+o = s:option(Flag, "custom_sniffing", translate("custom_sniffing"))
+o.rmempty = false
+o.default = true
 o:depends({type = "v2ray", v2ray_protocol = "vless"})
 o:depends({type = "v2ray", v2ray_protocol = "vmess"})
 o:depends({type = "v2ray", v2ray_protocol = "trojan"})
@@ -957,6 +985,18 @@ o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
 o:depends({type = "v2ray", v2ray_protocol = "socks"})
 o:depends({type = "v2ray", v2ray_protocol = "http"})
 
+-- [[ custom_domainsExcluded ]]--
+o = s:option(Flag, "custom_domainsExcluded", translate("custom_domainsExcluded"))
+o.rmempty = false
+o.default = true
+o:depends("custom_sniffing", true)
+
+-- [[ custom_routeOnly ]]--
+o = s:option(Flag, "custom_routeOnly", translate("custom_routeOnly"))
+o.rmempty = false
+o.default = false
+o:depends("custom_sniffing", true)
+
 -- [[ Cert ]]--
 o = s:option(Flag, "certificate", translate("Self-signed Certificate"))
 o.rmempty = true

+ 15 - 0
luci-app-ssr-plus/po/zh-cn/ssr-plus.po

@@ -97,6 +97,21 @@ msgstr "UDP 最大并发连接数"
 msgid "xudpProxyUDP443"
 msgstr "对被代理的 UDP/443 流量处理方式"
 
+msgid "custom_tcpcongestion"
+msgstr "连接服务器节点的 TCP 拥塞控制算法"
+
+msgid "comment_tcpcongestion_disable"
+msgstr "使用系统默认值"
+
+msgid "custom_sniffing"
+msgstr "流量嗅探"
+
+msgid "custom_domainsExcluded"
+msgstr "流量嗅探域名排除列表"
+
+msgid "custom_routeOnly"
+msgstr "嗅探得到的域名仅用于 Xray 内部路由"
+
 msgid "If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates."
 msgstr "是否允许不安全连接。当选择时,将不会检查远端主机所提供的 TLS 证书的有效性。"
 

+ 37 - 6
luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua

@@ -126,7 +126,38 @@ local Xray = {
 		port = tonumber(local_port),
 		protocol = "dokodemo-door",
 		settings = {network = proto, followRedirect = true},
-		sniffing = {enabled = true, destOverride = {"http", "tls", "quic"}}
+		sniffing = {
+			enabled =  (server.custom_sniffing == "1") and true or false,
+			routeOnly = (server.custom_routeOnly == "1") and true or false,
+			destOverride = {"http", "tls", "quic"},
+			domainsExcluded = (server.custom_domainsExcluded == "1") and {
+				"courier.push.apple.com",
+				"rbsxbxp-mim.vivox.com",
+				"rbsxbxp.www.vivox.com",
+				"rbsxbxp-ws.vivox.com",
+				"rbspsxp.www.vivox.com",
+				"rbspsxp-mim.vivox.com",
+				"rbspsxp-ws.vivox.com",
+				"rbswxp.www.vivox.com",
+				"rbswxp-mim.vivox.com",
+				"disp-rbspsp-5-1.vivox.com",
+				"disp-rbsxbp-5-1.vivox.com",
+				"proxy.rbsxbp.vivox.com",
+				"proxy.rbspsp.vivox.com",
+				"proxy.rbswp.vivox.com",
+				"rbswp.vivox.com",
+				"rbsxbp.vivox.com",
+				"rbspsp.vivox.com",
+				"rbspsp.www.vivox.com",
+				"rbswp.www.vivox.com",
+				"rbsxbp.www.vivox.com",
+				"rbsxbxp.vivox.com",
+				"rbspsxp.vivox.com",
+				"rbswxp.vivox.com",
+				"Mijia Cloud",
+				"dlg.io.mi.com"
+			} or nil,
+		}
 	} or nil,
 	-- 开启 socks 代理
 	inboundDetour = (proto:find("tcp") and socks_port ~= "0") and {
@@ -218,11 +249,11 @@ local Xray = {
 				permit_without_stream = (server.permit_without_stream == "1") and true or nil,
 				initial_windows_size = tonumber(server.initial_windows_size) or nil
 			} or nil,
-			sockopt = (server.mptcp == "1") and {
-				tcpcongestion = "bbr",
-				tcpMptcp = true,
-				tcpNoDelay = true
-			} or nil
+			sockopt = {
+				tcpMptcp = (server.mptcp == "1") and true or false,
+				tcpNoDelay = (server.mptcp == "1") and true or false,
+				tcpcongestion = server.custom_tcpcongestion
+			}
 		},
 		mux = (server.mux == "1") and {
 			-- mux