diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index 2f9277eb..20aebdb3 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -132,9 +132,10 @@ func (s *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection continue } + currentPacketCtx := ctx dest := request.Destination() if inbound.Source.IsValid() { - ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ + currentPacketCtx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ From: inbound.Source, To: dest, Status: log.AccessAccepted, @@ -142,10 +143,10 @@ func (s *Server) handlerUDPPayload(ctx context.Context, conn internet.Connection Email: request.User.Email, }) } - newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(ctx)) + newError("tunnelling request to ", dest).WriteToLog(session.ExportIDToError(currentPacketCtx)) - ctx = protocol.ContextWithRequestHeader(ctx, request) - udpServer.Dispatch(ctx, dest, data) + currentPacketCtx = protocol.ContextWithRequestHeader(currentPacketCtx, request) + udpServer.Dispatch(currentPacketCtx, dest, data) } }