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.
This commit is contained in:
Cuong Manh Le authored and Cuong Manh Le committed 2026-04-30 19:19:18 +07:00
1 parent 627eb23ed6
commit eaa6ccc356
8 files changed
+38 -89

No files matched your search

+1 -1
View File
@@ -1201,7 +1201,7 @@ func (p *prog) monitorNetworkChanges(ctx context.Context) error {
mon.RegisterChangeCallback(func(delta *netmon.ChangeDelta) {
// Get map of valid interfaces
validIfaces := validInterfacesMap()
validIfaces := validInterfacesMap(ctrld.LoggerCtx(ctx, p.logger.Load()))
isMajorChange := mon.IsMajorChangeFrom(delta.Old, delta.New)