From 60bb04d0e7cfefce9723773914f665b287cdd0f6 Mon Sep 17 00:00:00 2001 From: Steve Brunton Date: Mon, 11 Nov 2019 17:13:46 -0500 Subject: [PATCH] dialers with timeouts (#57) * added Dials with timeouts to deal with dead devices * bump for version release --- VERSION | 2 +- collector/collector.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 82aa315f..59e9e604 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.11-DEVEL +1.0.11 diff --git a/collector/collector.go b/collector/collector.go index 0b66c31b..47b611cc 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -245,7 +245,7 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) { log.WithField("device", d.Name).Debug("trying to Dial") if !c.enableTLS { - conn, err = net.Dial("tcp", d.Address+apiPort) + conn, err = net.DialTimeout("tcp", d.Address+apiPort, c.timeout) if err != nil { return nil, err } @@ -254,7 +254,10 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) { tlsCfg := &tls.Config{ InsecureSkipVerify: c.insecureTLS, } - conn, err = tls.Dial("tcp", d.Address+apiPortTLS, tlsCfg) + conn, err = tls.DialWithDialer(&net.Dialer{ + Timeout: c.timeout, + }, + "tcp", d.Address+apiPortTLS, tlsCfg) if err != nil { return nil, err }