From d21f98c6f94181dedeb7b194223bcf726fea3221 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Tue, 17 Jan 2023 23:51:59 +0000 Subject: [PATCH] use custom dialer for tcp probes Change-Id: I323b472606eaf3242b665022afe2a79ecf3b8358 --- pkg/probe/tcp/tcp.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/probe/tcp/tcp.go b/pkg/probe/tcp/tcp.go index 771bc047710..7ce1450470d 100644 --- a/pkg/probe/tcp/tcp.go +++ b/pkg/probe/tcp/tcp.go @@ -38,7 +38,7 @@ type Prober interface { type tcpProber struct{} -// Probe returns a ProbeRunner capable of running an TCP check. +// Probe checks that a TCP connection to the address can be opened. func (pr tcpProber) Probe(host string, port int, timeout time.Duration) (probe.Result, string, error) { return DoTCPProbe(net.JoinHostPort(host, strconv.Itoa(port)), timeout) } @@ -48,7 +48,9 @@ func (pr tcpProber) Probe(host string, port int, timeout time.Duration) (probe.R // If the socket fails to open, it returns Failure. // This is exported because some other packages may want to do direct TCP probes. func DoTCPProbe(addr string, timeout time.Duration) (probe.Result, string, error) { - conn, err := net.DialTimeout("tcp", addr, timeout) + d := probe.ProbeDialer() + d.Timeout = timeout + conn, err := d.Dial("tcp", addr) if err != nil { // Convert errors to failures to handle timeouts. return probe.Failure, err.Error(), nil