Added website source code

Fixed .gitignore
This commit is contained in:
Tristan B. Velloza Kildaire 2022-11-22 17:19:07 +02:00
parent 27082c8c18
commit d7af2eefb3
6 changed files with 100 additions and 17 deletions

17
.gitignore vendored
View File

@ -1,17 +0,0 @@
.dub
docs.json
__dummy.html
docs/
/libtun
libtun.so
libtun.dylib
libtun.dll
libtun.a
libtun.lib
libtun-test-*
*.exe
*.o
*.obj
*.lst
dub.json
liblibtun.a

59
docs/api.md Normal file
View File

@ -0,0 +1,59 @@
API
===
This document contains documentation on each user-facing component of the libtun library.
## Creating a new Adapter
Firstly add the following import line to your project:
```d
import libtun.adapter;
```
Now we can spawn a new `TUNAdapter` with the following parameters. This will
create a new interface named `myTun0` and we can choose between creating either
a TUN adapter or a TAP adapter by setting the second argument to one or the other
of:
1. `AdapterType.TUN`
2. `AdapterType.TAP`
```d
TUNAdapter adapter = new TUNAdapter("myTun0", AdapterType.TUN);
```
If one does not specify the second argument then it defaults to TAP mode.
## Using the adapter
This section describes how to use the adapter now that it is setup.
### Receiving from the adapter
One can use the `receive(ref byte[])` method in order to receive a frame/packet
from the adapter. This takes in a pointer to a vriable holding a buffer
(albeit automatically due to pass by `ref`-erence) and will assign a new
buffer to it of the correct size matching the received frame/packet.
Below we will receive a frame/packet:
```d
byte[] frameBuff;
adapter.receive(frameBuff);
```
If the read fails for some reason then a `TUNException` will be thrown.
### Sending via the adapter
One can use the `send(byte[])` method in order to send a frame/packet via
the adapter. All one needs to do is to provide the frame/packet to be sent
as follows:
```d
byte[] myData = [1,2,3,4];
adapter.send(myData);
```

6
docs/index.md Normal file
View File

@ -0,0 +1,6 @@
# libtun
Welcome to the libtun project homepage. Here you will find all information pertaining to the library - how to use it in your projects, API documentation and how you can
contribute!

BIN
docs/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

30
docs/setup.md Normal file
View File

@ -0,0 +1,30 @@
Setting up
==========
Setting up your project to be able to use the libtun library is a very easy process. For this you will need the
D package manager, [`dub`](https://code.dlang.org/), installed. If you had installed the D programming language
via the [`dmd`](https://dlang.org/download.html#dmd) package then dub would already be installed along with it.
### Setting up dub repository
Once that is done, you will want to initialize your current project directory as a dub repository by running the
following and then filling in the queries as you are prompted:
```bash
cd my-project/
dub init
```
### Adding libtun
You can now add the libtun library dependency to your project with one command:
```
dub add libtun
```
Upon your next build (via dub) the package will be fetched, however to force it _now_ just run:
```
dub build
```

5
mkdocs.yml Normal file
View File

@ -0,0 +1,5 @@
site_name: libtun
theme: alabaster
extra:
logo: logo.png