mirror of
https://github.com/nshttpd/mikrotik-exporter.git
synced 2025-03-13 13:29:29 +01:00
dialers with timeouts (#57)
* added Dials with timeouts to deal with dead devices * bump for version release
This commit is contained in:
parent
9fc2841a61
commit
60bb04d0e7
@ -245,7 +245,7 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) {
|
|||||||
|
|
||||||
log.WithField("device", d.Name).Debug("trying to Dial")
|
log.WithField("device", d.Name).Debug("trying to Dial")
|
||||||
if !c.enableTLS {
|
if !c.enableTLS {
|
||||||
conn, err = net.Dial("tcp", d.Address+apiPort)
|
conn, err = net.DialTimeout("tcp", d.Address+apiPort, c.timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -254,7 +254,10 @@ func (c *collector) connect(d *config.Device) (*routeros.Client, error) {
|
|||||||
tlsCfg := &tls.Config{
|
tlsCfg := &tls.Config{
|
||||||
InsecureSkipVerify: c.insecureTLS,
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user