libtun/README.md

62 lines
782 B
Markdown
Raw Normal View History

2021-07-18 22:25:59 +01:00
libtun
======
2022-01-12 16:17:45 +00:00
![](branding/logo.png)
2021-07-18 22:25:59 +01:00
TUN/TAP adapter for D-based applications
2021-10-24 18:09:27 +01:00
2021-10-25 14:09:28 +01:00
## Usage
First add it to your dub-based project via:
```
dub add libtun
```
2022-11-28 16:39:50 +00:00
### `Adapter`
2021-10-25 14:09:28 +01:00
2022-11-28 16:39:50 +00:00
The `Adapter` class provides you with all you need to get started. One can construct a new adapter as follows:
2021-10-25 14:09:28 +01:00
```d
import libtun.adapter;
void main()
{
try
{
TUNAdapter tun = new TUNAdapter("interface0", AdapterType.TUN);
}
catch(TUNException)
{
}
}
```
Reading and writing is easy:
```d
byte[] data;
try
{
tun.receive(data);
tun.write([65,66,66,65]);
}
catch(TUNException)
{
}
```
There are two types of adapters:
1. `AdapterType.TUN`
* This is for creating a TUN device
2. `AdapterType.TAP`
* This is for creating a TAP device
2021-10-24 18:09:27 +01:00
## License
2022-01-12 16:17:45 +00:00
LGPLv3