mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
20 lines
482 B
Go
20 lines
482 B
Go
//go:build go1.23
|
|
|
|
package net
|
|
|
|
import "net"
|
|
|
|
func tcpKeepAlive(tcp *net.TCPConn) {
|
|
config := net.KeepAliveConfig{
|
|
Enable: true,
|
|
Idle: KeepAliveIdle,
|
|
Interval: KeepAliveInterval,
|
|
}
|
|
if !SupportTCPKeepAliveCount() {
|
|
// it's recommended to set both Idle and Interval to non-negative values in conjunction with a -1
|
|
// for Count on those old Windows if you intend to customize the TCP keep-alive settings.
|
|
config.Count = -1
|
|
}
|
|
_ = tcp.SetKeepAliveConfig(config)
|
|
}
|