9 releases (5 breaking)

0.6.0 Jan 20, 2019
0.5.2 Dec 4, 2017
0.5.0 Nov 26, 2017
0.4.0 Nov 25, 2017
0.1.1 Nov 25, 2017

#143 in macOS and iOS APIs

Download history 1/week @ 2023-11-06 2/week @ 2023-11-13 19/week @ 2023-11-20 29/week @ 2023-11-27 9/week @ 2023-12-11 19/week @ 2023-12-25 9/week @ 2024-01-01 1/week @ 2024-01-08 11/week @ 2024-01-15 7/week @ 2024-01-22 18/week @ 2024-01-29 1/week @ 2024-02-05 32/week @ 2024-02-12 200/week @ 2024-02-19

251 downloads per month

MIT license

5KB
89 lines

mac_utun

Create utun device on macos.

Usage

In Cargo.toml include:

mac_utun = "0.6"

Import the get_utun function:

use mac_utun::get_utun;

Just need to call this function. It will search for the first available utun-device starting from 0. As you may know, root permission is necessary to create a utun-device.

pub fn get_utun() -> Result<(UdpSocket,String)>

In case of error, the last OS-Error will be returned. In case of success, an UDP-socket and the interface name (e.g. "utun0") will be returned.

UDP-socket is a nice choice, because rust will perform the necessary clean up itself.

Test

There is only one test case defined:

It checks the list of network interfaces before, during and after utun is opened. Expected behaviour: The returned utun is only in the list during utun is opened.

Contributions

Thanks for pull request from Feng Yingcai

No runtime deps

~175KB