mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 18:06:52 +01:00
Enumerate Android interfaces without anet
anet's only reason to need -ldflags=-checklinkname=0 is a pair of //go:linkname pulls that refresh the IPv6 zone caches inside net and x/net after it enumerates interfaces. localAddrs never resolves a zone and drops link-local addresses anyway, so nebula was paying for that flag, and disabling the linker's check for the whole binary, for nothing it used. Replace the dependency with the part of anet that matters: an RTM_GETADDR dump on a netlink socket that is never bound, and SIOCGIFNAME to name each index. Both are permitted to Android apps, and it is the same path Bionic's getifaddrs takes for app UIDs. It is built only for android; every other platform, Linux included, keeps net.Interfaces. One dump yields every interface with its addresses, so reshape the seam to a single enumerator returning localInterface values with a deferred Addrs. Android hands back what it already has; every other platform still only asks for the addresses of interfaces the allow list accepts. Take the bind-free path unconditionally on android. The sepolicy is keyed to the app's target SDK rather than the OS release, detecting either needs cgo, and the path is valid on every release. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B15ivF2aJUtLFdqJ4iz6zs
This commit is contained in:
1 parent
8589b76e1f
commit
fcc6008a78
7 files changed
+250
-49
No files matched your search
+10
-5
@@ -4,10 +4,15 @@ package nebula
|
||||
|
||||
import "net"
|
||||
|
||||
func localInterfaces() ([]net.Interface, error) {
|
||||
return net.Interfaces()
|
||||
}
|
||||
func localInterfaces() ([]localInterface, error) {
|
||||
ifaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func localInterfaceAddrs(i *net.Interface) ([]net.Addr, error) {
|
||||
return i.Addrs()
|
||||
out := make([]localInterface, len(ifaces))
|
||||
for n, i := range ifaces {
|
||||
out[n] = localInterface{Name: i.Name, Addrs: i.Addrs}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
Reference in new issue
Block a user