1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-06-17 16:29:55 -04:00

resolve to ip on demand

This commit is contained in:
Darien Raymond
2017-11-15 12:55:47 +01:00
parent f3c5df8798
commit 26f005e822
5 changed files with 101 additions and 53 deletions

View File

@@ -64,11 +64,15 @@ func InboundTagFromContext(ctx context.Context) (string, bool) {
return v, ok
}
func ContextWithResolveIPs(ctx context.Context, ips []net.Address) context.Context {
return context.WithValue(ctx, resolvedIPsKey, ips)
type IPResolver interface {
Resolve() []net.Address
}
func ResolvedIPsFromContext(ctx context.Context) ([]net.Address, bool) {
ips, ok := ctx.Value(resolvedIPsKey).([]net.Address)
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
}