(ctx context.Context, name string)
| 32 | } |
| 33 | |
| 34 | func (u *UpstreamResolver) Resolve(ctx context.Context, name string) (context.Context, net.IP, error) { |
| 35 | log.Println("Redirected DNS lookup:", name) |
| 36 | addrs, err := u.r.LookupIPAddr(ctx, name) |
| 37 | if err != nil { |
| 38 | return ctx, nil, err |
| 39 | } |
| 40 | if len(addrs) == 0 { |
| 41 | return ctx, nil, nil |
| 42 | } |
| 43 | // Prefer IPv4, like ResolveIPAddr. I can hear Olafur screaming, but the default |
| 44 | // go-socks5 Resolver uses ResolveIPAddr, and the interface does not allow any better. |
| 45 | for _, addr := range addrs { |
| 46 | if addr.IP.To4() != nil { |
| 47 | return ctx, addr.IP, nil |
| 48 | } |
| 49 | } |
| 50 | return ctx, addrs[0].IP, nil |
| 51 | // (Why the hell does this *return* a context?) |
| 52 | } |
| 53 | |
| 54 | type Config struct { |
| 55 | SOCKS5Addr string `toml:"socks5-addr"` |
nothing calls this directly
no outgoing calls
no test coverage detected