From 767d95468d9c6d09cf7409c5b5ea1c612e3e6a24 Mon Sep 17 00:00:00 2001 From: Stanislav Chzhen Date: Tue, 30 Jan 2024 19:31:07 +0300 Subject: [PATCH] upstream: imp code --- upstream/upstream.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/upstream/upstream.go b/upstream/upstream.go index 3a5113d39..51543f4ed 100644 --- a/upstream/upstream.go +++ b/upstream/upstream.go @@ -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 }