1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-08-31 00:34:14 -04:00
v2fly/app/dispatcher/dispatcher.go

23 lines
480 B
Go
Raw Normal View History

2016-01-31 11:01:28 -05:00
package dispatcher
2018-07-16 07:47:00 -04:00
import "context"
//go:generate go run $GOPATH/src/v2ray.com/core/common/errors/errorgen/main.go -pkg dispatcher -path App,Dispatcher
2018-07-16 07:47:00 -04: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
}