mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-03 07:56:42 -05:00
25 lines
408 B
Go
25 lines
408 B
Go
// +build !confonly
|
|
|
|
package dispatcher
|
|
|
|
import "context"
|
|
|
|
//go:generate errorgen
|
|
|
|
type key int
|
|
|
|
const (
|
|
sniffing key = iota
|
|
)
|
|
|
|
func ContextWithSniffingResult(ctx context.Context, r SniffResult) context.Context {
|
|
return context.WithValue(ctx, sniffing, r)
|
|
}
|
|
|
|
func SniffingResultFromContext(ctx context.Context) SniffResult {
|
|
if c, ok := ctx.Value(sniffing).(SniffResult); ok {
|
|
return c
|
|
}
|
|
return nil
|
|
}
|