mirror of
https://github.com/slackhq/nebula.git
synced 2026-08-15 08:36:57 +02:00
8cbee0e965
On Android 11+ the app sandbox denies bind() on netlink_route_socket, so the stdlib's net.Interfaces fails with EACCES. localAddrs discarded that error and returned an empty slice, so the node advertised no underlay addresses and peers could only ever reach it at the address a lighthouse observed. A device on the same LAN as a peer was unreachable at its LAN address. Split interface enumeration behind a build-tagged seam and use github.com/wlynxg/anet on Android, which reads RTM_GETADDR from an unbound socket. Interface addresses have to come from anet as well, since net.Interface.Addrs goes back through the same denied path. Every other platform keeps the net package implementation. Stop discarding the enumeration errors, which are exceptional now that the sandbox case is handled. anet needs -ldflags=-checklinkname=0 on Go 1.23+. Nebula ships no Android binaries, so build-test-mobile is unaffected, but consumers linking Android artifacts will need the flag.
14 lines
214 B
Go
14 lines
214 B
Go
//go:build !android
|
|
|
|
package nebula
|
|
|
|
import "net"
|
|
|
|
func localInterfaces() ([]net.Interface, error) {
|
|
return net.Interfaces()
|
|
}
|
|
|
|
func localInterfaceAddrs(i *net.Interface) ([]net.Addr, error) {
|
|
return i.Addrs()
|
|
}
|