luci: wireguard add reserved option when xray>=1.8.0 (#2462)

* luci: wireguard add reserved option when xray>=1.8.0

* luci: 4.63
This commit is contained in:
Tianhe Y 2023-04-06 14:34:35 +08:00 committed by sbwml
parent d67f9fd5c6
commit ac259f2d11
4 changed files with 18 additions and 4 deletions

View File

@ -6,8 +6,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=4.62
PKG_RELEASE:=7
PKG_VERSION:=4.63
PKG_RELEASE:=1
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \

View File

@ -748,6 +748,11 @@ wireguard_mtu = s:option(Value, "wireguard_mtu", translate("MTU"))
wireguard_mtu.default = "1420"
wireguard_mtu:depends({ type = "Xray", protocol = "wireguard" })
if api.compare_versions(api.get_app_version("xray"), ">=", "1.8.0") then
wireguard_reserved = s:option(Value, "wireguard_reserved", translate("Reserved"))
wireguard_reserved:depends({ type = "Xray", protocol = "wireguard" })
end
wireguard_keepAlive = s:option(Value, "wireguard_keepAlive", translate("Keep Alive"))
wireguard_keepAlive.default = "0"
wireguard_keepAlive:depends({ type = "Xray", protocol = "wireguard" })

View File

@ -536,7 +536,7 @@ local function exec(cmd, args, writer, timeout)
end
end
local function compare_versions(ver1, comp, ver2)
function compare_versions(ver1, comp, ver2)
local table = table
if not ver1 then ver1 = "" end

View File

@ -100,6 +100,14 @@ function gen_outbound(flag, node, tag, proxy_table)
end
end
if node.protocol == "wireguard" and node.wireguard_reserved then
local bytes = {}
node.wireguard_reserved:gsub("[^,]+", function(b)
bytes[#bytes+1] = tonumber(b)
end)
node.wireguard_reserved = #bytes > 0 and bytes or nil
end
result = {
_flag_tag = node_id,
_flag_proxy = proxy,
@ -223,7 +231,8 @@ function gen_outbound(flag, node, tag, proxy_table)
keepAlive = node.wireguard_keepAlive and tonumber(node.wireguard_keepAlive) or nil
}
} or nil,
mtu = (node.protocol == "wireguard" and node.wireguard_mtu) and tonumber(node.wireguard_mtu) or nil
mtu = (node.protocol == "wireguard" and node.wireguard_mtu) and tonumber(node.wireguard_mtu) or nil,
reserved = (node.protocol == "wireguard" and node.wireguard_reserved) and node.wireguard_reserved or nil
}
}
local alpn = {}