mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 09:16:58 +08:00
19 lines
299 B
Go
Executable File
19 lines
299 B
Go
Executable File
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)
|
|
}
|
|
}
|