Skip to content

Commit

Permalink
upstream: imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Jan 30, 2024
1 parent 313c715 commit 767d954
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions upstream/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,14 @@ func validateUpstreamURL(u *url.URL) (err error) {
host = h
}

_, err = netip.ParseAddr(host)
if err == nil {
return nil
}

// If it's an IPv6 address enclosed in square brackets with no port.
//
// See https://github.com/AdguardTeam/dnsproxy/issues/379.
_, err = netip.ParseAddr(u.Hostname())
if strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") {
_, err = netip.ParseAddr(host[1 : len(host)-1])
} else {
_, err = netip.ParseAddr(host)
}
if err == nil {
return nil
}
Expand Down

0 comments on commit 767d954

Please sign in to comment.