0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-13 11:59:35 +03:00

Fix data leak between mux.cool connections (#3718)

Fix #116
This commit is contained in:
mmmray
2024-08-25 21:02:01 +02:00
committed by GitHub
parent c0c23fdfeb
commit 3dd3bf94d4
3 changed files with 144 additions and 1 deletions

View File

@ -40,6 +40,22 @@ func ContextWithOutbounds(ctx context.Context, outbounds []*Outbound) context.Co
return context.WithValue(ctx, outboundSessionKey, outbounds)
}
func ContextCloneOutbounds(ctx context.Context) context.Context {
outbounds := OutboundsFromContext(ctx)
newOutbounds := make([]*Outbound, len(outbounds))
for i, ob := range outbounds {
if ob == nil {
continue
}
// copy outbound by value
v := *ob
newOutbounds[i] = &v
}
return ContextWithOutbounds(ctx, newOutbounds)
}
func OutboundsFromContext(ctx context.Context) []*Outbound {
if outbounds, ok := ctx.Value(outboundSessionKey).([]*Outbound); ok {
return outbounds