mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-14 20:39:36 +03:00
XUDP protocol: Add Global ID & UoT Migration
The first UoT protocol that supports UoT Migration Thank @yuhan6665 for testing
This commit is contained in:
@ -2,10 +2,14 @@ package session
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "unsafe"
|
||||
|
||||
"github.com/xtls/xray-core/features/routing"
|
||||
)
|
||||
|
||||
//go:linkname IndependentCancelCtx context.newCancelCtx
|
||||
func IndependentCancelCtx(parent context.Context) context.Context
|
||||
|
||||
type sessionKey int
|
||||
|
||||
const (
|
||||
@ -17,6 +21,7 @@ const (
|
||||
sockoptSessionKey
|
||||
trackedConnectionErrorKey
|
||||
dispatcherKey
|
||||
timeoutOnlyKey
|
||||
)
|
||||
|
||||
// ContextWithID returns a new context with the given ID.
|
||||
@ -131,3 +136,14 @@ func DispatcherFromContext(ctx context.Context) routing.Dispatcher {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ContextWithTimeoutOnly(ctx context.Context, only bool) context.Context {
|
||||
return context.WithValue(ctx, timeoutOnlyKey, only)
|
||||
}
|
||||
|
||||
func TimeoutOnlyFromContext(ctx context.Context) bool {
|
||||
if val, ok := ctx.Value(timeoutOnlyKey).(bool); ok {
|
||||
return val
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user