8 releases (4 breaking)
Uses old Rust 2015
0.5.1 | Sep 12, 2018 |
---|---|
0.5.0 | Sep 12, 2018 |
0.4.0 | Apr 19, 2018 |
0.3.1 | Jan 3, 2017 |
0.1.0 | Nov 30, 2016 |
#11 in #usage
Used in netinfo-ffi
57KB
864 lines
Netinfo
Netinfo is a Rust library and command line application that groups network usage by process. It works in a nethogs-like way, so you don't need a special kernel module.
In comparison to nethogs, it also supports UDP connections.
Because it heavily uses the /proc
-filesystem, only Linux is supported at the moment.
How to use the library
Add this to your Cargo.toml
:
[dependencies]
netinfo = 0.5.1
How to compile the binary
Install Rust and Cargo, then call:
# This will create the binary `~/.cargo/bin/netinfo`
$ cargo install netinfo
Running binaries
To avoid Permission denied
errors, you will either have to run the progam as root or allow the program to capture the network traffic:
sudo setcap cap_net_raw,cap_net_admin=eip /path/to/your/bin
lib.rs
:
This crate will group network usage per process. It uses a method similar to nethogs
:
All packets will be captured and their source/destination address are then used to
match them to a process.
This matching process relies on the /proc
file system, so it only works on Linux.
Because capturing the network traffic is not permittet for normal programs, you either have to run your binary as root or allow capturing with:
sudo setcap cap_net_raw,cap_net_admin=eip /path/to/your/bin
Dependencies
~3.5–5MB
~102K SLoC