mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-16 13:17:19 +02:00
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
This commit is contained in:
committed by
Cuong Manh Le
parent
f24059885f
commit
650e47a504
+7
-4
@@ -2,11 +2,14 @@
|
||||
|
||||
package ctrld
|
||||
|
||||
import "tailscale.com/net/netmon"
|
||||
import (
|
||||
"context"
|
||||
|
||||
// validInterfaces returns a set containing only default route interfaces.
|
||||
// TODO: deuplicated with cmd/cli/net_others.go in v2.
|
||||
func validInterfaces() map[string]struct{} {
|
||||
"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
|
||||
|
||||
Reference in New Issue
Block a user