From 8fab9b2217792141d7cb01ce4b80ce39988e4f1f Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 25 Oct 2021 15:09:28 +0200 Subject: [PATCH] Added some API notes --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 1cce8f7..e538108 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,57 @@ libtun TUN/TAP adapter for D-based applications +## Usage + +First add it to your dub-based project via: + +``` +dub add libtun +``` + +### `TUNAdapter` + +The `TUNAdapter` class provides you with all you need to get started. One can construct a new adapter as follows: + +```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 + ## License LGPLv3 \ No newline at end of file