mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
Add context parameter to validInterfacesMap for better error handling and logging. Move Windows-specific network adapter validation logic to the ctrld package. Key changes include: - Add context parameter to validInterfacesMap across all platforms - Move Windows validInterfaces to ctrld.ValidInterfaces - Improve error handling for virtual interface detection on Linux - Update all callers to pass appropriate context This change improves error reporting and makes the interface validation code more maintainable across different platforms.
24 lines
579 B
Go
24 lines
579 B
Go
//go:build !darwin && !windows && !linux
|
|
|
|
package cli
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"tailscale.com/net/netmon"
|
|
)
|
|
|
|
func patchNetIfaceName(iface *net.Interface) (bool, error) { return true, nil }
|
|
|
|
func validInterface(iface *net.Interface, validIfacesMap map[string]struct{}) bool { return true }
|
|
|
|
// validInterfacesMap returns a set containing only default route interfaces.
|
|
func validInterfacesMap(ctx context.Context) map[string]struct{} {
|
|
defaultRoute, err := netmon.DefaultRoute()
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return map[string]struct{}{defaultRoute.InterfaceName: {}}
|
|
}
|