fix(outputs.graphite): Handle local address without port correctly (#15224)

This commit is contained in:
Morian Sonnet 2024-04-25 20:25:34 +02:00 committed by GitHub
parent 274333921f
commit 42401a3175
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -109,8 +109,11 @@ func (g *Graphite) Connect() error {
if g.LocalAddr != "" {
// Resolve the local address into IP address and the given port if any
addr, sPort, err := net.SplitHostPort(g.LocalAddr)
if err != nil && !strings.Contains(err.Error(), "missing port") {
return fmt.Errorf("invalid local address: %w", err)
if err != nil {
if !strings.Contains(err.Error(), "missing port") {
return fmt.Errorf("invalid local address: %w", err)
}
addr = g.LocalAddr
}
local, err := net.ResolveIPAddr("ip", addr)
if err != nil {