This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-libzt/docs/gentle_intro.md

2.8 KiB

For beginners

Why would I integrate ZeroTier into my app?

The ZeroTier SDK is designed specifically for the developer that doesn't want to work with or deal with the headaches of writing a networking layer for their app. Integrating ZeroTier into your application will prevent you from having to figure out how to do the complex networking that your app might require. It will provide you with a secure, easy-to-use, P2P connectivity solution.

Use in Mobile Apps

If you're writing a game and you'd like to give it the ability talk to other instances in a secure and fast manner, you can embed our library into your app and choose from a couple different APIs. If you're developing for iOS, you'll want to add our iOS Framework to your project. If you're developing for Android, you'll need to add our JNI library to your project. Once your app starts up, a separate thread will start which contains the ZeroTier service and a network stack dedicated entirely to your app. Each of these integrations give your app two main options for talking over a ZeroTier network. The first is a "direct call" which is means you'll call functions such as zt_socket(), zt_connect(), ... which are reimplementations of the traditional socket API. Alternatively we provide a SOCKS5 proxy server in a separate thread which you can turn on via zt_start_proxy_server(...). And if you've already implemented your networking layer using the traditional socket API and you aren't using third-party libraries that need to make network calls, you can zt_start_intercept(). The intercept will essentially hijack your network calls and route them to our reimplementations. This has the advantage that you literally don't have to change a single line of your networking code to use ZeroTier. (NOTE, the intercept is not available on Android).

Use in Desktop Apps

Desktop apps are a bit easier than mobile apps to integrate with ZeroTier and you'll have even more API options. The exact details vary slightly among the various platforms/OSes we support, but generally you can either link the ZeroTier library into your application (same as mobile), you can use the built-in SOCKS5 proxy (same as mobile), you can use the intercept (so far tested on OSX, Linux), or you can use LD_PRELOAD to dynamically load just the intercept into each of your apps and all will talk to a single zerotier-sdk-service running on the local host. This last option is a good option if you don't have access to the source code of the application and thus cannot use the direct call or SOCKS5 proxy APIs.