app/vmagent/remotewrite: properly dial TCP6 addresses set via -remoteWrite.url

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/469
This commit is contained in:
Aliaksandr Valialkin 2020-05-12 15:22:27 +03:00
parent 3232605524
commit 6273385618

View file

@ -4,12 +4,17 @@ import (
"net" "net"
"sync/atomic" "sync/atomic"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/netutil"
"github.com/VictoriaMetrics/fasthttp" "github.com/VictoriaMetrics/fasthttp"
"github.com/VictoriaMetrics/metrics" "github.com/VictoriaMetrics/metrics"
) )
func statDial(addr string) (net.Conn, error) { func statDial(addr string) (conn net.Conn, err error) {
conn, err := fasthttp.Dial(addr) if netutil.TCP6Enabled() {
conn, err = fasthttp.DialDualStack(addr)
} else {
conn, err = fasthttp.Dial(addr)
}
dialsTotal.Inc() dialsTotal.Inc()
if err != nil { if err != nil {
dialErrors.Inc() dialErrors.Inc()