ZeroTier Sockets
Part of the ZeroTier SDK
P2P cross-platform encrypted sockets library using ZeroTier
| Language/Platform | Install | Version | Example |
|---|---|---|---|
| C/C++ | Build from source | C/C++ | |
| C# | Install-Package ZeroTier.Sockets |
C# | |
| Python | pip install libzt |
Python | |
| Rust | See: crates.io/crates/libzt | Rust | |
| Java | Install JDK, then: ./build.sh host-jar |
Java | |
| Linux | brew install zerotier/tap/libzt |
C/C++ | |
| macOS | brew install zerotier/tap/libzt |
C/C++ | |
| iOS / iPadOS | ./build.sh iphoneos-framework |
Objective-C, Swift | |
| Android | ./build.sh android-aar |
Java |
#include "ZeroTierSockets.h"
int main()
{
zts_node_start();
zts_net_join(net_id);
int fd = zts_bsd_socket(ZTS_AF_INET, ZTS_SOCK_STREAM, 0);
zts_bsd_connect(fd, ...);
...
}
Build from source (optional)
git submodule update --init
This project uses CMake (3.10 or newer) as a build system generator. The scripts build.* simplify building and packaging for various targets. There are many targets and configurations not mentioned here.
| Platform | Build instructions | Notes |
|---|---|---|
| Linux | ./build.sh host "release" |
build.sh |
| macOS | ./build.sh host "release" |
build.sh |
| Windows | . .\build.ps1; Build-Host -BuildType "Release" -Arch "x64" |
build.ps1, Requires PowerShell |
Using the host keyword will automatically detect the current machine type and build standard libzt for use in C/C++ (no additional language bindings.) See ./build.sh list for additional target options.
libzt has an optional portion of the API that interfaces with our hosted web offering (my.zerotier.com). It is disabled by default. To enable it, invoke CMake directly with -DZTS_DISABLE_CENTRAL_API=OFF; this requires cURL and its development headers. The build.sh targets do not pass additional CMake flags, so enabling it means configuring the build yourself:
cmake -DBUILD_HOST=True -DZTS_DISABLE_CENTRAL_API=OFF -S . -B cache/central -DCMAKE_BUILD_TYPE=release
cmake --build cache/central
Example output. The directory is named for the detected platform and machine type, for example macos-arm64-host-release, macos-x64-host-release, or linux-x64-host-release:
~/libzt/dist/<platform>-<arch>-host-release
├── bin
│ ├── client
│ ├── server
│ └── ...
└── lib
├── libzt.a
└── libzt.dylib
Important directories:
| Directory | Purpose |
|---|---|
dist |
Contains finished targets (libraries, binaries, packages, etc.) |
cache |
Contains build system caches that can safely be deleted after use. |
pkg |
Contains project, script and spec files to generate packages. |
Self-hosting
If you'd like to use your own infrastructure we make it easy to set up your own controllers and roots.
Help
- Documentation: docs.zerotier.com
- Examples: examples/
- Bug reports: Open a github issue.
- General ZeroTier troubleshooting: Knowledgebase.
- Chat with us: discuss.zerotier.com
Licensing
ZeroTier and the ZeroTier SDK (libzt and libztcore) are licensed under the BSL version 1.1. ZeroTier is free to use internally in businesses and academic institutions and for non-commercial purposes. Certain types of commercial use such as building closed-source apps and devices based on ZeroTier or offering ZeroTier network controllers and network management as a SaaS service require a commercial license. A small amount of third party code is also included in ZeroTier and is not subject to our BSL license. See AUTHORS.md for a list of third party code, where it is included, and the licenses that apply to it. All of the third party code in ZeroTier is liberally licensed (MIT, BSD, Apache, public domain, etc.). If you want a commercial license to use the ZeroTier SDK in your product contact us directly via contact@zerotier.com