Improve darwin tun performance

This commit is contained in:
世界 2025-07-17 17:33:41 +08:00
parent 7812930a48
commit aa1fd4d994
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
16 changed files with 192 additions and 115 deletions

26
stack_system_unix.go Normal file
View file

@ -0,0 +1,26 @@
//go:build !windows
package tun
import (
"net"
"github.com/sagernet/sing/common/control"
"golang.org/x/sys/unix"
)
func acceptConn(conn net.Conn) error {
return control.Conn(conn.(*net.TCPConn), func(fd uintptr) error {
const bufferSize = 1024 * 1024
oErr := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, bufferSize)
if oErr != nil {
return oErr
}
oErr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, bufferSize)
if oErr != nil {
return oErr
}
return nil
})
}