https://github.com/gin66/mac_utun
Create macOS utun device from rust
https://github.com/gin66/mac_utun
Last synced: about 1 year ago
JSON representation
Create macOS utun device from rust
- Host: GitHub
- URL: https://github.com/gin66/mac_utun
- Owner: gin66
- License: mit
- Created: 2017-11-25T08:01:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-20T08:53:17.000Z (over 7 years ago)
- Last Synced: 2025-03-18T13:16:05.848Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 23
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mac_utun
Create utun device on macos.
## Usage
In Cargo.toml include:
```
mac_utun = "0.6"
```
Import the get_utun function:
``` Rust
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.
``` Rust
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](https://github.com/fengyc)