Crates.io | mac_utun |
lib.rs | mac_utun |
version | 0.6.0 |
source | src |
created_at | 2017-11-25 08:11:49.006082 |
updated_at | 2019-01-20 08:55:17.031834 |
description | Create utun device for macos |
homepage | https://github.com/gin66/mac_utun |
repository | https://github.com/gin66/mac_utun |
max_upload_size | |
id | 40460 |
size | 6,061 |
Create utun device on macos.
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.
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.
Thanks for pull request from Feng Yingcai