without cancel the context

This commit is contained in:
ginuerzh
2025-08-05 20:24:00 +08:00
parent fd9dc6408a
commit 404aaae5f1
8 changed files with 11 additions and 46 deletions
-26
View File
@@ -6,7 +6,6 @@ import (
"github.com/go-gost/core/logger"
"github.com/go-gost/core/metadata"
xctx "github.com/go-gost/x/ctx"
xrecorder "github.com/go-gost/x/recorder"
)
@@ -53,28 +52,3 @@ func RecorderObjectFromContext(ctx context.Context) *xrecorder.HandlerRecorderOb
v, _ := ctx.Value(recorderObjectCtxKey{}).(*xrecorder.HandlerRecorderObject)
return v
}
func Copy(ctx context.Context) context.Context {
if ctx == nil {
return nil
}
ctx2 := context.Background()
if v := xctx.SrcAddrFromContext(ctx); v != nil {
ctx2 = xctx.ContextWithSrcAddr(ctx2, v)
}
if v := xctx.DstAddrFromContext(ctx); v != nil {
ctx2 = xctx.ContextWithDstAddr(ctx2, v)
}
if v := xctx.SidFromContext(ctx); v != "" {
ctx2 = xctx.ContextWithSid(ctx2, v)
}
if v := xctx.ClientIDFromContext(ctx); v != "" {
ctx2 = xctx.ContextWithClientID(ctx2, v)
}
if v := MetadataFromContext(ctx); v != nil {
ctx2 = ContextWithMetadata(ctx2, v)
}
return ctx2
}