I like that this has more features and details than the network-interface crate, but it has problems on Windows.
[package]
name = "testbin"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
netdev = "0.30"
network-interface = "2.0"
tun2 = { version = "3" }
use tun2::{configure, create};
fn main() {
let device = create(configure().tun_name("utun42").up()).unwrap();
for ni in
<network_interface::NetworkInterface as network_interface::NetworkInterfaceConfig>::show()
.unwrap()
{
dbg!(ni.name);
}
for ni in netdev::get_interfaces() {
dbg!(ni.name);
dbg!(ni.friendly_name);
}
drop(device);
}
Running on Linux with cargo b && sudo ./target/debug/testbin gives exactly what I expect,
Besides being inconsistent with the name and friendly_name (it should preferably set friendly_name to the same as name if it doesn't exest, so that I don't have to configure around it), it doesn't show "utun42" on windows.
Also, is it possible to look up an interface by ID (I am currently only looking up by name for workaround reasons) instead of needing to iterate through an array?
I like that this has more features and details than the
network-interface
crate, but it has problems on Windows.Running on Linux with
cargo b && sudo ./target/debug/testbin
gives exactly what I expect,But on Windows (
cargo r
, copy the DLL from https://github.com/tun2proxy/wintun-bindings/tree/master/wintun/bin/amd64 into the /target/debug folder and runcargo r
in a privileged shell), I getBesides being inconsistent with the
name
andfriendly_name
(it should preferably setfriendly_name
to the same asname
if it doesn't exest, so that I don't have to configure around it), it doesn't show "utun42" on windows.