2019-01-13 18:08:41 +00:00
|
|
|
// +build darwin
|
|
|
|
|
|
|
|
package yggdrasil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
// WARNING: This context is used both by net.Dialer and net.Listen in tcp.go
|
|
|
|
|
2019-03-04 17:52:57 +00:00
|
|
|
func (t *tcp) tcpContext(network, address string, c syscall.RawConn) error {
|
2019-01-13 18:08:41 +00:00
|
|
|
var control error
|
|
|
|
var recvanyif error
|
|
|
|
|
|
|
|
control = c.Control(func(fd uintptr) {
|
|
|
|
// sys/socket.h: #define SO_RECV_ANYIF 0x1104
|
|
|
|
recvanyif = unix.SetsockoptInt(int(fd), syscall.SOL_SOCKET, 0x1104, 1)
|
|
|
|
})
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case recvanyif != nil:
|
|
|
|
return recvanyif
|
|
|
|
default:
|
|
|
|
return control
|
|
|
|
}
|
|
|
|
}
|