2016-12-08 16:21:06 -08:00
Walkthrough
======
2016-12-09 09:45:57 -08:00
In this document we'll run through a simple example which should demonstrate the concept of the ZeroTier SDK. For this tutorial you'll need two devices (or at least the ability to run a VM or something like [Docker ](https://www.docker.com/ )). We will demonstrate a simple TCP server application intercepted on linux. This is only one of *many* ways the SDK can be used, but it'll at least convey the core concept how how the intercept works.
2016-12-08 16:21:06 -08:00
2016-12-09 09:45:57 -08:00
### On your first device:
- Download ZeroTier at [zerotier.com ](https://www.zerotier.com/product-one.shtml )
2016-12-08 16:21:06 -08:00
- Install it on a device/computer
2016-12-09 09:45:57 -08:00
- Create an account and new virtual network at [my.zerotier.com ](https://my.zerotier.com/ )
2016-12-08 16:21:06 -08:00
- Join your device to the network and assign it an address `zerotier-cli join <nwid>`
- Use `zerotier-cli listnetworks` to verify that you've joined the network.
2016-12-09 09:45:57 -08:00
***
2016-12-08 16:21:06 -08:00
2016-12-09 09:45:57 -08:00
### On your second device:
#### Build the SDK
```
make linux SDK_PICOTCP=1 SDK_IPV4=1 SDK_DEBUG=1; make -s check; ls -lG build
```
#### Build test apps
2016-12-08 16:21:06 -08:00
```
make tests
```
2016-12-09 09:45:57 -08:00
#### Start the SDK service in the background
2016-12-08 16:21:06 -08:00
```
2016-12-09 09:45:57 -08:00
./zerotier-cli -U -p8000 /netpath &
2016-12-08 16:21:06 -08:00
```
2016-12-09 09:45:57 -08:00
#### Set environment variables
2016-12-08 16:21:06 -08:00
```
2016-12-09 09:45:57 -08:00
export ZT_NC_NETWORK=/netpath/nc_XXXXXXXXXXXXXXXX
2016-12-08 16:21:06 -08:00
export LD_PRELOAD=./libztintercept.so
```
2016-12-09 09:45:57 -08:00
Where `netpath` can be any path you'd like the client's keys and configuration to be stored and `XXXXXXXXXXXXXXXX` is the 16-digit network ID.
#### Start your app
2016-12-08 16:21:06 -08:00
```
./build/tests/linux.tcpserver4.out 8001
```
2016-12-09 09:45:57 -08:00
Now, on your first device, `./build/tests/linux.tcpclient4.out <ip> 8001`
Now, you'll note that your new TCP server is automatically intercepted and available at on port 8001.
***
You've just uplifted your app onto your private ZeroTier network.