Updated documentation
This commit is contained in:
4
API.md
4
API.md
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<a href="https://www.zerotier.com/?pk_campaign=github_libzt"><img src="https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/artwork/ZeroTierIcon.png" width="128" height="128" align="left" hspace="20"></a>
|
<a href="https://www.zerotier.com/?pk_campaign=github_libzt"><img src="https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/artwork/ZeroTierIcon.png" width="128" height="128" align="left" hspace="20"></a>
|
||||||
|
|
||||||
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](https://en.wikipedia.org/wiki/Berkeley_sockets) and simple network control API. The full source for these products can be found at [github.com/zerotier/libzt](https://github.com/zerotier/libzt) for the SDK and [github.com/zerotier/ZeroTierOne](https://github.com/zerotier/ZeroTierOne) for the desktop client. With these libraries the stack and virtual link is 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?pk_campaign=github_libzt)
|
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](https://en.wikipedia.org/wiki/Berkeley_sockets) and simple network control API. The full source for these products can be found at [github.com/zerotier/libzt](https://github.com/zerotier/libzt) for the SDK and [github.com/zerotier/ZeroTierOne](https://github.com/zerotier/ZeroTierOne) for the desktop client. 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?pk_campaign=github_libzt)
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ int main()
|
|||||||
addr.sin_addr.s_addr = inet_addr(remoteIp);
|
addr.sin_addr.s_addr = inet_addr(remoteIp);
|
||||||
addr.sin_port = htons(remotePort);
|
addr.sin_port = htons(remotePort);
|
||||||
|
|
||||||
// Set up ZeroTier service and wai for callbacks
|
// Set up ZeroTier service and wait for callbacks
|
||||||
int port = 9994;
|
int port = 9994;
|
||||||
int nwid = 0x0123456789abcdef;
|
int nwid = 0x0123456789abcdef;
|
||||||
zts_start("test/path", &myZeroTierEventCallback, port);
|
zts_start("test/path", &myZeroTierEventCallback, port);
|
||||||
|
|||||||
95
README.md
95
README.md
@@ -1,97 +1,62 @@
|
|||||||
# libzt
|
# ZeroTier SDK (libzt, libztcore)
|
||||||
Library version of [ZeroTier](https://github.com/zerotier/ZeroTierOne)
|
Library edition of [ZeroTier](https://github.com/zerotier/ZeroTierOne)
|
||||||
***
|
***
|
||||||
|
|
||||||
<a href="https://www.zerotier.com/?pk_campaign=github_libzt"><img src="https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/artwork/ZeroTierIcon.png" width="128" height="128" align="left" hspace="20" vspace="9"></a>
|
<a href="https://www.zerotier.com/?pk_campaign=github_libzt"><img src="https://raw.githubusercontent.com/zerotier/ZeroTierOne/master/artwork/ZeroTierIcon.png" width="128" height="128" align="left" hspace="20" vspace="9"></a>
|
||||||
|
|
||||||
**libzt** makes it easy to securely connect devices, servers, cloud VMs, containers, and apps everywhere and manage them at scale. We provide a socket-like API supporting `SOCK_STREAM`, `SOCK_DGRAM`, and `SOCK_RAW`. There's no need for system-wide virtual interfaces. This connection is exclusive to your app and 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?pk_campaign=github_libzt)
|
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](https://en.wikipedia.org/wiki/Berkeley_sockets) 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?pk_campaign=github_libzt)
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
[](https://webchat.freenode.net/?channels=zerotier)
|
|
||||||
|
|
||||||
| Platform | Static | Shared | Package | Example project/code | Library build instructions
|
|
||||||
| --------- | --- | --- | --- | --- | --- |
|
|
||||||
| macOS | [libzt.a](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/macos/libzt-1.2.0r1-macOS-10.13.6-x64-release.a) | [libzt.dylib](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/macos/libzt-1.2.0r1-macOS-10.13.6-x64-release.dylib) | | | see below |
|
|
||||||
| iOS | [libzt.a](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/ios/libzt-1.2.0r1-ios-arm64-static-release.tar.tar.gz) | | [zt.framework](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/ios/libzt-1.2.0r1-ios-arm64-framework.tar.gz) | [examples/swift](examples/swift) | [packages/iOS](packages/iOS) |
|
|
||||||
| Windows | [libzt.lib](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/win/libzt-1.2.0r1-win10-x86-release.lib) (x86), [libzt.lib](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/win/libzt-1.2.0r1-win10-x64-release.lib) (x64) | [libzt.dll](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/win/libzt-1.2.0r1-win10-x86-release.dll) (x86), [libzt.dll](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/win/libzt-1.2.0r1-win10-x64-release.dll) (x64) | | [examples/cpp/ExampleWindowsCppApp](examples/cpp/ExampleWindowsCppApp), [examples/csharp/ExampleWindowsCSharpApp](examples/csharp/ExampleWindowsCSharpApp) | see below |
|
|
||||||
| Android | | | [libzt.aar](https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/android/libzt-1.2.0r1-android-armeabi-v7a.aar) | [examples/android/ExampleAndroidApp](examples/android/ExampleAndroidApp) | [packages/android](packages/android)|
|
|
||||||
| Linux | see below | see below | | | see below |
|
|
||||||
|
|
||||||
C API: [libzt.h](include/libzt.h)
|
|
||||||
Java JNI API: [ZeroTier.java](packages/android/app/src/main/java/ZeroTier.java)
|
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### C++ Example
|
<br>
|
||||||
|
|
||||||
|
For a complete example, see [test/simple.cpp](test/simple.cpp), and anything in the [examples](examples) directory. With no error checking, a paraphrased example is as follows:
|
||||||
|
|
||||||
```
|
```
|
||||||
#include <sys/socket.h>
|
#include "ZeroTier.h"
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
|
|
||||||
#include "libzt.h"
|
void myZeroTierEventCallback(struct zts_callback_msg *msg)
|
||||||
|
{
|
||||||
|
switch (msg->eventCode)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
char *str = "welcome to the machine";
|
zts_start("yourConfig/key/path", &myZeroTierEventCallback, 9994);
|
||||||
char *remoteIp = "10.8.8.42";
|
zts_join(0x0123456789abcdef);
|
||||||
int remotePort = 8080;
|
zts_socket(ZTS_AF_INET, ZTS_SOCK_STREAM, 0);
|
||||||
int fd, err = 0;
|
zts_connect(fd, (const struct sockaddr *)&addr, sizeof(addr));
|
||||||
struct sockaddr_in addr;
|
zts_write(fd, "welcome to the machine", strlen(str));
|
||||||
addr.sin_family = AF_INET;
|
|
||||||
addr.sin_addr.s_addr = inet_addr(remoteIp);
|
|
||||||
addr.sin_port = htons(remotePort);
|
|
||||||
|
|
||||||
zts_startjoin("path", 0xc7cd7c981b0f52a2); // config path, network ID
|
|
||||||
|
|
||||||
if ((fd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
|
||||||
printf("error creating socket\n");
|
|
||||||
}
|
|
||||||
if ((err = zts_connect(fd, (const struct sockaddr *)&addr, sizeof(addr))) < 0) {
|
|
||||||
printf("error connecting to remote host\n");
|
|
||||||
}
|
|
||||||
if ((err = zts_write(fd, str, strlen(str))) < 0) {
|
|
||||||
printf("error writing to socket\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
zts_close(fd);
|
zts_close(fd);
|
||||||
zts_stop();
|
zts_stop();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
|
||||||
|
|
||||||
For an example using only the [Virtual Layer 2](https://www.zerotier.com/manual.shtml#2_2?pk_campaign=github_libzt), see [examples/layer2](examples/layer2/layer2.cpp)
|
...
|
||||||
|
```
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### Build
|
## Build
|
||||||
|
|
||||||
We recommend using [CMake](https://cmake.org/) and [clang](https://en.wikipedia.org/wiki/Clang).
|
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:
|
||||||
|
|
||||||
```
|
```
|
||||||
git submodule update --init && make patch
|
make update
|
||||||
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
|
make patch
|
||||||
|
make all
|
||||||
```
|
```
|
||||||
|
|
||||||
or possibly:
|
All build targets can be seen by using `make list`.
|
||||||
|
|
||||||
```
|
Resultant libraries will be placed in `lib`, test and example programs will be placed in `bin`.
|
||||||
cmake -H. -Bbuild --config Release
|
|
||||||
```
|
|
||||||
|
|
||||||
Then
|
|
||||||
|
|
||||||
```
|
|
||||||
cmake --build build
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Builds are placed in `bin\lib`
|
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
### Commercial License
|
## Commercial License
|
||||||
|
|
||||||
If you want a commercial license to use libzt in your product contact us directly via `contact@zerotier.com`
|
If you want a commercial license to use the ZeroTier SDK in your product contact us directly via `contact@zerotier.com`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user