From 5aec13e562c30558ef04367042ec0a0755507b59 Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Thu, 5 Jan 2023 13:35:00 +0800 Subject: [PATCH] luci: add Xray wireguard support --- .../model/cbi/passwall/api/gen_v2ray.lua | 13 ++++++++++- .../model/cbi/passwall/client/node_config.lua | 23 +++++++++++++++++++ luci-app-passwall/po/zh-cn/passwall.po | 12 ++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua b/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua index f29fa7579..9daef4996 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua @@ -238,7 +238,18 @@ function gen_outbound(node, tag, proxy_table) } } or nil } - } or nil + } or nil, + address = (node.protocol == "wireguard" and node.wireguard_local_address) and node.wireguard_local_address or nil, + secretKey = (node.protocol == "wireguard") and node.wireguard_secret_key or nil, + peers = (node.protocol == "wireguard") and { + { + publicKey = node.wireguard_public_key, + endpoint = node.address .. ":" .. node.port, + preSharedKey = node.wireguard_preSharedKey, + 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 } } local alpn = {} diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua index 5ab9fe9f3..01430b41d 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua @@ -120,6 +120,7 @@ protocol:value("http", translate("HTTP")) protocol:value("socks", translate("Socks")) protocol:value("shadowsocks", translate("Shadowsocks")) protocol:value("trojan", translate("Trojan")) +protocol:value("wireguard", translate("WireGuard")) protocol:value("_balancing", translate("Balancing")) protocol:value("_shunt", translate("Shunt")) protocol:depends("type", "V2ray") @@ -257,6 +258,7 @@ address:depends({ type = "Xray", protocol = "http" }) address:depends({ type = "Xray", protocol = "socks" }) address:depends({ type = "Xray", protocol = "shadowsocks" }) address:depends({ type = "Xray", protocol = "trojan" }) +address:depends({ type = "Xray", protocol = "wireguard" }) port = s:option(Value, "port", translate("Port")) port.datatype = "port" @@ -283,6 +285,7 @@ port:depends({ type = "Xray", protocol = "http" }) port:depends({ type = "Xray", protocol = "socks" }) port:depends({ type = "Xray", protocol = "shadowsocks" }) port:depends({ type = "Xray", protocol = "trojan" }) +port:depends({ type = "Xray", protocol = "wireguard" }) hysteria_hop = s:option(Value, "hysteria_hop", translate("Additional ports for hysteria hop")) hysteria_hop:depends("type", "Hysteria") @@ -644,6 +647,26 @@ ss_transport:depends({ type = "V2ray", protocol = "shadowsocks" }) ss_transport:depends({ type = "Xray", protocol = "shadowsocks" }) ]]-- +wireguard_public_key = s:option(Value, "wireguard_public_key", translate("Public Key")) +wireguard_public_key:depends({ type = "Xray", protocol = "wireguard" }) + +wireguard_secret_key = s:option(Value, "wireguard_secret_key", translate("Private Key")) +wireguard_secret_key:depends({ type = "Xray", protocol = "wireguard" }) + +wireguard_preSharedKey = s:option(Value, "wireguard_preSharedKey", translate("Pre shared key")) +wireguard_preSharedKey:depends({ type = "Xray", protocol = "wireguard" }) + +wireguard_local_address = s:option(DynamicList, "wireguard_local_address", translate("Local Address")) +wireguard_local_address:depends({ type = "Xray", protocol = "wireguard" }) + +wireguard_mtu = s:option(Value, "wireguard_mtu", translate("MTU")) +wireguard_mtu.default = "1420" +wireguard_mtu:depends({ type = "Xray", protocol = "wireguard" }) + +wireguard_keepAlive = s:option(Value, "wireguard_keepAlive", translate("Keep Alive")) +wireguard_keepAlive.default = "0" +wireguard_keepAlive:depends({ type = "Xray", protocol = "wireguard" }) + -- [[ TCP部分 ]]-- -- TCP伪装 diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 0803f2c53..e8185ebf3 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -1042,6 +1042,18 @@ msgstr "用户等级(level)" msgid "Transport" msgstr "传输方式" +msgid "Public Key" +msgstr "公钥" + +msgid "Private Key" +msgstr "私钥" + +msgid "Pre shared key" +msgstr "额外的对称加密密钥" + +msgid "Local Address" +msgstr "本地地址" + msgid "Camouflage Type" msgstr "伪装类型"