From 59e5d24280812ce39674348878f96bef64cf32b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 20 Nov 2024 13:00:40 +0800 Subject: [PATCH] WireGuard inbound: Fix leaking session information between requests (#4030) Fixes https://github.com/XTLS/Xray-core/issues/3948 https://github.com/XTLS/Xray-core/issues/4025 --- proxy/wireguard/server.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/proxy/wireguard/server.go b/proxy/wireguard/server.go index 77aa4985..8ab84fe4 100644 --- a/proxy/wireguard/server.go +++ b/proxy/wireguard/server.go @@ -144,15 +144,20 @@ func (s *Server) forwardConnection(dest net.Destination, conn net.Conn) { Reason: "", }) - if s.info.inboundTag != nil { - ctx = session.ContextWithInbound(ctx, s.info.inboundTag) - } - if s.info.outboundTag != nil { - ctx = session.ContextWithOutbounds(ctx, []*session.Outbound{s.info.outboundTag}) - } - if s.info.contentTag != nil { - ctx = session.ContextWithContent(ctx, s.info.contentTag) - } + // what's this? + // Session information should not be shared between different connections + // why reuse them in server level? This will cause incorrect destoverride and unexpected routing behavior. + // Disable it temporarily. Maybe s.info should be removed. + + // if s.info.inboundTag != nil { + // ctx = session.ContextWithInbound(ctx, s.info.inboundTag) + // } + // if s.info.outboundTag != nil { + // ctx = session.ContextWithOutbounds(ctx, []*session.Outbound{s.info.outboundTag}) + // } + // if s.info.contentTag != nil { + // ctx = session.ContextWithContent(ctx, s.info.contentTag) + // } link, err := s.info.dispatcher.Dispatch(ctx, dest) if err != nil {