2019-03-18 14:22:02 -07:00
# ZeroTier SDK (libzt, libztcore)
Library edition of [ZeroTier ](https://github.com/zerotier/ZeroTierOne )
2017-06-14 16:58:48 -07:00
***
2017-05-05 18:51:04 -07:00
2019-05-01 14:23:14 -07:00
< a href = "https://www.zerotier.com/" > < img src = "https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/artwork/ZeroTierIcon.png" width = "128" height = "128" align = "left" hspace = "20" vspace = "9" > < / a >
2017-05-05 18:51:04 -07:00
2019-05-01 14:23:14 -07:00
The ZeroTier SDK is composed of two libraries: `libztcore` which is the platform-agnostic network hypervisor, and `libzt` which is the network hypervisor paired with a userspace network stack. `libzt` is a superset of `libztcore` and is distinguished by the fact that it exposes a standard socket API and simple network control API. With these libraries the stack and virtual link are exclusive to your app and traffic is fully encrypted via the [Salsa20 ](https://en.wikipedia.org/wiki/Salsa20 ) cipher. For a more in-depth discussion on the technical side of ZeroTier, check out our [Manual ](https://www.zerotier.com/manual.shtml )
2018-08-22 10:49:21 -07:00
2017-06-14 17:09:18 -07:00
***
2019-03-18 14:22:02 -07:00
< br >
2017-04-20 13:39:46 -07:00
2019-05-15 10:31:16 -07:00
## Downloads / Installation
Tarballs:
- [libzt-release.tar.gz ](https://download.zerotier.com/dist/sdk/libzt-1.3.0-release.tar.gz ) // [libzt-debug.tar.gz ](https://download.zerotier.com/dist/sdk/libzt-1.3.0-debug.tar.gz ) // [libzt-source.tar.gz ](https://download.zerotier.com/dist/sdk/libzt-1.3.0-source.tar.gz )
Homebrew
```
brew install libzt
```
***
< br >
## Example
- Complete example: [test/simple.cpp ](test/simple.cpp )
- Slightly more thorough example: [test/example.cpp ](test/example.cpp )
2017-06-14 17:53:32 -07:00
2019-03-18 14:22:02 -07:00
```
#include "ZeroTier.h"
2017-09-13 16:26:27 -07:00
2019-03-18 14:22:02 -07:00
void myZeroTierEventCallback(struct zts_callback_msg *msg)
2017-10-20 01:25:01 -07:00
{
2019-03-18 14:22:02 -07:00
switch (msg->eventCode)
{
//
}
2017-09-13 16:26:27 -07:00
}
2017-04-20 13:39:46 -07:00
2019-03-18 14:22:02 -07:00
int main()
{
zts_start("yourConfig/key/path", & myZeroTierEventCallback, 9994);
zts_join(0x0123456789abcdef);
zts_socket(ZTS_AF_INET, ZTS_SOCK_STREAM, 0);
zts_connect(fd, (const struct sockaddr *)& addr, sizeof(addr));
2019-03-25 14:09:10 -07:00
zts_write(fd, "welcome to the machine", 22);
2019-03-18 14:22:02 -07:00
zts_close(fd);
zts_stop();
return 0;
}
2017-12-15 16:26:27 -08:00
2019-03-18 14:22:02 -07:00
...
2017-12-15 16:26:27 -08:00
```
2019-05-15 10:31:16 -07:00
After you've created a virtual network and added its `nwid` to the sample code, run:
```
clang++ example.cpp -o example -lzt
./example
```
2019-05-01 14:23:14 -07:00
The complete API specification can be found here: [API.md ](API.md )
2019-03-18 14:22:02 -07:00
***
2018-07-31 17:29:43 -07:00
2019-05-15 10:31:16 -07:00
## Build from source
2018-07-31 17:29:43 -07:00
2019-03-18 14:22:02 -07:00
Build scripts use a combination of make, and cmake. To retrieve sources for all submodules, patch them, and build all targets (debug and release) for your host machine, issue the following:
2018-07-31 17:29:43 -07:00
```
2019-03-18 14:22:02 -07:00
make update
make patch
make all
2018-07-31 17:29:43 -07:00
```
2019-03-18 14:22:02 -07:00
All build targets can be seen by using `make list` .
2018-07-31 17:43:50 -07:00
2019-03-18 14:22:02 -07:00
Resultant libraries will be placed in `lib` , test and example programs will be placed in `bin` .
2017-05-30 13:50:27 -07:00
2017-05-30 12:35:18 -07:00
***
2019-03-18 14:22:02 -07:00
## Commercial License
2017-11-06 13:50:20 -08:00
2019-03-18 14:22:02 -07:00
If you want a commercial license to use the ZeroTier SDK in your product contact us directly via `contact@zerotier.com`
2018-07-19 17:19:06 -07:00