From 4e720fa28ddb2f674269dc4387ce945e73177dab Mon Sep 17 00:00:00 2001 From: Gzxhwq Date: Mon, 11 Sep 2023 22:11:30 +0800 Subject: [PATCH] luci: some fix & improvement with sing-box * luci: fix sing-box REALITY tag on client side * luci: add sing-box mux padding option * luci: fix sing-box dns --- .../cbi/passwall/client/type/sing-box.lua | 43 +++++++++++-------- .../luasrc/passwall/util_sing-box.lua | 3 ++ luci-app-passwall/po/zh-cn/passwall.po | 3 ++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua index 9ebb472a2..8a10a180b 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua @@ -355,19 +355,6 @@ o:depends({ [option_name("protocol")] = "trojan" }) o:depends({ [option_name("protocol")] = "shadowsocks" }) o:depends({ [option_name("protocol")] = "shadowtls" }) -if singbox_tags:find("with_reality") then - o = s:option(Flag, option_name("reality"), translate("REALITY")) - o.default = 0 - o:depends({ [option_name("protocol")] = "vless", [option_name("tls")] = true }) - - -- [[ REALITY部分 ]] -- - o = s:option(Value, option_name("reality_publicKey"), translate("Public Key")) - o:depends({ [option_name("tls")] = true, [option_name("reality")] = true }) - - o = s:option(Value, option_name("reality_shortId"), translate("Short Id")) - o:depends({ [option_name("tls")] = true, [option_name("reality")] = true }) -end - o = s:option(ListValue, option_name("alpn"), translate("alpn")) o.default = "default" o:value("default", translate("Default")) @@ -392,22 +379,36 @@ o:depends({ [option_name("protocol")] = "hysteria2" }) if singbox_tags:find("with_utls") then o = s:option(Flag, option_name("utls"), translate("uTLS")) o.default = "0" - o:depends({ [option_name("tls")] = true, [option_name("reality")] = false }) + o:depends({ [option_name("tls")] = true }) o = s:option(ListValue, option_name("fingerprint"), translate("Finger Print")) o:value("chrome") o:value("firefox") o:value("edge") o:value("safari") - o:value("360") + -- o:value("360") o:value("qq") o:value("ios") - o:value("android") + -- o:value("android") o:value("random") - o:value("randomized") + -- o:value("randomized") o.default = "chrome" o:depends({ [option_name("tls")] = true, [option_name("utls")] = true }) - o:depends({ [option_name("tls")] = true, [option_name("reality")] = true }) + + -- [[ REALITY部分 ]] -- + o = s:option(Flag, option_name("reality"), translate("REALITY")) + o.default = 0 + o:depends({ [option_name("protocol")] = "vless", [option_name("utls")] = true }) + o:depends({ [option_name("protocol")] = "vmess", [option_name("utls")] = true }) + o:depends({ [option_name("protocol")] = "shadowsocks", [option_name("utls")] = true }) + o:depends({ [option_name("protocol")] = "socks", [option_name("utls")] = true }) + o:depends({ [option_name("protocol")] = "trojan", [option_name("utls")] = true }) + + o = s:option(Value, option_name("reality_publicKey"), translate("Public Key")) + o:depends({ [option_name("utls")] = true, [option_name("reality")] = true }) + + o = s:option(Value, option_name("reality_shortId"), translate("Short Id")) + o:depends({ [option_name("utls")] = true, [option_name("reality")] = true }) end o = s:option(ListValue, option_name("transport"), translate("Transport")) @@ -512,7 +513,7 @@ o:depends({ [option_name("protocol")] = "vmess" }) o:depends({ [option_name("protocol")] = "vless", [option_name("flow")] = "" }) o:depends({ [option_name("protocol")] = "http" }) o:depends({ [option_name("protocol")] = "socks" }) -o:depends({ [option_name("protocol")] = "shadowsocks" }) +o:depends({ [option_name("protocol")] = "shadowsocks", [option_name("uot")] = "" }) o:depends({ [option_name("protocol")] = "trojan" }) o = s:option(ListValue, option_name("mux_type"), translate("Mux")) @@ -525,4 +526,8 @@ o = s:option(Value, option_name("mux_concurrency"), translate("Mux concurrency") o.default = 8 o:depends({ [option_name("mux")] = true }) +o = s:option(Flag, option_name("mux_padding"), translate("Padding")) +o.default = 0 +o:depends({ [option_name("mux")] = true }) + api.luci_types(arg[1], m, s, type_name, option_prefix) diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index f07a155cb..4a0ee752f 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -111,6 +111,7 @@ function gen_outbound(flag, node, tag, proxy_table) enabled = true, protocol = node.mux_type or "h2mux", max_connections = tonumber(node.mux_concurrency) or 4, + padding = (node.mux_padding == "1") and true or false, --min_streams = 4, --max_streams = 0, } @@ -231,6 +232,7 @@ function gen_outbound(flag, node, tag, proxy_table) flow = (node.tls == '1' and node.flow) and node.flow or nil, tls = tls, packet_encoding = "xudp", --UDP 包编码。(空):禁用 packetaddr:由 v2ray 5+ 支持 xudp:由 xray 支持 + multiplex = mux, transport = v2ray_transport, } end @@ -1290,6 +1292,7 @@ function gen_config(var) default_dns_flag = "direct" end end + else default_dns_flag = "direct" end dns.final = default_dns_flag end diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 7d4e8b605..2e916abc8 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -1417,6 +1417,9 @@ msgstr "XUDP 最大并发连接数" msgid "Mux idle timeout" msgstr "最大闲置时间" +msgid "Padding" +msgstr "填充" + msgid "Enable early data" msgstr "启用前置数据"