From d38c0532bcb029ea85d2f7bb9e0744e179021811 Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Wed, 6 Sep 2023 16:15:15 +0800 Subject: [PATCH] luci: add Naive support to sing-box server --- .../model/cbi/passwall/server/type/sing-box.lua | 3 +++ luci-app-passwall/luasrc/passwall/util_sing-box.lua | 12 ++++++++++++ 2 files changed, 15 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 7b67269e3..c4d9f01f0 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 @@ -55,6 +55,7 @@ o:value("shadowsocks", "Shadowsocks") o:value("vmess", "Vmess") o:value("vless", "VLESS") o:value("trojan", "Trojan") +o:value("naive", "Naive") o:value("direct", "Direct") o = s:option(Value, option_name("port"), translate("Listen Port")) @@ -77,11 +78,13 @@ o:depends({ [option_name("protocol")] = "http" }) o = s:option(Value, option_name("username"), translate("Username")) o:depends({ [option_name("auth")] = true }) +o:depends({ [option_name("protocol")] = "naive" }) o = s:option(Value, option_name("password"), translate("Password")) o.password = true o:depends({ [option_name("auth")] = true }) o:depends({ [option_name("protocol")] = "shadowsocks" }) +o:depends({ [option_name("protocol")] = "naive" }) o = s:option(ListValue, option_name("d_protocol"), translate("Destination protocol")) o:value("tcp", "TCP") diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index 6e2e96a92..adbacbd26 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -483,6 +483,18 @@ function gen_config_server(node) end end + if node.protocol == "naive" then + protocol_table = { + users = { + { + username = node.username, + password = node.password + } + }, + tls = tls, + } + end + if node.protocol == "direct" then protocol_table = { network = (node.d_protocol ~= "TCP,UDP") and node.d_protocol or nil,