Skip to content

Commit

Permalink
support also checks for ipv6 endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
DockToFuture committed Oct 15, 2024
1 parent 610f0eb commit e3934e5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/agent/runners/checktcpport.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"

"github.com/gardener/network-problem-detector/pkg/common/config"

"github.com/spf13/cobra"
k8snetutils "k8s.io/utils/net"
)

type checkTCPPortArgs struct {
Expand Down Expand Up @@ -123,6 +123,9 @@ var _ Runner = &checkTCPPort{}

func checkTCPPortFunc(endpoint config.Endpoint) (string, error) {
addr := fmt.Sprintf("%s:%d", endpoint.IP, endpoint.Port)
if k8snetutils.IsIPv6(net.ParseIP(endpoint.IP)) {
addr = fmt.Sprintf("[%s]:%d", endpoint.IP, endpoint.Port)
}
conn, err := net.DialTimeout("tcp", addr, 30*time.Second)
if err != nil {
return "", err
Expand Down

0 comments on commit e3934e5

Please sign in to comment.