Files
sing-box-extended-mirror/common/interrupt/context.go
T
2026-11-30 19:46:00 +03:00

25 lines
734 B
Go

package interrupt
import "context"
type contextKeyIsExternalConnection struct{}
func ContextWithIsExternalConnection(ctx context.Context, isExternal bool) context.Context {
return context.WithValue(ctx, contextKeyIsExternalConnection{}, isExternal)
}
func IsExternalConnectionFromContext(ctx context.Context) bool {
isExternal, _ := ctx.Value(contextKeyIsExternalConnection{}).(bool)
return isExternal
}
type contextKeyIsProviderConnection struct{}
func ContextWithIsProviderConnection(ctx context.Context) context.Context {
return context.WithValue(ctx, contextKeyIsProviderConnection{}, true)
}
func IsProviderConnectionFromContext(ctx context.Context) bool {
return ctx.Value(contextKeyIsProviderConnection{}) != nil
}