1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/proxy/context.go

27 lines
451 B
Go
Raw Normal View History

package proxy
import (
"context"
"v2ray.com/core/common/net"
)
type key uint32
const (
resolvedIPsKey key = iota
)
2017-11-15 06:55:47 -05:00
type IPResolver interface {
Resolve() []net.Address
}
2017-11-15 06:55:47 -05:00
func ContextWithResolveIPs(ctx context.Context, f IPResolver) context.Context {
return context.WithValue(ctx, resolvedIPsKey, f)
}
func ResolvedIPsFromContext(ctx context.Context) (IPResolver, bool) {
ips, ok := ctx.Value(resolvedIPsKey).(IPResolver)
return ips, ok
}