fix(health/check): validate URL port before dialing in Stream check

Add port validation to return an unhealthy result with descriptive
message when URL has no port specified, preventing potential dialing
errors on zero port.
This commit is contained in:
yusing
2026-01-31 18:50:13 +08:00
parent c6e4e83fcd
commit 5c30f4a859

View File

@@ -12,6 +12,14 @@ import (
)
func Stream(ctx context.Context, url *url.URL, timeout time.Duration) (types.HealthCheckResult, error) {
if port := url.Port(); port == "" || port == "0" {
return types.HealthCheckResult{
Latency: 0,
Healthy: false,
Detail: "no port specified",
}, nil
}
dialer := net.Dialer{
Timeout: timeout,
FallbackDelay: -1,