Giter Site home page Giter Site logo

weibo3721 / zerotiersdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gdamore/libzt

0.0 2.0 0.0 32.35 MB

ZeroTier SDK and User-Space Networking Stack

License: Other

Makefile 1.09% Shell 0.92% C 66.30% Batchfile 0.02% HTML 0.07% Perl 0.03% C++ 29.04% Python 0.11% JavaScript 0.22% C# 1.29% Java 0.56% Objective-C 0.01% Swift 0.33% Lua 0.01% Roff 0.01%

zerotiersdk's Introduction

ZeroTier SDK

ZeroTier-enabled apps, devices, and services.

  • For a convenient BSD socket-style API, follow the rest of this document.
  • For information on the core ZT API, see ZeroTierOne.h

Secure virtual network access embedded directly into applications, games, and devices. Imagine starting an instance of your application or game and having it automatically be a member of your virtual network without having to rewrite your networking layer. Check out our Integrations to learn how to integrate this into your application, device, or ecosystem.

The general idea is this:

  • Your application starts.
  • The API and ZeroTier service initializes inside a separate thread of your app.
  • Your app can now reach anything on your flat virtual network via normal network calls.

It's as simple as that!

To build everything for your platform, you can start with:

  • On Linux: make linux SDK_PICOTCP=1 SDK_IPV4=1 SDK_DEBUG=1; make -s check; ls -lG build
  • On macOS: make apple SDK_PICOTCP=1 SDK_IPV4=1 SDK_DEBUG=1; make -s check; ls -lG build

The SDK couples the ZeroTier core Ethernet virtualization engine with a user-space TCP/IP stack and a carefully-crafted API which intercepts and re-directs network API calls to our service. This allows servers and applications to be used without modification or recompilation. It can be used to run services on virtual networks without elevated privileges, special configuration of the physical host, kernel support, or any other application specific configuration. It's ideal for containerized applications, games, and desktop/mobile apps.

Combine this functionality with the network/device management capabilities of ZeroTier Central and its associated API and we've hopefully created a simple and reliable way for you to flatten and reduce the complexity of your app's networking layer.

The ZeroTier SDK now works on both x64 and ARM architectures. We've tested a beta version for iOS, Android, Linux, and macOS.

How do I use it?

There are generally two ways one might want to use the service.

  • The first approach is a compile-time static linking of our service library directly into your application. With this option you can bundle our entire functionality right into your app with no need to communicate with a service externally, it'll all be handled automatically. This is most typical for mobile applications, games, etc.

  • The second is a service-oriented approach where our smaller intercept library is dynamically-linked into your app upon startup and will communicate to a single ZeroTier service on the host which will relay traffic to and from the ZeroTier virtual network. This can be useful if you don't have access to the app's source code and can't perform a static linking.

Image

How does it work?

We've designed a background tap service that pairs the ZeroTier protocol with swappable user-space network stacks. We've provided drivers for Lightweight IP (lwIP) and picoTCP. The aim is to give you a new way to bring your applications onto your virtual network. For a more in-depth explanation of how it works take a look at our Technical discussion

APIs

Hook/Intercept

  • Uses dynamic loading of our library to allow function interposition or "hooking" to re-implement traditional socket API functions like socket(), connect(), bind(), etc.

Direct Call

  • Directly call the zts_* API specified in src/sdk.h. For this to work, just use one of the provided headers that specify the interface for your system/architecture and then either dynamically-load our library into your app or statically-link it at compile-time.

Important Build Flags

  • SDK_IPV4=1 - Enable IPv4 support

  • SDK_IPV6=1 - Enable IPv6 support

  • SDK_DEBUG=1 - Enables SDK debugging

  • SDK_PICOTCP=1 - Enable the use of picoTCP (recommended)

  • SDK_PICOTCP_DEBUG=1 - Enables debug output for the picoTCP network stack

  • SDK_LWIP=1 - Enable the use of lwIP (deprecated)

  • SDK_LWIP_DEBUG=1 - Enables debug output for the lwIP library.


Apple

  • For everything: make apple <flags>
iOS
  • Embedding within an app make ios_app_framework -> build/ios_app_framework/*
  • Unity3D plugin make ios_unity3d_bundle -> build/ios_unity3d_bundle/*
OSX

Linux

Android

  • For everything: make android

  • Embedding within an app make android_jni_lib -> build/android_jni_lib/YOUR_ARCH/libZeroTierOneJNI.so


Windows

  • Not yet.

Image

More discussion can be found in our original blog announcement and the SDK product page. If you have any feature or support requests, be sure to let us know here!

zerotiersdk's People

Contributors

joseph-henry avatar janjaapbos avatar pmajumdar-ixia avatar adamierymenko avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.