Tidy up last change to socket listener/writer
This commit is contained in:
parent
37474d28a5
commit
fc74c1afa5
|
@ -13,6 +13,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/inputs"
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||||||
|
@ -338,14 +339,6 @@ func (uc unixCloser) Close() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uc unixCloser) Accept() (net.Conn, error) {
|
|
||||||
return uc.closer.(net.Listener).Accept()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (uc unixCloser) Addr() net.Addr {
|
|
||||||
return uc.closer.(net.Listener).Addr()
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
inputs.Add("socket_listener", func() telegraf.Input { return newSocketListener() })
|
inputs.Add("socket_listener", func() telegraf.Input { return newSocketListener() })
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
"github.com/influxdata/telegraf/plugins/outputs"
|
"github.com/influxdata/telegraf/plugins/outputs"
|
||||||
|
@ -70,11 +71,6 @@ func (sw *SocketWriter) SetSerializer(s serializers.Serializer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sw *SocketWriter) Connect() error {
|
func (sw *SocketWriter) Connect() error {
|
||||||
var (
|
|
||||||
c net.Conn
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
spl := strings.SplitN(sw.Address, "://", 2)
|
spl := strings.SplitN(sw.Address, "://", 2)
|
||||||
if len(spl) != 2 {
|
if len(spl) != 2 {
|
||||||
return fmt.Errorf("invalid address: %s", sw.Address)
|
return fmt.Errorf("invalid address: %s", sw.Address)
|
||||||
|
@ -85,6 +81,7 @@ func (sw *SocketWriter) Connect() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var c net.Conn
|
||||||
if tlsCfg == nil {
|
if tlsCfg == nil {
|
||||||
c, err = net.Dial(spl[0], spl[1])
|
c, err = net.Dial(spl[0], spl[1])
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue