From 75b99d30729acae81671131c8299fd2a7dbd8dc3 Mon Sep 17 00:00:00 2001 From: TwiN Date: Wed, 26 Mar 2025 18:46:46 -0400 Subject: [PATCH] fix(client): Correctly parse hostname for ICMP endpoint when using IPv6 (#1043) Fixes #1042 --- config/endpoint/endpoint.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/endpoint/endpoint.go b/config/endpoint/endpoint.go index dfd52336..39e26e9e 100644 --- a/config/endpoint/endpoint.go +++ b/config/endpoint/endpoint.go @@ -264,6 +264,10 @@ func (e *Endpoint) EvaluateHealth() *Result { // Parse or extract hostname from URL if e.DNSConfig != nil { result.Hostname = strings.TrimSuffix(e.URL, ":53") + } else if e.Type() == TypeICMP { + // To handle IPv6 addresses, we need to handle the hostname differently here. This is to avoid, for instance, + // "1111:2222:3333::4444" being displayed as "1111:2222:3333:" because :4444 would be interpreted as a port. + result.Hostname = strings.TrimPrefix(e.URL, "icmp://") } else { urlObject, err := url.Parse(e.URL) if err != nil {