Files
ctrld/cmd/cli/net_windows.go
Cuong Manh Le 59ece456b1 refactor: improve network interface validation
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.
2025-10-09 17:49:21 +07:00

29 lines
686 B
Go

package cli
import (
"context"
"net"
"github.com/Control-D-Inc/ctrld"
)
func patchNetIfaceName(iface *net.Interface) (bool, error) {
return true, nil
}
// validInterface reports whether the *net.Interface is a valid one.
// On Windows, only physical interfaces are considered valid.
func validInterface(iface *net.Interface, validIfacesMap map[string]struct{}) bool {
_, ok := validIfacesMap[iface.Name]
return ok
}
// validInterfacesMap returns a set of all physical interfaces.
func validInterfacesMap(ctx context.Context) map[string]struct{} {
m := make(map[string]struct{})
for ifaceName := range ctrld.ValidInterfaces(ctx) {
m[ifaceName] = struct{}{}
}
return m
}