Skip to content

Created network interfaces aren't in get_interfaces on Windows #87

@AaronKutch

Description

@AaronKutch

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,

[src/main.rs:10:9] ni.name = "eth0"
[src/main.rs:10:9] ni.name = "utun42"
[src/main.rs:10:9] ni.name = "lo"
[src/main.rs:13:9] ni.name = "lo"
[src/main.rs:14:9] ni.friendly_name = None
[src/main.rs:13:9] ni.name = "eth0"
[src/main.rs:14:9] ni.friendly_name = None
[src/main.rs:13:9] ni.name = "utun42"
[src/main.rs:14:9] ni.friendly_name = None

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 run cargo r in a privileged shell), I get

[src/main.rs:10:9] ni.name = "utun42"
[src/main.rs:10:9] ni.name = "Ethernet 2"
...
[src/main.rs:13:9] ni.name = "{E5A5F923-716B-487F-B647-0523E95CE909}"
[src/main.rs:14:9] ni.friendly_name = Some(
    "Ethernet 2",
)
...

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions