meh / rust-tun

TUN device creation and handling.
343 stars 136 forks source link

fix macos utun name #7

Closed LuoZijun closed 3 years ago

LuoZijun commented 6 years ago

Current, when we create a tun device with name utun10 on macos, the ifconfig will display utun9 .

so this patch will fix this problem.

LuoZijun commented 6 years ago

@meh ping ...

meh commented 6 years ago

Is the index in both cases supposed to be + 1? I remember there being some edge case when I was testing this stuff.

LuoZijun commented 6 years ago

@meh XNU source code https://github.com/apple/darwin-xnu/blob/master/bsd/net/if_utun.c#L1426-L1428

eycorsican commented 3 years ago

@meh

I think +1 is the general way to due with this issue: https://github.com/WireGuard/wireguard-go/blob/58a8f05f50b633bb45c7cc299c405618489c18ad/tun/tun_darwin.go#L156