fix(inputs.socket_listener): Fix TLS socket initialization(#13050)

This commit is contained in:
Patrick Hemmer 2023-04-13 08:30:33 -04:00 committed by GitHub
parent 9b742a1540
commit 596ecc4a67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -82,6 +82,10 @@ func (l *streamListener) setupUnix(u *url.URL, tlsCfg *tls.Config, socketMode st
}
func (l *streamListener) setupConnection(conn net.Conn) error {
if c, ok := conn.(*tls.Conn); ok {
conn = c.NetConn()
}
if l.ReadBufferSize > 0 {
if rb, ok := conn.(hasSetReadBuffer); ok {
if err := rb.SetReadBuffer(l.ReadBufferSize); err != nil {
@ -104,7 +108,7 @@ func (l *streamListener) setupConnection(conn net.Conn) error {
if l.KeepAlivePeriod != nil {
tcpConn, ok := conn.(*net.TCPConn)
if !ok {
return fmt.Errorf("connection not a TCP connection (%T)", conn)
return fmt.Errorf("cannot set keep-alive: not a TCP connection (%T)", conn)
}
if *l.KeepAlivePeriod == 0 {
if err := tcpConn.SetKeepAlive(false); err != nil {