Add openvpn and openconnect

This commit is contained in:
世界
2026-08-30 17:41:43 +08:00
parent 23ca3b415f
commit 2df7a9bac7
65 changed files with 12495 additions and 386 deletions
+28
View File
@@ -0,0 +1,28 @@
package openvpn
import (
"syscall"
"github.com/sagernet/sing/common"
"golang.org/x/sys/unix"
)
const openVPNUDPSocketBufferSize = 7 << 20
func tuneOpenVPNUDPSocket(connection any) {
syscallConnection, loaded := common.Cast[syscall.Conn](connection)
if !loaded {
return
}
rawConnection, err := syscallConnection.SyscallConn()
if err != nil {
return
}
_ = rawConnection.Control(func(fd uintptr) {
_ = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUF, openVPNUDPSocketBufferSize)
_ = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUF, openVPNUDPSocketBufferSize)
_ = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_RCVBUFFORCE, openVPNUDPSocketBufferSize)
_ = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_SNDBUFFORCE, openVPNUDPSocketBufferSize)
})
}