mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-12 12:02:17 +08:00
24 lines
356 B
Go
24 lines
356 B
Go
package net
|
|
|
|
import (
|
|
"net"
|
|
"runtime"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
KeepAliveIdle = 0 * time.Second
|
|
KeepAliveInterval = 0 * time.Second
|
|
DisableKeepAlive = false
|
|
)
|
|
|
|
func TCPKeepAlive(c net.Conn) {
|
|
if tcp, ok := c.(*net.TCPConn); ok {
|
|
if runtime.GOOS == "android" || DisableKeepAlive {
|
|
_ = tcp.SetKeepAlive(false)
|
|
} else {
|
|
tcpKeepAlive(tcp)
|
|
}
|
|
}
|
|
}
|