mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 12:42:27 +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)
|
|
}
|
|
}
|
|
}
|