Files
ctrld/net_others.go
Cuong Manh Le fb807d7c37 refactor: consolidate network interface detection logic
Move platform-specific network interface detection from cmd/cli/ to root package
as ValidInterfaces function. This eliminates code duplication and provides a
consistent interface for determining valid physical network interfaces across
all platforms.

- Remove duplicate validInterfacesMap functions from platform-specific files
- Add context parameter to virtualInterfaces for proper logging
- Update all callers to use ctrld.ValidInterfaces instead of local functions
- Improve error handling in virtual interface detection on Linux
2025-10-09 19:12:06 +07:00

19 lines
385 B
Go

//go:build !darwin && !windows && !linux
package ctrld
import (
"context"
"tailscale.com/net/netmon"
)
// ValidInterfaces returns a set containing only default route interfaces.
func ValidInterfaces(_ context.Context) map[string]struct{} {
defaultRoute, err := netmon.DefaultRoute()
if err != nil {
return nil
}
return map[string]struct{}{defaultRoute.InterfaceName: {}}
}