cleanup unused scenarios

This commit is contained in:
Darien Raymond
2018-10-22 22:40:53 +02:00
parent 17e51b277b
commit c2566e1331
4 changed files with 23 additions and 41 deletions
-26
View File
@@ -1,26 +0,0 @@
package proxy
import (
"context"
"v2ray.com/core/common/net"
)
type key uint32
const (
resolvedIPsKey key = iota
)
type IPResolver interface {
Resolve() []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
}
-9
View File
@@ -18,7 +18,6 @@ import (
"v2ray.com/core/common/vio"
"v2ray.com/core/features/dns"
"v2ray.com/core/features/policy"
"v2ray.com/core/proxy"
"v2ray.com/core/transport/internet"
)
@@ -59,14 +58,6 @@ func (h *Handler) policy() policy.Session {
}
func (h *Handler) resolveIP(ctx context.Context, domain string) net.Address {
if resolver, ok := proxy.ResolvedIPsFromContext(ctx); ok {
ips := resolver.Resolve()
if len(ips) == 0 {
return nil
}
return ips[dice.Roll(len(ips))]
}
ips, err := h.dns.LookupIP(domain)
if err != nil {
newError("failed to get IP address for domain ", domain).Base(err).WriteToLog(session.ExportIDToError(ctx))