Loopback outbound: Avoid directly modifying potential shared ctx (#5960)

Fixes https://github.com/XTLS/Xray-core/issues/5958
This commit is contained in:
风扇滑翔翼
2026-04-18 05:41:10 +08:00
committed by GitHub
parent a9cec25b8d
commit df4b97097c

View File

@@ -45,9 +45,11 @@ func (l *Loopback) Process(ctx context.Context, link *transport.Link, _ internet
ctx = session.ContextWithContent(ctx, content)
inbound := session.InboundFromContext(ctx)
if inbound == nil {
inbound = &session.Inbound{}
inbound := &session.Inbound{}
originInbound := session.InboundFromContext(ctx)
if originInbound != nil {
// get a shallow copy to avoid modifying the inbound tag in upstream context
*inbound = *originInbound
}
inbound.Tag = l.config.InboundTag