5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-02 02:21:59 +00:00
yggdrasil-go/src/yggdrasil/tcp_linux.go

29 lines
526 B
Go
Raw Normal View History

// +build linux
package yggdrasil
import (
"syscall"
"golang.org/x/sys/unix"
)
// WARNING: This context is used both by net.Dialer and net.Listen in tcp.go
func (t *tcp) tcpContext(network, address string, c syscall.RawConn) error {
var control error
var bbr error
control = c.Control(func(fd uintptr) {
// sys/socket.h: #define SO_RECV_ANYIF 0x1104
bbr = unix.SetsockoptString(int(fd), unix.IPPROTO_TCP, unix.TCP_CONGESTION, "bbr")
})
switch {
case bbr != nil:
return bbr
default:
return control
}
}