From c0abcd264717fc2f954cc4f641e16c607f0d1a5d Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Fri, 5 Apr 2024 22:45:12 +0800 Subject: [PATCH 1/5] luci-app-ssr-plus: Add WireGuard `kernelMode` `reserved` `keepalive` ` allowedips` argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit whether to use the virtual NIC TUN of the Linux kernel!Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. Some routes cannot be connected if they are used. --- .../model/cbi/shadowsocksr/client-config.lua | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua index d2b87a7f..3831ce64 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua @@ -831,11 +831,22 @@ o:depends("transport", "kcp") o.rmempty = true -- [[ WireGuard 部分 ]]-- +o = s:option(Flag, "kernelmode", translate("Enabled Kernel virtual NIC TUN(optional)")) +o.description = translate("Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. If used, IPv6 routing table 1023 is occupied.") +o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) +o.default = "0" +o.rmempty = true + o = s:option(DynamicList, "local_addresses", translate("Local addresses")) o.datatype = "cidr" o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) o.rmempty = true +o = s:option(DynamicList, "reserved", translate("Reserved bytes(optional)")) +o.description = translate("Wireguard reserved bytes.") +o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) +o.rmempty = true + o = s:option(Value, "private_key", translate("Private key")) o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) o.password = true @@ -850,6 +861,19 @@ o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) o.password = true o.rmempty = true +o = s:option(Value, "keepalive", translate("Heartbeat interval(second)")) +o.description = translate("Default value 0 indicatesno heartbeat.") +o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) +o.default = "0" +o.rmempty = true + +o = s:option(DynamicList, "allowedips", translate("allowedIPs(optional)")) +o.description = translate("Wireguard allows only traffic from specific source IP.") +o.datatype = "cidr" +o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) +o.default = "0.0.0.0/0" +o.rmempty = true + -- [[ TLS ]]-- o = s:option(Flag, "tls", translate("TLS")) o.rmempty = true From 6f6f2b679b9e0a30b2c68d5479edc8c506f687b6 Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Fri, 5 Apr 2024 22:53:23 +0800 Subject: [PATCH 2/5] luci-app-ssr-plus: Add `kernelMode` `reserved` `keepalive` ` allowedips` argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *** whether to use the virtual NIC TUN of the Linux kernel!Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. Some routes cannot be connected if they are used. *** Current Wireguard protocol `outbound` Is not supported `streamSettings`. --- .../usr/share/shadowsocksr/gen_config.lua | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua b/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua index cbb911eb..c98d623a 100755 --- a/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua +++ b/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua @@ -72,9 +72,13 @@ function wireguard() { publicKey = server.peer_pubkey, preSharedKey = server.preshared_key, - endpoint = server.server .. ":" .. server.server_port + endpoint = server.server .. ":" .. server.server_port, + keepAlive = tonumber(server.keepalive), + allowedIPs = (server.allowedips) or nil, } }, + kernelMode = (server.kernelmode == "1") and true or false, + reserved = {server.reserved} or nil, mtu = tonumber(server.mtu) } end @@ -172,7 +176,7 @@ local Xray = { protocol = server.v2ray_protocol, settings = outbound_settings, -- 底层传输配置 - streamSettings = { + streamSettings = (server.v2ray_protocol ~= "wireguard") and { network = server.transport or "tcp", security = (server.tls == '1') and "tls" or (server.reality == '1') and "reality" or nil, tlsSettings = (server.tls == '1') and { @@ -258,14 +262,14 @@ local Xray = { tcpNoDelay = (server.mptcp == "1") and true or false, -- MPTCP tcpcongestion = server.custom_tcpcongestion -- 连接服务器节点的 TCP 拥塞控制算法 } - }, - mux = { + } or nil, + mux = (server.v2ray_protocol ~= "wireguard") and { -- mux enabled = (server.mux == "1") and true or false, -- Mux concurrency = tonumber(server.concurrency), -- TCP 最大并发连接数 xudpConcurrency = tonumber(server.xudpConcurrency), -- UDP 最大并发连接数 xudpProxyUDP443 = server.xudpProxyUDP443 -- 对被代理的 UDP/443 流量处理方式 - } + } or nil } } local cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:AES128-SHA:AES256-SHA:DES-CBC3-SHA" @@ -322,7 +326,7 @@ local ss = { } local hysteria = { server = (server.server_port and (server.port_range and (server.server .. ":" .. server.server_port .. "," .. server.port_range) or server.server .. ":" .. server.server_port) or (server.port_range and server.server .. ":" .. server.port_range or server.server .. ":443")), - bandwidth = { + bandwidth = (server.uplink_capacity or server.downlink_capacity) and { up = tonumber(server.uplink_capacity) and tonumber(server.uplink_capacity) .. " mbps" or nil, down = tonumber(server.downlink_capacity) and tonumber(server.downlink_capacity) .. " mbps" or nil }, @@ -336,12 +340,11 @@ local hysteria = { hopInterval = (server.port_range and (tonumber(server.hopinterval) .. "s") or nil) } or nil) } or nil, - --[[ tcpTProxy = (proto:find("tcp") and local_port ~= "0") and { - listen = "0.0.0.0:" .. tonumber(local_port) -} or nil, -]] + listen = "0.0.0.0:" .. tonumber(local_port) + } or nil, +]]-- tcpRedirect = (proto:find("tcp") and local_port ~= "0") and { listen = "0.0.0.0:" .. tonumber(local_port) } or nil, @@ -359,7 +362,7 @@ local hysteria = { maxConnReceiveWindow = (server.maxconnreceivewindow and server.maxconnreceivewindow or nil), maxIdleTimeout = (tonumber(server.maxidletimeout) and tonumber(server.maxidletimeout) .. "s" or nil), keepAlivePeriod = (tonumber(server.keepaliveperiod) and tonumber(server.keepaliveperiod) .. "s" or nil), - disable_mtu_discovery = (server.disablepathmtudiscovery == "1") and true or false + disablePathMTUDiscovery = (server.disablepathmtudiscovery == "1") and true or false } or nil, auth = server.hy2_auth, tls = (server.tls_host) and { @@ -394,7 +397,7 @@ local chain_sslocal = { mode = (proto:find("tcp,udp") and "tcp_and_udp") or proto .. "_only", protocol = "redir", tcp_redir = "redirect", - --tcp_redir = "tproxy", + --tcp_redir = "tproxy", udp_redir = "tproxy" }, socks_port ~= "0" and { From 4834ba4dbd09933402120c5308f74df962d9bd37 Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Fri, 5 Apr 2024 23:06:36 +0800 Subject: [PATCH 3/5] luci-app-ssr-plus: Add `kernelMode` `reserved` `keepalive` `allowedips` argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *** whether to use the virtual NIC TUN of the Linux kernel!Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. Some routes cannot be connected if they are used. *** Current Wireguard protocol `outbound` Is not supported `streamSettings`. --- luci-app-ssr-plus/po/zh-cn/ssr-plus.po | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/luci-app-ssr-plus/po/zh-cn/ssr-plus.po b/luci-app-ssr-plus/po/zh-cn/ssr-plus.po index d343d4f2..632b5c9e 100644 --- a/luci-app-ssr-plus/po/zh-cn/ssr-plus.po +++ b/luci-app-ssr-plus/po/zh-cn/ssr-plus.po @@ -942,9 +942,21 @@ msgstr "写入缓冲区大小" msgid "Congestion" msgstr "拥塞控制" +msgid "Enabled Kernel virtual NIC TUN(optional)" +msgstr "启用内核的虚拟网卡 TUN(可选)" + +msgid "Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. If used, IPv6 routing table 1023 is occupied." +msgstr "需要系统支持且有 root 权限才能使用 Linux 内核的虚拟网卡 TUN,使用后会占用 IPv6 的 1023 号路由表。" + msgid "Local addresses" msgstr "本地地址" +msgid "Reserved bytes(optional)" +msgstr "保留字节(可选)" + +msgid "Wireguard reserved bytes." +msgstr "Wireguard 保留字节。" + msgid "Private key" msgstr "私钥" @@ -954,6 +966,15 @@ msgstr "节点公钥" msgid "Pre-shared key" msgstr "预共享密钥" +msgid "Default value 0 indicatesno heartbeat." +msgstr "默认为 0 表示无心跳。" + +msgid "allowedIPs(optional)" +msgstr "allowedIPs(可选)" + +msgid "Wireguard allows only traffic from specific source IP." +msgstr "Wireguard 仅允许特定源 IP 的流量。" + msgid "Network interface to use" msgstr "使用的网络接口" From fdf7b30d2f9786406aef01d00b3e98afbe7519d6 Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Sat, 6 Apr 2024 09:47:32 +0800 Subject: [PATCH 4/5] luci-app-ssr-plus: Add WireGuard `kernelMode` `reserved` `keepalive` `allowedips` argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *** whether to use the virtual NIC TUN of the Linux kernel!Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. Some routes cannot be connected if they are used. *** Current Wireguard protocol outbound Is not supported streamSettings. --- .../luasrc/model/cbi/shadowsocksr/client-config.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua index 3831ce64..44b29af2 100644 --- a/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua +++ b/luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua @@ -525,7 +525,9 @@ o.default = "3" o.rmempty = true o = s:option(Value, "timeout", translate("Timeout for establishing a connection to server(second)")) +o.description = translate("Default value 0 indicatesno heartbeat.") o:depends("type", "tuic") +o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) o.datatype = "uinteger" o.default = "8" o.rmempty = true @@ -861,12 +863,6 @@ o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) o.password = true o.rmempty = true -o = s:option(Value, "keepalive", translate("Heartbeat interval(second)")) -o.description = translate("Default value 0 indicatesno heartbeat.") -o:depends({type = "v2ray", v2ray_protocol = "wireguard"}) -o.default = "0" -o.rmempty = true - o = s:option(DynamicList, "allowedips", translate("allowedIPs(optional)")) o.description = translate("Wireguard allows only traffic from specific source IP.") o.datatype = "cidr" From f60f1978a0b5feaf801b84e7a0ed4b86cba400f9 Mon Sep 17 00:00:00 2001 From: zxlhhyccc <45259624+zxlhhyccc@users.noreply.github.com> Date: Sat, 6 Apr 2024 09:48:42 +0800 Subject: [PATCH 5/5] luci-app-ssr-plus: Add WireGuard `kernelMode` `reserved` `keepalive` `allowedips` argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *** whether to use the virtual NIC TUN of the Linux kernel!Virtual NIC TUN of Linux kernel can be used only when system supports and have root permission. Some routes cannot be connected if they are used. *** Current Wireguard protocol outbound Is not supported streamSettings. --- luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua b/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua index c98d623a..b07949e5 100755 --- a/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua +++ b/luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua @@ -73,7 +73,7 @@ function wireguard() publicKey = server.peer_pubkey, preSharedKey = server.preshared_key, endpoint = server.server .. ":" .. server.server_port, - keepAlive = tonumber(server.keepalive), + keepAlive = tonumber(server.heartbeat), allowedIPs = (server.allowedips) or nil, } },