From 42d563934b76351fd422cf3e26486697f5b2fe09 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 5 May 2020 23:55:55 +0300 Subject: [PATCH] lib/promscrape: properly connect to TCP6 addresses if `-enableTCP6` is set --- lib/promscrape/statconn.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/promscrape/statconn.go b/lib/promscrape/statconn.go index eaf44a54bc..10d45f4aa0 100644 --- a/lib/promscrape/statconn.go +++ b/lib/promscrape/statconn.go @@ -4,12 +4,17 @@ import ( "net" "sync/atomic" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/netutil" "github.com/VictoriaMetrics/fasthttp" "github.com/VictoriaMetrics/metrics" ) -func statDial(addr string) (net.Conn, error) { - conn, err := fasthttp.Dial(addr) +func statDial(addr string) (conn net.Conn, err error) { + if netutil.TCP6Enabled() { + conn, err = fasthttp.DialDualStack(addr) + } else { + conn, err = fasthttp.Dial(addr) + } dialsTotal.Inc() if err != nil { dialErrors.Inc()