mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-02-13 18:31:51 +00:00
Merge pull request #377 from neilalexander/awdl-fixes
AWDL fixes for macOS
This commit is contained in:
commit
c48cbfa78b
5 changed files with 38 additions and 16 deletions
|
@ -57,7 +57,7 @@ func (m *multicast) start() error {
|
||||||
// Windows can't set this flag, so we need to handle it in other ways
|
// Windows can't set this flag, so we need to handle it in other ways
|
||||||
}
|
}
|
||||||
|
|
||||||
m.multicastWake()
|
go m.multicastStarted()
|
||||||
go m.listen()
|
go m.listen()
|
||||||
go m.announce()
|
go m.announce()
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,25 +6,47 @@ package yggdrasil
|
||||||
#cgo CFLAGS: -x objective-c
|
#cgo CFLAGS: -x objective-c
|
||||||
#cgo LDFLAGS: -framework Foundation
|
#cgo LDFLAGS: -framework Foundation
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
void WakeUpAWDL() {
|
NSNetServiceBrowser *serviceBrowser;
|
||||||
NSNetServiceBrowser *serviceBrowser;
|
void StartAWDLBrowsing() {
|
||||||
|
if (serviceBrowser == nil) {
|
||||||
serviceBrowser = [[NSNetServiceBrowser alloc] init];
|
serviceBrowser = [[NSNetServiceBrowser alloc] init];
|
||||||
serviceBrowser.includesPeerToPeer = YES;
|
serviceBrowser.includesPeerToPeer = YES;
|
||||||
|
}
|
||||||
[serviceBrowser searchForServicesOfType:@"_yggdrasil._tcp" inDomain:@""];
|
[serviceBrowser searchForServicesOfType:@"_yggdrasil._tcp" inDomain:@""];
|
||||||
}
|
}
|
||||||
|
void StopAWDLBrowsing() {
|
||||||
|
if (serviceBrowser == nil) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[serviceBrowser stop];
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import "syscall"
|
import (
|
||||||
import "golang.org/x/sys/unix"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
func (m *multicast) multicastWake() {
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
var awdlGoroutineStarted bool
|
||||||
|
|
||||||
|
func (m *multicast) multicastStarted() {
|
||||||
|
if awdlGoroutineStarted {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.core.log.Infoln("Multicast discovery will wake up AWDL if required")
|
||||||
|
awdlGoroutineStarted = true
|
||||||
|
for {
|
||||||
|
C.StopAWDLBrowsing()
|
||||||
for _, intf := range m.interfaces() {
|
for _, intf := range m.interfaces() {
|
||||||
if intf.Name == "awdl0" {
|
if intf.Name == "awdl0" {
|
||||||
m.core.log.Infoln("Multicast discovery is waking up AWDL")
|
C.StartAWDLBrowsing()
|
||||||
C.WakeUpAWDL()
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
time.Sleep(time.Minute)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *multicast) multicastReuse(network string, address string, c syscall.RawConn) error {
|
func (m *multicast) multicastReuse(network string, address string, c syscall.RawConn) error {
|
||||||
|
|
|
@ -4,7 +4,7 @@ package yggdrasil
|
||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
||||||
func (m *multicast) multicastWake() {
|
func (m *multicast) multicastStarted() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ package yggdrasil
|
||||||
import "syscall"
|
import "syscall"
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
func (m *multicast) multicastWake() {
|
func (m *multicast) multicastStarted() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ package yggdrasil
|
||||||
import "syscall"
|
import "syscall"
|
||||||
import "golang.org/x/sys/windows"
|
import "golang.org/x/sys/windows"
|
||||||
|
|
||||||
func (m *multicast) multicastWake() {
|
func (m *multicast) multicastStarted() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue