Add requests page Fix checkUpdate dark mode style error Fix quickStart error open app Add memory proxies tab index Support hidden group Optimize logs
43 lines
607 B
Go
43 lines
607 B
Go
//go:build android
|
|
|
|
package platform
|
|
|
|
import "syscall"
|
|
|
|
var nullFd int
|
|
var maxFdCount int
|
|
|
|
func init() {
|
|
fd, err := syscall.Open("/dev/null", syscall.O_WRONLY, 0644)
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
|
|
nullFd = fd
|
|
|
|
var limit syscall.Rlimit
|
|
|
|
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err != nil {
|
|
maxFdCount = 1024
|
|
} else {
|
|
maxFdCount = int(limit.Cur)
|
|
}
|
|
|
|
maxFdCount = maxFdCount / 4 * 3
|
|
}
|
|
|
|
func ShouldBlockConnection() bool {
|
|
fd, err := syscall.Dup(nullFd)
|
|
if err != nil {
|
|
return true
|
|
}
|
|
|
|
_ = syscall.Close(fd)
|
|
|
|
if fd > maxFdCount {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|