mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2025-01-11 07:15:42 +00:00
5ef61faeff
* Link refactoring * More refactoring * More tweaking * Cleaner shutdowns, UNIX socket support, more tweaks * Actorise links, remove mutex * SOCKS support
34 lines
663 B
Go
34 lines
663 B
Go
//go:build darwin
|
|
// +build darwin
|
|
|
|
package core
|
|
|
|
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 {
|
|
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
|
|
}
|
|
}
|
|
|
|
func (t *linkTCP) getControl(sintf string) func(string, string, syscall.RawConn) error {
|
|
return t.tcpContext
|
|
}
|