//go:build android package main import ( "net" "tailscale.com/net/netmon" ) func init() { // Register an alternate interface getter for Android. // Go's net.Interfaces() uses netlink which requires CAP_NET_ADMIN, // and /sys/class/net is restricted on modern Android. // Provide a minimal loopback interface to satisfy tsnet's startup. // tsnet uses userspace netstack and doesn't need real interface data. netmon.RegisterInterfaceGetter(func() ([]netmon.Interface, error) { return []netmon.Interface{ { Interface: &net.Interface{ Index: 1, MTU: 65536, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback | net.FlagRunning, }, }, { Interface: &net.Interface{ Index: 2, MTU: 1500, Name: "wlan0", HardwareAddr: net.HardwareAddr{0x02, 0x00, 0x00, 0x00, 0x00, 0x01}, Flags: net.FlagUp | net.FlagRunning | net.FlagMulticast, }, }, }, nil }) }