fix(client): Correctly parse hostname for ICMP endpoint when using IPv6 (#1043)

Fixes #1042
This commit is contained in:
TwiN 2025-03-26 18:46:46 -04:00 committed by GitHub
parent 55d7bcdf2e
commit 75b99d3072
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -264,6 +264,10 @@ func (e *Endpoint) EvaluateHealth() *Result {
// Parse or extract hostname from URL // Parse or extract hostname from URL
if e.DNSConfig != nil { if e.DNSConfig != nil {
result.Hostname = strings.TrimSuffix(e.URL, ":53") 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 { } else {
urlObject, err := url.Parse(e.URL) urlObject, err := url.Parse(e.URL)
if err != nil { if err != nil {