mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-02 09:48:43 +00:00
Simplify multi-peer WireGuard fix with read timeout
Replaced complex unified reader with minimal changes: - Add 50ms read deadline to prevent readers from blocking indefinitely - Use core.ToBackgroundDetachedContext for connection independence - Clear deadline after read completes - Allows multiple peer readers to timeout and retry instead of blocking This is much simpler than the unified reader architecture while still solving the core blocking issue. When a reader times out, it returns and another reader can try, allowing all peers to work. Tests pass. Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
@@ -114,12 +114,6 @@ func (h *Handler) processWireGuard(ctx context.Context, dialer internet.Dialer)
|
||||
}
|
||||
|
||||
// bind := conn.NewStdNetBind() // TODO: conn.Bind wrapper for dialer
|
||||
// Set workers to number of peers if not explicitly configured
|
||||
// This allows concurrent packet reception from multiple peers
|
||||
workers := int(h.conf.NumWorkers)
|
||||
if workers <= 0 && len(h.conf.Peers) > 0 {
|
||||
workers = len(h.conf.Peers)
|
||||
}
|
||||
h.bind = &netBindClient{
|
||||
netBind: netBind{
|
||||
dns: h.dns,
|
||||
@@ -127,7 +121,7 @@ func (h *Handler) processWireGuard(ctx context.Context, dialer internet.Dialer)
|
||||
IPv4Enable: h.hasIPv4,
|
||||
IPv6Enable: h.hasIPv6,
|
||||
},
|
||||
workers: workers,
|
||||
workers: int(h.conf.NumWorkers),
|
||||
},
|
||||
ctx: core.ToBackgroundDetachedContext(ctx),
|
||||
dialer: dialer,
|
||||
|
||||
Reference in New Issue
Block a user