From d3248a4f8ecbf7ebd6380ffef9642f0b03e64234 Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Wed, 10 Sep 2025 13:43:21 +0200 Subject: [PATCH] app/reverse/bridge.go: Add timer nil check (#5119) Fixes https://github.com/XTLS/Xray-core/issues/5120 --- app/reverse/bridge.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/reverse/bridge.go b/app/reverse/bridge.go index fe3b2c3a..74e20497 100644 --- a/app/reverse/bridge.go +++ b/app/reverse/bridge.go @@ -55,7 +55,9 @@ func (b *Bridge) cleanup() { activeWorkers = append(activeWorkers, w) } if w.Closed() { - w.Timer.SetTimeout(0) + if w.Timer != nil { + w.Timer.SetTimeout(0) + } } } @@ -166,19 +168,25 @@ func (w *BridgeWorker) handleInternalConn(link *transport.Link) { for { mb, err := reader.ReadMultiBuffer() if err != nil { - if w.Closed() { - w.Timer.SetTimeout(0) - } else { - w.Timer.SetTimeout(24 * time.Hour) + if w.Timer != nil { + if w.Closed() { + w.Timer.SetTimeout(0) + } else { + w.Timer.SetTimeout(24 * time.Hour) + } } return } - w.Timer.Update() + if w.Timer != nil { + w.Timer.Update() + } for _, b := range mb { var ctl Control if err := proto.Unmarshal(b.Bytes(), &ctl); err != nil { errors.LogInfoInner(context.Background(), err, "failed to parse proto message") - w.Timer.SetTimeout(0) + if w.Timer != nil { + w.Timer.SetTimeout(0) + } return } if ctl.State != w.State {