mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-11-12 06:00:52 +08:00
15 lines
411 B
Go
15 lines
411 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
|
|
}
|