luci-app-passwall: server: add xray acceptProxyProtocol option

This commit is contained in:
xiaorouji 2021-01-08 13:47:21 +08:00 committed by CN_SZTL
parent 4bfcaff4cf
commit 15d7faaf9e
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
3 changed files with 36 additions and 22 deletions

View File

@ -14,9 +14,9 @@ function gen_config(user)
for i = 1, #user.uuid do
clients[i] = {
id = user.uuid[i],
flow = (user.xtls and user.xtls == "1") and user.flow or nil,
level = tonumber(user.level),
alterId = tonumber(user.alter_id)
flow = ("1" == user.xtls) and user.flow or nil,
level = user.level and tonumber(user.level) or nil,
alterId = user.alter_id and tonumber(user.alter_id) or nil
}
end
settings = {
@ -26,8 +26,8 @@ function gen_config(user)
end
elseif user.protocol == "socks" then
settings = {
auth = (user.auth and user.auth == "1") and "password" or "noauth",
accounts = (user.auth and user.auth == "1") and {
auth = ("1" == user.auth) and "password" or "noauth",
accounts = ("1" == user.auth) and {
{
user = user.username,
pass = user.password
@ -37,7 +37,7 @@ function gen_config(user)
elseif user.protocol == "http" then
settings = {
allowTransparent = false,
accounts = (user.auth and user.auth == "1") and {
accounts = ("1" == user.auth) and {
{
user = user.username,
pass = user.password
@ -50,7 +50,7 @@ function gen_config(user)
settings = {
method = user.method,
password = user.password,
level = tonumber(user.level) or 1,
level = user.level and tonumber(user.level) or nil,
network = user.ss_network or "TCP,UDP"
}
elseif user.protocol == "trojan" then
@ -58,9 +58,9 @@ function gen_config(user)
local clients = {}
for i = 1, #user.uuid do
clients[i] = {
flow = (user.xtls and user.xtls == "1") and user.flow or nil,
flow = ("1" == user.xtls) and user.flow or nil,
password = user.uuid[i],
level = tonumber(user.level)
level = user.level and tonumber(user.level) or nil,
}
end
settings = {
@ -71,7 +71,7 @@ function gen_config(user)
settings = {
users = {
{
level = tonumber(user.level) or 1,
level = user.level and tonumber(user.level) or nil,
secret = (user.password == nil) and "" or user.password
}
}
@ -123,7 +123,7 @@ function gen_config(user)
local config = {
log = {
-- error = "/var/etc/passwall_server/log/" .. user[".name"] .. ".log",
loglevel = (user.log and user.log == "1") and user.loglevel or "none"
loglevel = ("1" == user.log) and user.loglevel or "none"
},
-- 传入连接
inbounds = {
@ -135,8 +135,11 @@ function gen_config(user)
streamSettings = {
network = user.transport,
security = "none",
xtlsSettings = (user.tls and user.tls == "1" and user.xtls and user.xtls == "1") and {
alpn = {"http/1.1"},
xtlsSettings = ("1" == user.tls and "1" == user.xtls) and {
alpn = {
"h2",
"http/1.1"
},
disableSystemRoot = false,
certificates = {
{
@ -145,8 +148,11 @@ function gen_config(user)
}
}
} or nil,
tlsSettings = (user.tls and user.tls == "1") and {
alpn = {"http/1.1"},
tlsSettings = ("1" == user.tls) and {
alpn = {
"h2",
"http/1.1"
},
disableSystemRoot = false,
certificates = {
{
@ -156,6 +162,7 @@ function gen_config(user)
}
} or nil,
tcpSettings = (user.transport == "tcp") and {
acceptProxyProtocol = (user.acceptProxyProtocol and user.acceptProxyProtocol == "1") and true or false,
header = {
type = user.tcp_guise,
request = (user.tcp_guise == "http") and {
@ -178,7 +185,7 @@ function gen_config(user)
header = {type = user.mkcp_guise}
} or nil,
wsSettings = (user.transport == "ws") and {
acceptProxyProtocol = true,
acceptProxyProtocol = (user.acceptProxyProtocol and user.acceptProxyProtocol == "1") and true or false,
headers = (user.ws_host) and {Host = user.ws_host} or nil,
path = user.ws_path
} or nil,
@ -201,7 +208,7 @@ function gen_config(user)
routing = routing
}
if user.tls and user.tls == "1" then
if "1" == user.tls then
config.inbounds[1].streamSettings.security = "tls"
if user.xtls and user.xtls == "1" then
config.inbounds[1].streamSettings.security = "xtls"

View File

@ -258,12 +258,10 @@ uuid:depends("type", "Trojan-Go")
uuid:depends("type", "Trojan-Plus")
alter_id = s:option(Value, "alter_id", translate("Alter ID"))
alter_id.default = 16
alter_id:depends({ type = "Xray", protocol = "vmess" })
alter_id:depends({ type = "V2ray", protocol = "vmess" })
level = s:option(Value, "level", translate("User Level"))
level.default = 1
level:depends({ type = "Xray", protocol = "vmess" })
level:depends({ type = "Xray", protocol = "vless" })
level:depends({ type = "Xray", protocol = "shadowsocks" })
@ -511,6 +509,12 @@ quic_guise = s:option(ListValue, "quic_guise", translate("Camouflage Type"))
for a, t in ipairs(header_type_list) do quic_guise:value(t) end
quic_guise:depends("transport", "quic")
acceptProxyProtocol = s:option(Flag, "acceptProxyProtocol", translate("acceptProxyProtocol"), translate("Whether to receive PROXY protocol, when this node want to be fallback or forwarded by proxy, it must be enable, otherwise it cannot be used."))
acceptProxyProtocol:depends({ type = "Xray", transport = "tcp" })
acceptProxyProtocol:depends({ type = "Xray", transport = "ws" })
acceptProxyProtocol:depends({ type = "V2ray", transport = "tcp" })
acceptProxyProtocol:depends({ type = "V2ray", transport = "ws" })
-- [[ Fallback部分 ]]--
fallback = s:option(Flag, "fallback", translate("Fallback"))
fallback:depends({ type = "Xray", protocol = "vless", transport = "tcp" })
@ -573,7 +577,7 @@ remote_port.datatype = "port"
remote_port.default = "80"
remote_port:depends("remote_enable", 1)
bind_local = s:option(Flag, "bind_local", translate("Bind Local"), translate("When selected, it can only be accessed locally,It is recommended to turn on when using reverse proxies."))
bind_local = s:option(Flag, "bind_local", translate("Bind Local"), translate("When selected, it can only be accessed locally, It is recommended to turn on when using reverse proxies or be fallback."))
bind_local.default = "0"
bind_local:depends("type", "Xray")
bind_local:depends("type", "V2ray")

View File

@ -1075,14 +1075,17 @@ msgstr "当你隐藏后想再次显示,地址栏输入例:"
msgid "The MTProto protocol must be 32 characters and can only contain characters from 0 to 9 and a to f."
msgstr "MTProto 协议必须为 32 个字符,仅可包含 0 到 9 和 a 到 f 之间的字符。"
msgid "Whether to receive PROXY protocol, when this node want to be fallback or forwarded by proxy, it must be enable, otherwise it cannot be used."
msgstr "是否接收 PROXY protocol当该节点要被回落或被代理转发时必须启用否则不能使用。"
msgid "transit node"
msgstr "中转到此节点"
msgid "Bind Local"
msgstr "本机监听"
msgid "When selected, it can only be accessed locally,It is recommended to turn on when using reverse proxies."
msgstr "当勾选时,只能由本机访问此端口,当开启反向代理时建议勾选此项。"
msgid "When selected, it can only be accessed locally, It is recommended to turn on when using reverse proxies or be fallback."
msgstr "当勾选时,只能由本机访问此端口,当想被反向代理或被回落时建议勾选此项。"
msgid "Accept LAN Access"
msgstr "接受局域网访问"