refactor(beacon, osutil, upnp, netutil): only use anet on Android (#10211)

Add a wrapper that uses anet on Android, but net on other platforms.

### Purpose

Fixes
https://forum.syncthing.net/t/workaround-for-android-local-discovery/20403/12

### Testing

Run two Syncthing instances with Global Discovery disabled. Pair them
with each other, don't hardcode their addresses, and verify they
connect.
This commit is contained in:
Marcus B Spencer
2025-07-08 08:18:51 +02:00
committed by GitHub
parent e8cfc8acfb
commit 32a913c0ff
7 changed files with 55 additions and 15 deletions
+3 -3
View File
@@ -10,13 +10,13 @@ import (
"net"
"strings"
"github.com/wlynxg/anet"
"github.com/syncthing/syncthing/lib/netutil"
)
// GetInterfaceAddrs returns the IP networks of all interfaces that are up.
// Point-to-point interfaces are exluded unless includePtP is true.
func GetInterfaceAddrs(includePtP bool) ([]*net.IPNet, error) {
intfs, err := anet.Interfaces()
intfs, err := netutil.Interfaces()
if err != nil {
return nil, err
}
@@ -33,7 +33,7 @@ func GetInterfaceAddrs(includePtP bool) ([]*net.IPNet, error) {
// which, for our purposes, do not qualify as LANs.
continue
}
intfAddrs, err := anet.InterfaceAddrsByInterface(&intf)
intfAddrs, err := netutil.InterfaceAddrsByInterface(&intf)
if err != nil {
return nil, err
}