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 6388d07f64
commit c0e2cf63b5

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,