mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-18 07:24:31 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user