mirror of
https://github.com/TwiN/gatus.git
synced 2025-06-27 21:21:56 +02:00
fix(client): Correctly parse hostname for ICMP endpoint when using IPv6 (#1043)
Fixes #1042
This commit is contained in:
parent
55d7bcdf2e
commit
75b99d3072
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user