Skip to content

Conversation

@hanskorg
Copy link

  • unix like os uses interface ifa_flags to map interface types, on windows
    It uses IfType
  • add filter fn
///  This helps people filter interfaces that look like`Ethernet` and are running
NetworkInterface::filter(NetworkInterface::show().unwarp(), IFF_ETH   | IFF_RUNNING)

infra-bot and others added 5 commits November 27, 2025 15:37
- unix like os use interface `ifa_flags` to map interface types, windows
  use `IfType`
- add filter fn:wq
- windows not set flags
- filter  `netif.flags` empty remove
Copy link
Owner

@LeoBorai LeoBorai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR @hanskorg!

Thank you so much! I just have some nitpick comments, I think running cargo fmt should get them fixed (at least most of them).

Other is the DocString suggestion.

Great to have the example indeed!

I think I can draft a release in the next hours if fmt is addressed.

@LeoBorai LeoBorai requested a review from Copilot November 27, 2025 18:32
@LeoBorai LeoBorai changed the title interface can be filtered feat: interface can be filtered and flags Nov 27, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds interface filtering capabilities to the network-interface library, allowing users to filter network interfaces by flags (such as Ethernet, wireless, VPN, etc.). The implementation accounts for platform differences between Unix-like systems (which use ifa_flags) and Windows (which uses IfType).

  • Adds a new filter method to the NetworkInterfaceConfig trait for filtering interfaces by flags
  • Introduces platform-specific flag constants (IFF_ETH, IFF_WIRELESS, IFF_TUN, IFF_LOOPBACK, IFF_RUNNING, IFF_VPN)
  • Adds Status enum and corresponding fields to track interface operational status

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
src/lib.rs Adds filter method to NetworkInterfaceConfig trait with documentation
src/interface.rs Defines Status enum, platform-specific flag constants, and adds status/flags fields to NetworkInterface struct
src/target/windows.rs Implements filter method and helper functions to map Windows IfType to flag constants
src/target/unix/mod.rs Implements filter method and netifa_status function for Unix-like systems
src/target/linux.rs Implements filter method and netifa_status function for Linux
examples/demo.rs Updates example to demonstrate interface filtering
Cargo.toml Removes duplicate keyword and adds demo binary configuration
Comments suppressed due to low confidence (1)

src/interface.rs:1

  • Missing space after comma before flags parameter. Should be ifas: &Vec<NetworkInterface>, flags: i32.
//! Network Interface abstraction from commonly used fields for nodes from the

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@LeoBorai
Copy link
Owner

@hanskorg seems like there is a dmport issue in the example

@LeoBorai
Copy link
Owner

@hanskorg seems like theres an issue with the pipe operator?

@hanskorg hanskorg closed this Dec 1, 2025
@hanskorg
Copy link
Author

hanskorg commented Dec 1, 2025

Windows os impl needs more tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants