-
Notifications
You must be signed in to change notification settings - Fork 38
feat: interface can be filtered and flags #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- unix like os use interface `ifa_flags` to map interface types, windows use `IfType` - add filter fn:wq
LeoBorai
left a comment
There was a problem hiding this 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.
There was a problem hiding this 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
filtermethod to theNetworkInterfaceConfigtrait for filtering interfaces by flags - Introduces platform-specific flag constants (IFF_ETH, IFF_WIRELESS, IFF_TUN, IFF_LOOPBACK, IFF_RUNNING, IFF_VPN)
- Adds
Statusenum 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
flagsparameter. Should beifas: &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.
- format code by running `cargo fmt` - add some comments for constants
- format code by running `cargo fmt` - add some comments for constants
|
@hanskorg seems like there is a dmport issue in the example |
|
@hanskorg seems like theres an issue with the pipe operator? |
|
Windows os impl needs more tests |
ifa_flagsto map interface types, on windowsIt uses
IfType