github.com/sagernet/sing-box@v1.9.0-rc.20/common/interrupt/context.go (about) 1 package interrupt 2 3 import "context" 4 5 type contextKeyIsExternalConnection struct{} 6 7 func ContextWithIsExternalConnection(ctx context.Context) context.Context { 8 return context.WithValue(ctx, contextKeyIsExternalConnection{}, true) 9 } 10 11 func IsExternalConnectionFromContext(ctx context.Context) bool { 12 return ctx.Value(contextKeyIsExternalConnection{}) != nil 13 }