Skip to content

Commit

Permalink
upstream: imp cognit
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Nov 8, 2023
1 parent 35ce9dc commit 8582ed9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions upstream/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ func (r *UpstreamResolver) lookup(host, network string) (ips []netip.Addr, err e
switch network {
case "ip4", "ip6":
ips, err = r.resolve(host, network)
if err != nil {
return []netip.Addr{}, err
}
case "ip":
resCh := make(chan any, 2)
go r.resolveAsync(resCh, host, "ip4")
Expand All @@ -204,14 +201,16 @@ func (r *UpstreamResolver) lookup(host, network string) (ips []netip.Addr, err e
}
}

if err = errors.Join(errs...); len(ips) == 0 && err != nil {
return nil, err
}
err = errors.Join(errs...)
default:
return []netip.Addr{}, fmt.Errorf("unsupported network %s", network)
}

return ips, nil
if len(ips) == 0 {
ips = []netip.Addr{}
}

return ips, err
}

// StaticResolver is a resolver which always responds with an underlying slice
Expand Down

0 comments on commit 8582ed9

Please sign in to comment.