Added noop returns for Android GOOS

This commit is contained in:
Samuel Hawksby-Robinson 2023-09-05 09:58:55 +01:00
parent 5824fedaed
commit 1a7414312e
2 changed files with 12 additions and 8 deletions

View File

@ -15,7 +15,7 @@ var (
)
const (
androidPlatform = "android"
AndroidPlatform = "android"
)
func GetOutboundIP() (net.IP, error) {
@ -90,7 +90,9 @@ func getAndroidLocalIP() ([][]net.IP, error) {
// getLocalAddresses returns an array of all addresses
// of all available network interfaces.
func getLocalAddresses() ([][]net.IP, error) {
if runtime.GOOS == androidPlatform {
// TODO until we can resolve Android errors when calling net.Interfaces() just return the outbound local address.
// Sorry Android
if runtime.GOOS == AndroidPlatform {
return getAndroidLocalIP()
}
@ -183,12 +185,9 @@ func getAllAvailableNetworks() ([]net.IPNet, error) {
// FindReachableAddressesForPairingClient is a high-level func
// that returns a reachable server's address to be used by local pairing client.
func FindReachableAddressesForPairingClient(serverIps []net.IP) ([]net.IP, error) {
if runtime.GOOS == androidPlatform {
ips, err := getAndroidLocalIP()
if err != nil {
return nil, err
}
return filterAddressesForPairingServer(ips), nil
// TODO until we can resolve Android errors when calling net.Interfaces() just noop. Sorry Android
if runtime.GOOS == AndroidPlatform {
return serverIps, nil
}
nets, err := getAllAvailableNetworks()

View File

@ -43,6 +43,11 @@ func (p *PeerNotifier) handler(hello *peers.LocalPairingPeerHello) {
}
func (p *PeerNotifier) Search() error {
// TODO until we can resolve Android errors when calling net.Interfaces() just noop. Sorry Android
if runtime.GOOS == server.AndroidPlatform {
return nil
}
dn, err := server.GetDeviceName()
if err != nil {
return err