v2ray-core/app/dispatcher/dispatcher.go

23 lines
387 B
Go
Raw Normal View History

2016-01-31 16:01:28 +00:00
package dispatcher
2018-07-16 11:47:00 +00:00
import "context"
2018-09-30 21:08:41 +00:00
//go:generate errorgen
2018-07-16 11:47:00 +00:00
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
}