5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-01-11 20:05:40 +00:00
yggdrasil-go/src/core/link_tcp_darwin.go

34 lines
659 B
Go
Raw Normal View History

2021-09-23 09:34:58 +00:00
//go:build darwin
2019-01-13 18:08:41 +00:00
// +build darwin
2021-05-23 19:42:26 +00:00
package core
2019-01-13 18:08:41 +00:00
import (
"syscall"
"golang.org/x/sys/unix"
)
// WARNING: This context is used both by net.Dialer and net.Listen in tcp.go
func (t *linkTCP) 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
}
}
2024-07-20 11:31:58 +00:00
func (t *linkTCP) getControl(_ string) func(string, string, syscall.RawConn) error {
return t.tcpContext
}