Browse Source

new OSX shared library target

pull/1/head
Joseph Henry 10 years ago
parent
commit
bef23ea04d
  1. 25
      docs/integrations.md
  2. 13
      docs/osx_zt_sdk.md
  3. 25
      integrations/README.md
  4. 13
      integrations/apple/example_app/OSX/README.md
  5. 13
      make-mac.mk
  6. 6
      src/SDK_ServiceSetup.hpp

25
docs/integrations.md

@ -14,24 +14,25 @@ For more support on these integrations, or if you'd like help creating a new int
*** ***
## Important Build flags ## Important Build flags
- `SDK_DEBUG` - Turns on SDK activity/warning/error output. Levels of verbosity can be adjusted in `src/SDK_Debug.h` - `SDK_DEBUG=1` - Turns on SDK activity/warning/error output. Levels of verbosity can be adjusted in `src/SDK_Debug.h`
- `SDK_DEBUG_LOGFILE` - Used in conjunction with `SDK_DEBUG`, this will write all SDK debug chatter to a log file. To use this, set `make SDK_DEBUG_LOGFILE=1` then `export ZT_SDK_LOGFILE=debug.log`. - `SDK_DEBUG_LOGFILE=1` - Used in conjunction with `SDK_DEBUG`, this will write all SDK debug chatter to a log file. To use this, set `make SDK_DEBUG_LOGFILE=1` then `export ZT_SDK_LOGFILE=debug.log`.
- `SDK_LWIP_DEBUG` - Turns on debug output for the lwIP library. - `SDK_LWIP_DEBUG=1` - Turns on debug output for the lwIP library.
- `SDK_BUNDLED` - Builds the SDK as a single bundled target including a the RPC mechanism, the lwIP library, and the ZeroTier service. - `SDK_BUNDLED=1` - Builds the SDK as a single bundled target including a the RPC mechanism, the lwIP library, and the ZeroTier service.
- `SDK_SOCKS_PROXY` - Enables the SOCK5 Proxy. This flag is enabled by default on must builds, especially mobile. - `SDK_SOCKS_PROXY=1` - Enables the SOCK5 Proxy. This flag is enabled by default on must builds, especially mobile.
*** ***
## Current Integrations ## Current Integrations
### Apple `make apple` ### Apple `make apple`
##### iOS ##### iOS
- [Embedding within an app](apple/example_app/iOS) `make ios_app_framework` - [Embedding within an app](apple/example_app/iOS) `make ios_app_framework` -> `build/ios_app_framework/*`
- Unity3D plugin `make ios_unity3d_bundle` - Unity3D plugin `make ios_unity3d_bundle` -> `build/ios_unity3d_bundle/*`
##### OSX ##### OSX
- [Embedding within an app](apple/example_app/OSX) `make osx_app_framework` - [Linking into an app at compiletime](../docs/osx_zt_sdk.md) `make osx_shared_lib` -> `build/libztosx.so`
- [Dynamic-linking into an app/service at runtime](../docs/osx_zt_sdk.md) `make osx_shared_lib` - [Embedding within an app with Xcode](apple/example_app/OSX) `make osx_app_framework` -> `build/osx_app_framework/*`
- [Unity3D plugin](apple/ZeroTierSDK_Apple) `make osx_unity3d_bundle` - [Dynamic-linking into an app/service at runtime](../docs/osx_zt_sdk.md) `make osx_service_and_intercept` -> `build/zerotier-sdk-service` + `build/libztintercept.so`
- [Unity3D plugin](apple/ZeroTierSDK_Apple) `make osx_unity3d_bundle` ->
*** ***
### Linux ### Linux
@ -39,8 +40,8 @@ For more support on these integrations, or if you'd like help creating a new int
- [Using the SDK with Docker](docker) - [Using the SDK with Docker](docker)
### Android `make android` ### Android `make android`
- [Embedding within an app](android) `make android_jni_lib` - [Embedding within an app](android) `make android_jni_lib` -> `build/android_jni_lib/YOUR_ARCH/libZeroTierOneJNI.so`
- [Unity 3D plugin](../docs/android_unity3d_zt_sdk.md) `make android_unity3d_plugin` - [Unity 3D plugin](../docs/android_unity3d_zt_sdk.md) `make android_unity3d_plugin` -> `build/android_unity3d_plugin/*`
*** ***
### Windows ### Windows

