You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

18 lines
299 B

package proxy
import (
"net"
"time"
)
const (
tcpKeepAlivePeriod = 30 * time.Second
)
// setKeepAlive sets tcp keepalive option for tcp connection.
func setKeepAlive(c net.Conn) {
if tcp, ok := c.(*net.TCPConn); ok {
tcp.SetKeepAlive(true)
tcp.SetKeepAlivePeriod(tcpKeepAlivePeriod)
}
}