mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-14 00:51:12 +03:00
24 lines
682 B
Go
24 lines
682 B
Go
package interrupt
|
|
|
|
import "context"
|
|
|
|
type contextKeyIsExternalConnection struct{}
|
|
|
|
func ContextWithIsExternalConnection(ctx context.Context) context.Context {
|
|
return context.WithValue(ctx, contextKeyIsExternalConnection{}, true)
|
|
}
|
|
|
|
func IsExternalConnectionFromContext(ctx context.Context) bool {
|
|
return ctx.Value(contextKeyIsExternalConnection{}) != nil
|
|
}
|
|
|
|
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
|
|
}
|