13
docs/osx_zt_sdk.md

@ -8,7 +8,16 @@ Imagine a flat, encrypted, no-configuration LAN for all of the instances of your
This short tutorial will show you how to enable ZeroTier functionality for your OSX app with little to no code modification. Check out our [ZeroTier SDK](https://www.zerotier.com/blog) page for more info on how the integration works. This short tutorial will show you how to enable ZeroTier functionality for your OSX app with little to no code modification. Check out our [ZeroTier SDK](https://www.zerotier.com/blog) page for more info on how the integration works.
*** ***
## Via Static-linking
## Via Traditional Linking (Everything bundled)
```
make osx_shared_lib`
g++ myapp.cpp -o myapp libztosx.so
./myapp
```
## Via Traditional Linking (Service+Intercept model)
Example: Example:
@ -23,7 +32,7 @@ Run application
./myapp ./myapp
## Via App Framework ## Via App Framework in XCode
*** ***
**Step 1: Build iOS framework** **Step 1: Build iOS framework**

25
integrations/README.md

@ -14,24 +14,25 @@ For more support on these integrations, or if you'd like help creating a new int
*** ***
## Important Build flags ## Important Build flags
- `SDK_DEBUG` - Turns on SDK activity/warning/error output. Levels of verbosity can be adjusted in `src/SDK_Debug.h` - `SDK_DEBUG=1` - Turns on SDK activity/warning/error output. Levels of verbosity can be adjusted in `src/SDK_Debug.h`
- `SDK_DEBUG_LOGFILE` - Used in conjunction with `SDK_DEBUG`, this will write all SDK debug chatter to a log file. To use this, set `make SDK_DEBUG_LOGFILE=1` then `export ZT_SDK_LOGFILE=debug.log`. - `SDK_DEBUG_LOGFILE=1` - Used in conjunction with `SDK_DEBUG`, this will write all SDK debug chatter to a log file. To use this, set `make SDK_DEBUG_LOGFILE=1` then `export ZT_SDK_LOGFILE=debug.log`.
- `SDK_LWIP_DEBUG` - Turns on debug output for the lwIP library. - `SDK_LWIP_DEBUG=1` - Turns on debug output for the lwIP library.
- `SDK_BUNDLED` - Builds the SDK as a single bundled target including a the RPC mechanism, the lwIP library, and the ZeroTier service. - `SDK_BUNDLED=1` - Builds the SDK as a single bundled target including a the RPC mechanism, the lwIP library, and the ZeroTier service.
- `SDK_SOCKS_PROXY` - Enables the SOCK5 Proxy. This flag is enabled by default on must builds, especially mobile. - `SDK_SOCKS_PROXY=1` - Enables the SOCK5 Proxy. This flag is enabled by default on must builds, especially mobile.
*** ***
## Current Integrations ## Current Integrations
### Apple `make apple` ### Apple `make apple`
##### iOS ##### iOS
- [Embedding within an app](apple/example_app/iOS) `make ios_app_framework` - [Embedding within an app](apple/example_app/iOS) `make ios_app_framework` -> `build/ios_app_framework/*`
- Unity3D plugin `make ios_unity3d_bundle` - Unity3D plugin `make ios_unity3d_bundle` -> `build/ios_unity3d_bundle/*`
##### OSX ##### OSX
- [Embedding within an app](apple/example_app/OSX) `make osx_app_framework` - [Linking into an app at compiletime](../docs/osx_zt_sdk.md) `make osx_shared_lib` -> `build/libztosx.so`
- [Dynamic-linking into an app/service at runtime](../docs/osx_zt_sdk.md) `make osx_shared_lib` - [Embedding within an app with Xcode](apple/example_app/OSX) `make osx_app_framework` -> `build/osx_app_framework/*`
- [Unity3D plugin](apple/ZeroTierSDK_Apple) `make osx_unity3d_bundle` - [Dynamic-linking into an app/service at runtime](../docs/osx_zt_sdk.md) `make osx_service_and_intercept` -> `build/zerotier-sdk-service` + `build/libztintercept.so`
- [Unity3D plugin](apple/ZeroTierSDK_Apple) `make osx_unity3d_bundle` ->
*** ***
### Linux ### Linux
@ -39,8 +40,8 @@ For more support on these integrations, or if you'd like help creating a new int
- [Using the SDK with Docker](docker) - [Using the SDK with Docker](docker)
### Android `make android` ### Android `make android`
- [Embedding within an app](android) `make android_jni_lib` - [Embedding within an app](android) `make android_jni_lib` -> `build/android_jni_lib/YOUR_ARCH/libZeroTierOneJNI.so`
- [Unity 3D plugin](../docs/android_unity3d_zt_sdk.md) `make android_unity3d_plugin` - [Unity 3D plugin](../docs/android_unity3d_zt_sdk.md) `make android_unity3d_plugin` -> `build/android_unity3d_plugin/*`
*** ***
### Windows ### Windows

13
integrations/apple/example_app/OSX/README.md

@ -8,7 +8,16 @@ Imagine a flat, encrypted, no-configuration LAN for all of the instances of your
This short tutorial will show you how to enable ZeroTier functionality for your OSX app with little to no code modification. Check out our [ZeroTier SDK](https://www.zerotier.com/blog) page for more info on how the integration works. This short tutorial will show you how to enable ZeroTier functionality for your OSX app with little to no code modification. Check out our [ZeroTier SDK](https://www.zerotier.com/blog) page for more info on how the integration works.
*** ***
## Via Static-linking
## Via Traditional Linking (Everything bundled)
```
make osx_shared_lib`
g++ myapp.cpp -o myapp libztosx.so
./myapp
```
## Via Traditional Linking (Service+Intercept model)
Example: Example:
@ -23,7 +32,7 @@ Run application
./myapp ./myapp
## Via App Framework ## Via App Framework in XCode
*** ***
**Step 1: Build iOS framework** **Step 1: Build iOS framework**

13
make-mac.mk

@ -59,7 +59,7 @@ apple: osx ios
ios: ios_app_framework ios_unity3d_bundle ios: ios_app_framework ios_unity3d_bundle
# Build all OSX targets # Build all OSX targets
osx: osx_app_framework osx_unity3d_bundle osx_shared_lib osx: osx_app_framework osx_unity3d_bundle osx_shared_lib osx_service_and_intercept
# Build all Android targets # Build all Android targets
# Chip architectures can be specified in integrations/android/android_jni_lib/java/jni/Application.mk # Chip architectures can be specified in integrations/android/android_jni_lib/java/jni/Application.mk
@ -99,18 +99,18 @@ remove_only_intermediates:
-find . -type f \( -name '*.o' -o -name '*.so' \) -delete -find . -type f \( -name '*.o' -o -name '*.so' \) -delete
osx_shared_lib: remove_only_intermediates $(OBJS) osx_shared_lib: remove_only_intermediates $(OBJS)
mkdir -p $(BUILD)/osx_shared_lib $(CXX) $(CXXFLAGS) $(LDFLAGS) -DSDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -Izerotierone/osdep -Izerotierone/node -Izerotierone/service -Isrc -shared -o $(BUILD)/libztosx.so $(OBJS) zerotierone/service/OneService.cpp src/SDK_ServiceSetup.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp zerotierone/one.cpp -x c src/SDK_Sockets.c src/SDK_Intercept.c src/SDK_Debug.c src/SDK_RPC.c $(LDLIBS) -ldl
osx_service_and_intercept: remove_only_intermediates $(OBJS)
# Need to selectively rebuild one.cpp and OneService.cpp with ZT_SERVICE_NETCON and ZT_ONE_NO_ROOT_CHECK defined, and also NetconEthernetTap # Need to selectively rebuild one.cpp and OneService.cpp with ZT_SERVICE_NETCON and ZT_ONE_NO_ROOT_CHECK defined, and also NetconEthernetTap
$(CXX) $(CXXFLAGS) $(LDFLAGS) -DSDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -Izerotierone/osdep -Izerotierone/node -Isrc -o $(BUILD)/zerotier-sdk-service $(OBJS) zerotierone/service/OneService.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp zerotierone/one.cpp -x c src/SDK_RPC.c $(LDLIBS) -ldl $(CXX) $(CXXFLAGS) $(LDFLAGS) -DSDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -Izerotierone/osdep -Izerotierone/node -Isrc -o $(BUILD)/zerotier-sdk-service $(OBJS) zerotierone/service/OneService.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp zerotierone/one.cpp -x c src/SDK_RPC.c $(LDLIBS) -ldl
# Build liblwip.so which must be placed in ZT home for zerotier-sdk-service to work # Build liblwip.so which must be placed in ZT home for zerotier-sdk-service to work
make -f make-liblwip.mk make -f make-liblwip.mk
# Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility # Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
cd src ; gcc $(DEFS) -O2 -Wall -std=c99 -fPIC -fno-common -dynamiclib -flat_namespace -DVERBOSE -D_GNU_SOURCE -DNETCON_INTERCEPT -I. -I../zerotierone/node -nostdlib -shared -o libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl cd src ; gcc $(DEFS) -O2 -Wall -std=c99 -fPIC -fno-common -dynamiclib -flat_namespace -DVERBOSE -D_GNU_SOURCE -DNETCON_INTERCEPT -I. -I../zerotierone/node -nostdlib -shared -o libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl
mv src/libztintercept.so $(BUILD)/osx_shared_lib/libztintercept.so mv src/libztintercept.so $(BUILD)/libztintercept.so
ln -sf zerotier-sdk-service zerotier-cli ln -sf zerotier-sdk-service zerotier-cli
ln -sf zerotier-sdk-service zerotier-idtool ln -sf zerotier-sdk-service zerotier-idtool
cp docs/osx_zt_sdk.md $(BUILD)/osx_shared_lib/README.md
prep: prep:
cp $(INT)/android/android_jni_lib/java/libs/* build cp $(INT)/android/android_jni_lib/java/libs/* build
@ -118,7 +118,8 @@ prep:
# Check for the presence of built frameworks/bundles/libaries # Check for the presence of built frameworks/bundles/libaries
check: check:
./check.sh $(BUILD)/lwip/liblwip.so ./check.sh $(BUILD)/lwip/liblwip.so
./check.sh $(BUILD)/osx_shared_lib/libztintercept.so ./check.sh $(BUILD)/libztintercept.so
./check.sh $(BUILD)/libztosx.so
./check.sh $(BUILD)/osx_unity3d_bundle/Debug/ZeroTierSDK_Unity3D_OSX.bundle ./check.sh $(BUILD)/osx_unity3d_bundle/Debug/ZeroTierSDK_Unity3D_OSX.bundle
./check.sh $(BUILD)/osx_app_framework/Debug/ZeroTierSDK_OSX.framework ./check.sh $(BUILD)/osx_app_framework/Debug/ZeroTierSDK_OSX.framework
./check.sh $(BUILD)/ios_app_framework/Debug-iphoneos/ZeroTierSDK_iOS.framework ./check.sh $(BUILD)/ios_app_framework/Debug-iphoneos/ZeroTierSDK_iOS.framework

6
src/SDK_ServiceSetup.hpp

@ -25,8 +25,6 @@
* LLC. Start here: http://www.zerotier.com/ * LLC. Start here: http://www.zerotier.com/
*/ */
#include <string>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -40,9 +38,7 @@ extern "C" {
#define INTERCEPT_ENABLED 111 #define INTERCEPT_ENABLED 111
#define INTERCEPT_DISABLED 222 #define INTERCEPT_DISABLED 222
extern std::string homeDir;
#if defined(__ANDROID__) #if defined(__ANDROID__)
// JNI naming convention: Java_PACKAGENAME_CLASSNAME_METHODNAME // JNI naming convention: Java_PACKAGENAME_CLASSNAME_METHODNAME
/* If you define anything else in this file it that you wish to expose to your Android /* If you define anything else in this file it that you wish to expose to your Android

Loading…
Cancel
Save