Improve darwin tun performance
This commit is contained in:
parent
7812930a48
commit
aa1fd4d994
16 changed files with 192 additions and 115 deletions
26
stack_system_unix.go
Normal file
26
stack_system_unix.go
Normal 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
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue