From 0163ec85781105de304c76b825bf4ec21d740e35 Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:14:18 +0800 Subject: [PATCH] luci: add Mixed support to sing-box server mixed inbound is a socks4, socks4a, socks5 and http server. --- .../model/cbi/passwall/server/type/sing-box.lua | 2 ++ luci-app-passwall/luasrc/passwall/util_sing-box.lua | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua b/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua index ba356c406..7b67269e3 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/server/type/sing-box.lua @@ -48,6 +48,7 @@ local ss_method_list = { s.fields["type"]:value(type_name, "Sing-Box") o = s:option(ListValue, option_name("protocol"), translate("Protocol")) +o:value("mixed", "Mixed") o:value("socks", "Socks") o:value("http", "HTTP") o:value("shadowsocks", "Shadowsocks") @@ -70,6 +71,7 @@ o.validate = function(self, value, t) end return value end +o:depends({ [option_name("protocol")] = "mixed" }) o:depends({ [option_name("protocol")] = "socks" }) o:depends({ [option_name("protocol")] = "http" }) diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index d17326887..6e2e96a92 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -386,6 +386,18 @@ function gen_config_server(node) local protocol_table = nil + if node.protocol == "mixed" then + protocol_table = { + users = (node.auth == "1") and { + { + username = node.username, + password = node.password + } + } or nil, + set_system_proxy = false + } + end + if node.protocol == "socks" then protocol_table = { users = (node.auth == "1") and {