Skip to content

Commit 95539ec

Browse files
authored
Merge pull request #1445 from zxlhhyccc/patch-47
luci-app-ssr-plus: fix `WireGuard protocol` failure to connect problem.
2 parents 03a8dfe + f60f197 commit 95539ec

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ o.default = "3"
525525
o.rmempty = true
526526

527527
o = s:option(Value, "timeout", translate("Timeout for establishing a connection to server(second)"))
528+
o.description = translate("Default value 0 indicatesno heartbeat.")
528529
o:depends("type", "tuic")
530+
o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
529531
o.datatype = "uinteger"
530532
o.default = "8"
531533
o.rmempty = true
@@ -831,11 +833,22 @@ o:depends("transport", "kcp")
831833
o.rmempty = true
832834

833835
-- [[ WireGuard 部分 ]]--
836+
o = s:option(Flag, "kernelmode", translate("Enabled Kernel virtual NIC TUN(optional)"))
837+
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.")
838+
o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
839+
o.default = "0"
840+
o.rmempty = true
841+
834842
o = s:option(DynamicList, "local_addresses", translate("Local addresses"))
835843
o.datatype = "cidr"
836844
o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
837845
o.rmempty = true
838846

847+
o = s:option(DynamicList, "reserved", translate("Reserved bytes(optional)"))
848+
o.description = translate("Wireguard reserved bytes.")
849+
o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
850+
o.rmempty = true
851+
839852
o = s:option(Value, "private_key", translate("Private key"))
840853
o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
841854
o.password = true
@@ -850,6 +863,13 @@ o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
850863
o.password = true
851864
o.rmempty = true
852865

866+
o = s:option(DynamicList, "allowedips", translate("allowedIPs(optional)"))
867+
o.description = translate("Wireguard allows only traffic from specific source IP.")
868+
o.datatype = "cidr"
869+
o:depends({type = "v2ray", v2ray_protocol = "wireguard"})
870+
o.default = "0.0.0.0/0"
871+
o.rmempty = true
872+
853873
-- [[ TLS ]]--
854874
o = s:option(Flag, "tls", translate("TLS"))
855875
o.rmempty = true

luci-app-ssr-plus/po/zh-cn/ssr-plus.po

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,21 @@ msgstr "写入缓冲区大小"
942942
msgid "Congestion"
943943
msgstr "拥塞控制"
944944

945+
msgid "Enabled Kernel virtual NIC TUN(optional)"
946+
msgstr "启用内核的虚拟网卡 TUN(可选)"
947+
948+
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."
949+
msgstr "需要系统支持且有 root 权限才能使用 Linux 内核的虚拟网卡 TUN,使用后会占用 IPv6 的 1023 号路由表。"
950+
945951
msgid "Local addresses"
946952
msgstr "本地地址"
947953

954+
msgid "Reserved bytes(optional)"
955+
msgstr "保留字节(可选)"
956+
957+
msgid "Wireguard reserved bytes."
958+
msgstr "Wireguard 保留字节。"
959+
948960
msgid "Private key"
949961
msgstr "私钥"
950962

@@ -954,6 +966,15 @@ msgstr "节点公钥"
954966
msgid "Pre-shared key"
955967
msgstr "预共享密钥"
956968

969+
msgid "Default value 0 indicatesno heartbeat."
970+
msgstr "默认为 0 表示无心跳。"
971+
972+
msgid "allowedIPs(optional)"
973+
msgstr "allowedIPs(可选)"
974+
975+
msgid "Wireguard allows only traffic from specific source IP."
976+
msgstr "Wireguard 仅允许特定源 IP 的流量。"
977+
957978
msgid "Network interface to use"
958979
msgstr "使用的网络接口"
959980

luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ function wireguard()
7272
{
7373
publicKey = server.peer_pubkey,
7474
preSharedKey = server.preshared_key,
75-
endpoint = server.server .. ":" .. server.server_port
75+
endpoint = server.server .. ":" .. server.server_port,
76+
keepAlive = tonumber(server.heartbeat),
77+
allowedIPs = (server.allowedips) or nil,
7678
}
7779
},
80+
kernelMode = (server.kernelmode == "1") and true or false,
81+
reserved = {server.reserved} or nil,
7882
mtu = tonumber(server.mtu)
7983
}
8084
end
@@ -172,7 +176,7 @@ local Xray = {
172176
protocol = server.v2ray_protocol,
173177
settings = outbound_settings,
174178
-- 底层传输配置
175-
streamSettings = {
179+
streamSettings = (server.v2ray_protocol ~= "wireguard") and {
176180
network = server.transport or "tcp",
177181
security = (server.tls == '1') and "tls" or (server.reality == '1') and "reality" or nil,
178182
tlsSettings = (server.tls == '1') and {
@@ -258,14 +262,14 @@ local Xray = {
258262
tcpNoDelay = (server.mptcp == "1") and true or false, -- MPTCP
259263
tcpcongestion = server.custom_tcpcongestion -- 连接服务器节点的 TCP 拥塞控制算法
260264
}
261-
},
262-
mux = {
265+
} or nil,
266+
mux = (server.v2ray_protocol ~= "wireguard") and {
263267
-- mux
264268
enabled = (server.mux == "1") and true or false, -- Mux
265269
concurrency = tonumber(server.concurrency), -- TCP 最大并发连接数
266270
xudpConcurrency = tonumber(server.xudpConcurrency), -- UDP 最大并发连接数
267271
xudpProxyUDP443 = server.xudpProxyUDP443 -- 对被代理的 UDP/443 流量处理方式
268-
}
272+
} or nil
269273
}
270274
}
271275
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 = {
322326
}
323327
local hysteria = {
324328
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")),
325-
bandwidth = {
329+
bandwidth = (server.uplink_capacity or server.downlink_capacity) and {
326330
up = tonumber(server.uplink_capacity) and tonumber(server.uplink_capacity) .. " mbps" or nil,
327331
down = tonumber(server.downlink_capacity) and tonumber(server.downlink_capacity) .. " mbps" or nil
328332
},
@@ -336,12 +340,11 @@ local hysteria = {
336340
hopInterval = (server.port_range and (tonumber(server.hopinterval) .. "s") or nil)
337341
} or nil)
338342
} or nil,
339-
340343
--[[
341344
tcpTProxy = (proto:find("tcp") and local_port ~= "0") and {
342-
listen = "0.0.0.0:" .. tonumber(local_port)
343-
} or nil,
344-
]]
345+
listen = "0.0.0.0:" .. tonumber(local_port)
346+
} or nil,
347+
]]--
345348
tcpRedirect = (proto:find("tcp") and local_port ~= "0") and {
346349
listen = "0.0.0.0:" .. tonumber(local_port)
347350
} or nil,
@@ -359,7 +362,7 @@ local hysteria = {
359362
maxConnReceiveWindow = (server.maxconnreceivewindow and server.maxconnreceivewindow or nil),
360363
maxIdleTimeout = (tonumber(server.maxidletimeout) and tonumber(server.maxidletimeout) .. "s" or nil),
361364
keepAlivePeriod = (tonumber(server.keepaliveperiod) and tonumber(server.keepaliveperiod) .. "s" or nil),
362-
disable_mtu_discovery = (server.disablepathmtudiscovery == "1") and true or false
365+
disablePathMTUDiscovery = (server.disablepathmtudiscovery == "1") and true or false
363366
} or nil,
364367
auth = server.hy2_auth,
365368
tls = (server.tls_host) and {
@@ -394,7 +397,7 @@ local chain_sslocal = {
394397
mode = (proto:find("tcp,udp") and "tcp_and_udp") or proto .. "_only",
395398
protocol = "redir",
396399
tcp_redir = "redirect",
397-
--tcp_redir = "tproxy",
400+
--tcp_redir = "tproxy",
398401
udp_redir = "tproxy"
399402
},
400403
socks_port ~= "0" and {

0 commit comments

Comments
 (0)