MCPcopy Create free account
hub / github.com/FiloSottile/captive-browser / Resolve

Method Resolve

main.go:34–52  ·  view source on GitHub ↗
(ctx context.Context, name string)

Source from the content-addressed store, hash-verified

32}
33
34func (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
54type Config struct {
55 SOCKS5Addr string `toml:"socks5-addr"`

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected