AWDL support for macOS/iOS

This commit is contained in:
Neil Alexander 2019-01-13 18:08:41 +00:00
parent 4f7e8856b8
commit 4622a85c34
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
6 changed files with 90 additions and 3 deletions

View file

@ -15,6 +15,7 @@ package yggdrasil
// See version.go for version metadata format
import (
"context"
"errors"
"fmt"
"io"
@ -88,7 +89,11 @@ func (iface *tcpInterface) init(core *Core, addr string, readTimeout int32) (err
iface.tcp_timeout = default_tcp_timeout
}
iface.serv, err = net.Listen("tcp", addr)
ctx := context.Background()
lc := net.ListenConfig{
Control: iface.tcpContext,
}
iface.serv, err = lc.Listen(ctx, "tcp", addr)
if err == nil {
iface.calls = make(map[string]struct{})
iface.conns = make(map[tcpInfo](chan struct{}))
@ -164,7 +169,9 @@ func (iface *tcpInterface) call(saddr string, socksaddr *string, sintf string) {
},
}
} else {
dialer := net.Dialer{}
dialer := net.Dialer{
Control: iface.tcpContext,
}
if sintf != "" {
ief, err := net.InterfaceByName(sintf)
if err != nil {