From bca8e1cda01072f7ca19cf6af357cad94ad208f6 Mon Sep 17 00:00:00 2001
From: Evan Olcott
Date: Mon, 6 May 2019 14:47:36 -0500
Subject: [PATCH 01/78] iOS Simulator support
Added support for the iOS Simulator in zt.framework for iOS.
---
dist.sh | 61 ++++++++++++++++++++++++++++++---------------------------
1 file changed, 32 insertions(+), 29 deletions(-)
diff --git a/dist.sh b/dist.sh
index d9a8b93..19a24ea 100755
--- a/dist.sh
+++ b/dist.sh
@@ -36,8 +36,8 @@ BUILD_CONCURRENCY=
OSNAME=$(uname | tr '[A-Z]' '[a-z]')
BUILD_TMP=$(pwd)/tmp
ANDROID_PROJ_DIR=$(pwd)/ports/android
-XCODE_IOS_ARM64_PROJ_DIR=$(pwd)/ports/xcode_ios-arm64
-#XCODE_IOS_ARMV7_PROJ_DIR=$(pwd)/ports/xcode_ios-armv7
+XCODE_IOS_PROJ_DIR=$(pwd)/ports/xcode_ios
+XCODE_IOS_SIMULATOR_PROJ_DIR=$(pwd)/ports/xcode_ios_simulator
XCODE_MACOS_PROJ_DIR=$(pwd)/ports/xcode_macos
# Generates projects if needed
@@ -49,23 +49,24 @@ generate_projects()
echo "Executing task: " ${FUNCNAME[ 0 ]} "(" $1 ")"
if [[ $OSNAME = *"darwin"* ]]; then
# iOS (SDK 11+, 64-bit only, arm64)
- if [ ! -d "$XCODE_IOS_ARM64_PROJ_DIR" ]; then
- mkdir -p $XCODE_IOS_ARM64_PROJ_DIR
- cd $XCODE_IOS_ARM64_PROJ_DIR
+ if [ ! -d "$XCODE_IOS_PROJ_DIR" ]; then
+ mkdir -p $XCODE_IOS_PROJ_DIR
+ cd $XCODE_IOS_PROJ_DIR
cmake -G Xcode ../../ -DIOS_FRAMEWORK=1 -DIOS_ARM64=1
# Manually replace arch strings in project file
sed -i '' 's/x86_64/$(CURRENT_ARCH)/g' zt.xcodeproj/project.pbxproj
cd -
fi
- # iOS (SDK <11, 32-bit only, armv7, armv7s)
- #if [ ! -d "$XCODE_IOS_ARMV7_PROJ_DIR" ]; then
- # mkdir -p $XCODE_IOS_ARMV7_PROJ_DIR
- # cd $XCODE_IOS_ARMV7_PROJ_DIR
- # cmake -G Xcode ../../ -DIOS_FRAMEWORK=1 -DIOS_ARMV7=1
+
+ if [ ! -d "$XCODE_IOS_SIMULATOR_PROJ_DIR" ]; then
+ mkdir -p $XCODE_IOS_SIMULATOR_PROJ_DIR
+ cd $XCODE_IOS_SIMULATOR_PROJ_DIR
+ cmake -G Xcode ../../ -DIOS_FRAMEWORK=1
# Manually replace arch strings in project file
- # sed -i '' 's/x86_64/$(CURRENT_ARCH)/g' zt.xcodeproj/project.pbxproj
- # cd -
- #fi
+ #sed -i '' 's/x86_64/$(CURRENT_ARCH)/g' zt.xcodeproj/project.pbxproj
+ cd -
+ fi
+
# macOS
if [ ! -d "$XCODE_MACOS_PROJ_DIR" ]; then
mkdir -p $XCODE_MACOS_PROJ_DIR
@@ -86,27 +87,29 @@ ios()
echo "Executing task: " ${FUNCNAME[ 0 ]} "(" $1 ")"
UPPERCASE_CONFIG="$(tr '[:lower:]' '[:upper:]' <<< ${1:0:1})${1:1}"
- # 64-bit
- cd $XCODE_IOS_ARM64_PROJ_DIR
+ cd $XCODE_IOS_PROJ_DIR
# Framework
xcodebuild -arch arm64 -target zt -configuration "$UPPERCASE_CONFIG" -sdk "iphoneos"
cd -
- OUTPUT_DIR=$(pwd)/lib/$1/ios-arm64
- mkdir -p $OUTPUT_DIR
- rm -rf $OUTPUT_DIR/zt.framework # Remove prior to move to prevent error
- mv $XCODE_IOS_ARM64_PROJ_DIR/$UPPERCASE_CONFIG-iphoneos/* $OUTPUT_DIR
+ IOS_OUTPUT_DIR=$(pwd)/lib/$1/ios
+ mkdir -p $IOS_OUTPUT_DIR
+ rm -rf $IOS_OUTPUT_DIR/zt.framework # Remove prior to move to prevent error
+ mv $XCODE_IOS_PROJ_DIR/$UPPERCASE_CONFIG-iphoneos/* $IOS_OUTPUT_DIR
- # 32-bit
- #cd $XCODE_IOS_ARMV7_PROJ_DIR
+ cd $XCODE_IOS_SIMULATOR_PROJ_DIR
# Framework
- #xcodebuild -target zt -configuration "$UPPERCASE_CONFIG" -sdk "iphoneos10.0"
- # Manually replace arch strings in project file
- #sed -i '' 's/x86_64/$(CURRENT_ARCH)/g' zt.xcodeproj/project.pbxproj
- #cd -
- #OUTPUT_DIR=$(pwd)/lib/$1/ios-armv7
- #mkdir -p $OUTPUT_DIR
- #rm -rf $OUTPUT_DIR/*
- #mv $XCODE_IOS_ARMV7_PROJ_DIR/$UPPERCASE_CONFIG-iphoneos/* $OUTPUT_DIR
+ xcodebuild -target zt -configuration "$UPPERCASE_CONFIG" -sdk "iphonesimulator"
+ cd -
+ SIMULATOR_OUTPUT_DIR=$(pwd)/lib/$1/ios-simulator
+ mkdir -p $SIMULATOR_OUTPUT_DIR
+ rm -rf $SIMULATOR_OUTPUT_DIR/zt.framework # Remove prior to move to prevent error
+ mv $XCODE_IOS_SIMULATOR_PROJ_DIR/$UPPERCASE_CONFIG-iphonesimulator/* $SIMULATOR_OUTPUT_DIR
+
+ # Combine the two archs
+ lipo -create $IOS_OUTPUT_DIR/zt.framework/zt $SIMULATOR_OUTPUT_DIR/zt.framework/zt -output $IOS_OUTPUT_DIR/zt.framework/zt
+
+ # Clean up
+ rm -rf $SIMULATOR_OUTPUT_DIR
}
# Build framework for current host (macOS only)
From d07b3a4f188a45f51bfca1646b2d44e540400242 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Mon, 6 May 2019 15:01:19 -0700
Subject: [PATCH 02/78] Updated Makefile clean_* section to correspond with new
port/xcode_* paths
---
Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index a201f6d..fbe95fb 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,8 @@ patch:
# Target-specific clean
clean_ios:
- -rm -rf ports/xcode_ios-arm64
+ -rm -rf ports/xcode_ios
+ -rm -rf ports/xcode_ios_simulator
clean_macos:
-rm -rf ports/xcode_macos
clean_android:
From 726216a22d51c9a069b01dda2e8493a3cc9c2975 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 7 May 2019 12:14:49 -0700
Subject: [PATCH 03/78] Added .gitattributes to exclude certain directories
from git-archive
---
.gitattributes | 5 ++++
ports/Homebrew/README.md | 15 +++++++++++
ports/Homebrew/libzt.rb | 58 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 78 insertions(+)
create mode 100644 .gitattributes
create mode 100644 ports/Homebrew/README.md
create mode 100644 ports/Homebrew/libzt.rb
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..6513868
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,5 @@
+/examples export-ignore
+/ports export-ignore
+/test export-ignore
+.gitattributes export-ignore
+.gitignore export-ignore
\ No newline at end of file
diff --git a/ports/Homebrew/README.md b/ports/Homebrew/README.md
new file mode 100644
index 0000000..23e789c
--- /dev/null
+++ b/ports/Homebrew/README.md
@@ -0,0 +1,15 @@
+Homebrew formula for libzt/libztcore
+======
+
+This formula script is only here for archival purposes. To install `libzt` and `libztcore` via Homebrew use:
+
+```
+brew tap zerotier/libzt
+brew install libzt
+```
+
+Once accepted into Homebrew core this will be shortened to:
+
+```
+brew install libzt
+```
diff --git a/ports/Homebrew/libzt.rb b/ports/Homebrew/libzt.rb
new file mode 100644
index 0000000..68cf0cf
--- /dev/null
+++ b/ports/Homebrew/libzt.rb
@@ -0,0 +1,58 @@
+class Libzt < Formula
+ desc "ZeroTier: libzt -- An encrypted P2P networking library for applications"
+ homepage "https://www.zerotier.com"
+
+ version "1.3.0"
+
+ stable do
+ url "https://github.com/zerotier/libzt.git", :branch => "master", :revision => "3d1159882117278fcb5fabb623bd62175b6c7e6c"
+ end
+
+ bottle do
+ root_url "https://download.zerotier.com/dist/homebrew"
+ cellar :any
+ sha256 "e1ac8425fd0ea510c7db734af8d6c41cd3650b12f66a571f9d818c0121422eee" => :mojave
+ end
+
+ devel do
+ version "1.3.1"
+ url "https://github.com/zerotier/libzt.git", :branch => "dev"
+ end
+
+ head do
+ url "https://github.com/zerotier/libzt.git"
+ end
+
+ depends_on "cmake" => :build
+ depends_on "make" => :build
+
+ def install
+ system "make", "update"
+ system "cmake", ".", *std_cmake_args
+ system "cmake", "--build", "."
+ system "make", "install"
+ cp "LICENSE.GPL-3", "#{prefix}/LICENSE"
+ end
+
+ def caveats
+ <<~EOS
+ Visit https://my.zerotier.com to create virtual networks and authorize devices.
+ Visit https://www.zerotier.com/manual.shtml to learn more about how ZeroTier works.
+ Visit https://github.com/zerotier/ZeroTierOne/tree/master/controller to learn how to run your own network controller (advanced).
+ EOS
+ end
+
+ test do
+ # Writes a simple test program to test.cpp which calls a library function. The expected output of this
+ # function is -2. This test verifies the following:
+ # - The library was installed correctly
+ # - The library was linked correctly
+ # - Library code executes successfully and sends the proper error code to the test program
+ (testpath/"test.cpp").write <<-EOS
+ #include\n#include\nint main(){return zts_socket(0,0,0)!=-2;}
+ EOS
+
+ system ENV.cc, "-v", "test.cpp", "-o", "test", "-L#{lib}/Release", "-lzt"
+ system "./test"
+ end
+end
From ddd8e2c96e456aa40272e1008347a6c3d4795268 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 7 May 2019 12:20:47 -0700
Subject: [PATCH 04/78] Extended .gitattributes
---
.gitattributes | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/.gitattributes b/.gitattributes
index 6513868..642f37d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,24 @@
/examples export-ignore
/ports export-ignore
/test export-ignore
+
+/ext/lwip-contrib/apps/ export-ignore
+/ext/lwip-contrib/addons/ export-ignore
+/ext/lwip-contrib/Coverity/ export-ignore
+/ext/lwip-contrib/examples/ export-ignore
+/ext/lwip-contrib/*.mk export-ignore
+/ext/lwip-contrib/*.cmake export-ignore
+/ext/lwip/test export-ignore
+/ext/lwip/doc export-ignore
+
+/ext/ZeroTierOne/artwork export-ignore
+/ext/ZeroTierOne/attic export-ignore
+/ext/ZeroTierOne/debian export-ignore
+/ext/ZeroTierOne/doc export-ignore
+/ext/ZeroTierOne/docker export-ignore
+/ext/ZeroTierOne/java export-ignore
+/ext/ZeroTierOne/macui export-ignore
+/ext/ZeroTierOne/rule-compiler export-ignore
+
.gitattributes export-ignore
.gitignore export-ignore
\ No newline at end of file
From 326ca817671005a20ad09448fd45f2339076bc00 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 7 May 2019 12:22:58 -0700
Subject: [PATCH 05/78] Tweaked .gitattributes
---
.gitattributes | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/.gitattributes b/.gitattributes
index 642f37d..7cab7ae 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,24 +1,24 @@
-/examples export-ignore
-/ports export-ignore
-/test export-ignore
+examples export-ignore
+ports export-ignore
+test export-ignore
-/ext/lwip-contrib/apps/ export-ignore
-/ext/lwip-contrib/addons/ export-ignore
-/ext/lwip-contrib/Coverity/ export-ignore
-/ext/lwip-contrib/examples/ export-ignore
-/ext/lwip-contrib/*.mk export-ignore
-/ext/lwip-contrib/*.cmake export-ignore
-/ext/lwip/test export-ignore
-/ext/lwip/doc export-ignore
+ext/lwip-contrib/apps export-ignore
+ext/lwip-contrib/addons export-ignore
+ext/lwip-contrib/Coverity export-ignore
+ext/lwip-contrib/examples export-ignore
+ext/lwip-contrib/*.mk export-ignore
+ext/lwip-contrib/*.cmake export-ignore
+ext/lwip/test export-ignore
+ext/lwip/doc export-ignore
-/ext/ZeroTierOne/artwork export-ignore
-/ext/ZeroTierOne/attic export-ignore
-/ext/ZeroTierOne/debian export-ignore
-/ext/ZeroTierOne/doc export-ignore
-/ext/ZeroTierOne/docker export-ignore
-/ext/ZeroTierOne/java export-ignore
-/ext/ZeroTierOne/macui export-ignore
-/ext/ZeroTierOne/rule-compiler export-ignore
+ext/ZeroTierOne/artwork export-ignore
+ext/ZeroTierOne/attic export-ignore
+ext/ZeroTierOne/debian export-ignore
+ext/ZeroTierOne/doc export-ignore
+ext/ZeroTierOne/docker export-ignore
+ext/ZeroTierOne/java export-ignore
+ext/ZeroTierOne/macui export-ignore
+ext/ZeroTierOne/rule-compiler export-ignore
.gitattributes export-ignore
.gitignore export-ignore
\ No newline at end of file
From eaac3429f0f88686c7da0630bcdb9d1aea94c4f0 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Fri, 10 May 2019 10:39:27 -0700
Subject: [PATCH 06/78] Re-worked the CMakeLists.txt install section
---
CMakeLists.txt | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a67292..549318a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -505,18 +505,12 @@ endif ()
# | INSTALL |
# -----------------------------------------------------------------------------
-set(PUBLIC_ZT_HEADERS
+set (PUBLIC_ZT_HEADERS
${PROJECT_SOURCE_DIR}/include/ZeroTier.h
${PROJECT_SOURCE_DIR}/include/ZeroTierConstants.h)
-set(PUBLIC_ZTCORE_HEADERS
- ${PROJECT_SOURCE_DIR}/ext/ZeroTierOne/include/ZeroTierOne.h)
-
-set(include_dest "include")
-set(main_lib_dest "lib")
-set(lib_dest "${main_lib_dest}/${CMAKE_BUILD_TYPE}")
-install(TARGETS ${STATIC_LIB_NAME} EXPORT ${STATIC_LIB_NAME} DESTINATION "${lib_dest}")
-install(TARGETS ${DYNAMIC_LIB_NAME} EXPORT ${DYNAMIC_LIB_NAME} DESTINATION "${lib_dest}")
-install(FILES ${PUBLIC_ZT_HEADERS} DESTINATION "${include_dest}")
-install(FILES ${PUBLIC_ZTCORE_HEADERS} DESTINATION "${include_dest}")
-install(EXPORT ${STATIC_LIB_NAME} DESTINATION "${lib_dest}")
+set_target_properties(${STATIC_LIB_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_ZT_HEADERS}")
+install (TARGETS ${STATIC_LIB_NAME}
+ LIBRARY DESTINATION "lib"
+ PUBLIC_HEADER DESTINATION "include"
+)
From b5c49ebd35e490d33259d123086e502d4612e18e Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Fri, 10 May 2019 12:24:00 -0700
Subject: [PATCH 07/78] Tweaked Makefile patch target for compatibility with
older versions of git. Differentiated bdist and sdist in dist.sh
---
CMakeLists.txt | 5 +--
Makefile | 22 ++++++++-----
dist.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 92 insertions(+), 18 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 549318a..ea3a2fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -511,6 +511,7 @@ set (PUBLIC_ZT_HEADERS
set_target_properties(${STATIC_LIB_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_ZT_HEADERS}")
install (TARGETS ${STATIC_LIB_NAME}
- LIBRARY DESTINATION "lib"
- PUBLIC_HEADER DESTINATION "include"
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ PUBLIC_HEADER DESTINATION include
)
diff --git a/Makefile b/Makefile
index fbe95fb..ff90a2e 100644
--- a/Makefile
+++ b/Makefile
@@ -17,14 +17,14 @@ list:
# Pull all submodules
update:
- git submodule update --init
- git submodule status
+ @git submodule update --init
+ @git submodule status
# Patch submodules (issue update first)
patch:
- -git -C ext/lwip apply ../lwip.patch
- -git -C ext/lwip-contrib apply ../lwip-contrib.patch
- -git -C ext/ZeroTierOne apply ../ZeroTierOne.patch
+ -cd ext/lwip; git apply ../lwip.patch;
+ -cd ext/lwip-contrib; git apply ../lwip-contrib.patch;
+ -cd ext/ZeroTierOne; git apply ../ZeroTierOne.patch;
# Target-specific clean
clean_ios:
@@ -98,7 +98,13 @@ all: host host_jar macos ios android
wrap:
$(DIST_BUILD_SCRIPT) wrap
-# [For distribution process only] Marge and package everything into a tarball
-dist:
+# Binary distribution
+bdist:
$(DIST_BUILD_SCRIPT) merge
- $(DIST_BUILD_SCRIPT) dist
+ $(DIST_BUILD_SCRIPT) bdist
+
+# Source distribution
+sdist: update patch
+ $(DIST_BUILD_SCRIPT) sdist
+
+dist: bdist sdist
diff --git a/dist.sh b/dist.sh
index 19a24ea..0bb7ba0 100755
--- a/dist.sh
+++ b/dist.sh
@@ -292,6 +292,7 @@ clean()
prep_android_example()
{
echo "Executing task: " ${FUNCNAME[ 0 ]} "(" $1 ")"
+ mkdir -p examples/android/ExampleAndroidApp/app/libs/
cp -f lib/$1/android-armeabi-v7a/libzt-$1.aar \
examples/android/ExampleAndroidApp/app/libs/libzt.aar
}
@@ -448,6 +449,19 @@ wrap()
tar --exclude=$PROD_FILENAME -zcvf $PROD_FILENAME -C $ARCH_WRAP_DIR .
}
+# Renames and copies licenses for libzt and each of its dependencies
+package_licenses()
+{
+ CURR_DIR=$1
+ DEST_DIR=$2
+ mkdir -p $DEST_DIR
+ cp $CURR_DIR/ext/lwip/COPYING $DEST_DIR/LWIP-LICENSE.BSD
+ cp $CURR_DIR/ext/concurrentqueue/LICENSE.md $DEST_DIR/CONCURRENTQUEUE-LICENSE.BSD
+ cp $CURR_DIR/LICENSE.GPL-3 $DEST_DIR/ZEROTIER-LICENSE.GPL-3
+ cp $CURR_DIR/include/net/ROUTE_H-LICENSE.APSL $DEST_DIR/ROUTE_H-LICENSE.APSL
+ cp $CURR_DIR/include/net/ROUTE_H-LICENSE $DEST_DIR/ROUTE_H-LICENSE
+}
+
# Copies binaries, documentation, licenses, etc into a products
# dir and then tarballs everything together
package_everything()
@@ -457,14 +471,8 @@ package_everything()
PROD_NAME=$LIBZT_VERSION-$(date '+%Y%m%d_%H-%M')-$1
PROD_DIR=$(pwd)/products/$PROD_NAME/
# Make products directory
- LICENSE_DIR=$PROD_DIR/licenses
- mkdir -p $LICENSE_DIR
# Licenses
- cp $(pwd)/ext/lwip/COPYING $LICENSE_DIR/LWIP-LICENSE.BSD
- cp $(pwd)/ext/concurrentqueue/LICENSE.md $LICENSE_DIR/CONCURRENTQUEUE-LICENSE.BSD
- cp $(pwd)/LICENSE.GPL-3 $LICENSE_DIR/ZEROTIER-LICENSE.GPL-3
- cp $(pwd)/include/net/ROUTE_H-LICENSE.APSL $LICENSE_DIR/ROUTE_H-LICENSE.APSL
- cp $(pwd)/include/net/ROUTE_H-LICENSE $LICENSE_DIR/ROUTE_H-LICENSE
+ package_licenses $(pwd) $PROD_DIR/licenses
# Documentation
mkdir -p $PROD_DIR/doc
# Copy the errno header from lwIP for customer reference
@@ -523,8 +531,67 @@ package_everything()
done
}
+# Generates a source-only tarball
+sdist()
+{
+ VERSION=$(git describe --abbrev=0)
+ TARBALL_DIR="libzt-${VERSION}"
+ TARBALL_NAME=libzt-${VERSION}-source.tar.gz
+ PROD_DIR=$(pwd)/products/
+ mkdir -p $PROD_DIR
+ #
+ mkdir ${TARBALL_DIR}
+ # primary sources
+ cp -rf src ${TARBALL_DIR}/src
+ cp -rf include ${TARBALL_DIR}/include
+ # important build scripts
+ cp Makefile ${TARBALL_DIR}
+ cp CMakeLists.txt ${TARBALL_DIR}
+ cp *.md ${TARBALL_DIR}
+ cp *.sh ${TARBALL_DIR}
+ cp *.bat ${TARBALL_DIR}
+ # submodules/dependencies
+ # lwIP
+ mkdir ${TARBALL_DIR}/ext
+ mkdir -p ${TARBALL_DIR}/ext/lwip/src
+ cp -rf ext/lwip/src/api ${TARBALL_DIR}/ext/lwip/src
+ cp -rf ext/lwip/src/core ${TARBALL_DIR}/ext/lwip/src
+ cp -rf ext/lwip/src/include ${TARBALL_DIR}/ext/lwip/src
+ cp -rf ext/lwip/src/netif ${TARBALL_DIR}/ext/lwip/src
+ # lwIP ports
+ mkdir -p ${TARBALL_DIR}/ext/lwip-contrib/ports
+ cp -rf ext/lwip-contrib/ports/unix ${TARBALL_DIR}/ext/lwip-contrib/ports
+ cp -rf ext/lwip-contrib/ports/win32 ${TARBALL_DIR}/ext/lwip-contrib/ports
+ # ZeroTierOne
+ mkdir ${TARBALL_DIR}/ext/ZeroTierOne
+ cp -rf ext/ZeroTierOne/*.h ${TARBALL_DIR}/ext/ZeroTierOne
+ cp -rf ext/ZeroTierOne/controller ${TARBALL_DIR}/ext/ZeroTierOne
+ cp -rf ext/ZeroTierOne/ext ${TARBALL_DIR}/ext/ZeroTierOne
+ cp -rf ext/ZeroTierOne/include ${TARBALL_DIR}/ext/ZeroTierOne
+ cp -rf ext/ZeroTierOne/node ${TARBALL_DIR}/ext/ZeroTierOne
+ cp -rf ext/ZeroTierOne/osdep ${TARBALL_DIR}/ext/ZeroTierOne
+ #
+ # Perform selective removal
+ rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/bin
+ rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/tap-mac
+ rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/librethinkdbxx
+ rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/installfiles
+ rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/curl-*
+ rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/http-parser
+ #
+ mkdir ${TARBALL_DIR}/ext/concurrentqueue
+ cp -rf ext/concurrentqueue/*.h ${TARBALL_DIR}/ext/concurrentqueue
+ # Licenses
+ package_licenses $(pwd) $TARBALL_DIR/licenses
+ # Tarball everything and display the results
+ tar -cvf ${TARBALL_NAME} ${TARBALL_DIR}
+ tree ${TARBALL_DIR}
+ rm -rf ${TARBALL_DIR}
+ mv ${TARBALL_NAME} ${PROD_DIR}
+}
+
# Package both debug and release
-dist()
+bdist()
{
echo "Executing task: " ${FUNCNAME[ 0 ]} "(" $1 ")"
package_everything "debug"
From 9dbcc8eb45bf8863261599962c799b1de3557d14 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Fri, 10 May 2019 12:39:49 -0700
Subject: [PATCH 08/78] Added dynamic library to install section of
CMakeLists.txt
---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea3a2fb..add188e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -515,3 +515,6 @@ install (TARGETS ${STATIC_LIB_NAME}
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
+install (TARGETS ${DYNAMIC_LIB_NAME}
+ LIBRARY DESTINATION lib
+)
From 26ba6add126dd425c73627706753044e10b606af Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Mon, 13 May 2019 12:36:44 -0700
Subject: [PATCH 09/78] Updated ZeroTierOne submodule to incorperate minor
SDK-related changes
---
Makefile | 2 +-
ext/ZeroTierOne | 2 +-
ext/ZeroTierOne.patch | 123 ------------------------------------------
3 files changed, 2 insertions(+), 125 deletions(-)
delete mode 100644 ext/ZeroTierOne.patch
diff --git a/Makefile b/Makefile
index ff90a2e..77ea515 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ update:
patch:
-cd ext/lwip; git apply ../lwip.patch;
-cd ext/lwip-contrib; git apply ../lwip-contrib.patch;
- -cd ext/ZeroTierOne; git apply ../ZeroTierOne.patch;
+ #-cd ext/ZeroTierOne; git apply ../ZeroTierOne.patch;
# Target-specific clean
clean_ios:
diff --git a/ext/ZeroTierOne b/ext/ZeroTierOne
index 21f4f16..4743ad0 160000
--- a/ext/ZeroTierOne
+++ b/ext/ZeroTierOne
@@ -1 +1 @@
-Subproject commit 21f4f16e63f45577a614e25066e71080740fe175
+Subproject commit 4743ad0b16a72c00039de1aed98499fe0adf633f
diff --git a/ext/ZeroTierOne.patch b/ext/ZeroTierOne.patch
deleted file mode 100644
index cce5bf7..0000000
--- a/ext/ZeroTierOne.patch
+++ /dev/null
@@ -1,123 +0,0 @@
-diff --git a/node/Node.cpp b/node/Node.cpp
-index 30c722b2..f0503e1c 100644
---- a/node/Node.cpp
-+++ b/node/Node.cpp
-@@ -317,7 +317,7 @@ ZT_ResultCode Node::processBackgroundTasks(void *tptr,int64_t now,volatile int64
-
- // Update online status, post status change as event
- const bool oldOnline = _online;
-- _online = (((now - lastReceivedFromUpstream) < ZT_PEER_ACTIVITY_TIMEOUT)||(RR->topology->amUpstream()));
-+ _online = (((now - lastReceivedFromUpstream) < (ZT_PEER_ACTIVITY_TIMEOUT / 16))||(RR->topology->amUpstream()));
- if (oldOnline != _online)
- postEvent(tptr,_online ? ZT_EVENT_ONLINE : ZT_EVENT_OFFLINE);
- } catch ( ... ) {
-diff --git a/node/RingBuffer.hpp b/node/RingBuffer.hpp
-index dab81b9e..0d90152b 100644
---- a/node/RingBuffer.hpp
-+++ b/node/RingBuffer.hpp
-@@ -72,6 +72,11 @@ public:
- memset(buf, 0, sizeof(T) * size);
- }
-
-+ ~RingBuffer()
-+ {
-+ delete [] buf;
-+ }
-+
- /**
- * @return A pointer to the underlying buffer
- */
-diff --git a/node/Switch.cpp b/node/Switch.cpp
-index 74c22d33..3e4f53b4 100644
---- a/node/Switch.cpp
-+++ b/node/Switch.cpp
-@@ -425,16 +425,16 @@ void Switch::onLocalEthernet(void *tPtr,const SharedPtr &network,const
- from.appendTo(outp);
- outp.append((uint16_t)etherType);
- outp.append(data,len);
-- if (!network->config().disableCompression())
-- outp.compress();
-+ //if (!network->config().disableCompression())
-+ // outp.compress();
- aqm_enqueue(tPtr,network,outp,true,qosBucket);
- } else {
- Packet outp(toZT,RR->identity.address(),Packet::VERB_FRAME);
- outp.append(network->id());
- outp.append((uint16_t)etherType);
- outp.append(data,len);
-- if (!network->config().disableCompression())
-- outp.compress();
-+ //if (!network->config().disableCompression())
-+ // outp.compress();
- aqm_enqueue(tPtr,network,outp,true,qosBucket);
- }
-
-@@ -532,7 +532,7 @@ void Switch::aqm_enqueue(void *tPtr, const SharedPtr &network, Packet &
- TXQueueEntry *txEntry = new TXQueueEntry(dest,RR->node->now(),packet,encrypt);
-
- ManagedQueue *selectedQueue = nullptr;
-- for (int i=0; ioldQueues.size()) { // search old queues first (I think this is best since old would imply most recent usage of the queue)
- if (nqcb->oldQueues[i]->id == qosBucket) {
- selectedQueue = nqcb->oldQueues[i];
-@@ -568,7 +568,7 @@ void Switch::aqm_enqueue(void *tPtr, const SharedPtr &network, Packet &
- {
- // DEBUG_INFO("too many enqueued packets (%d), finding packet to drop", nqcb->_currEnqueuedPackets);
- int maxQueueLength = 0;
-- for (int i=0; ioldQueues.size()) {
- if (nqcb->oldQueues[i]->byteLength > maxQueueLength) {
- maxQueueLength = nqcb->oldQueues[i]->byteLength;
-diff --git a/osdep/OSUtils.cpp b/osdep/OSUtils.cpp
-index 676f6335..2834fd22 100644
---- a/osdep/OSUtils.cpp
-+++ b/osdep/OSUtils.cpp
-@@ -452,6 +452,7 @@ std::string OSUtils::platformDefaultHomePath()
- #endif // __UNIX_LIKE__ or not...
- }
-
-+#ifndef OMIT_JSON_SUPPORT
- // Inline these massive JSON operations in one place only to reduce binary footprint and compile time
- nlohmann::json OSUtils::jsonParse(const std::string &buf) { return nlohmann::json::parse(buf.c_str()); }
- std::string OSUtils::jsonDump(const nlohmann::json &j,int indentation) { return j.dump(indentation); }
-@@ -543,6 +544,8 @@ std::string OSUtils::jsonBinFromHex(const nlohmann::json &jv)
- return std::string();
- }
-
-+#endif // OMIT_JSON_SUPPORT
-+
- // Used to convert HTTP header names to ASCII lower case
- const unsigned char OSUtils::TOLOWER_TABLE[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff };
-
-diff --git a/osdep/OSUtils.hpp b/osdep/OSUtils.hpp
-index 2c4283b0..afdb1bf1 100644
---- a/osdep/OSUtils.hpp
-+++ b/osdep/OSUtils.hpp
-@@ -55,7 +55,9 @@
- #endif
- #endif
-
-+#ifndef OMIT_JSON_SUPPORT
- #include "../ext/json/json.hpp"
-+#endif
-
- namespace ZeroTier {
-
-@@ -284,6 +286,7 @@ public:
- */
- static std::string platformDefaultHomePath();
-
-+#ifndef OMIT_JSON_SUPPORT
- static nlohmann::json jsonParse(const std::string &buf);
- static std::string jsonDump(const nlohmann::json &j,int indentation = 1);
- static uint64_t jsonInt(const nlohmann::json &jv,const uint64_t dfl);
-@@ -291,6 +294,7 @@ public:
- static bool jsonBool(const nlohmann::json &jv,const bool dfl);
- static std::string jsonString(const nlohmann::json &jv,const char *dfl);
- static std::string jsonBinFromHex(const nlohmann::json &jv);
-+#endif // OMIT_JSON_SUPPORT
-
- private:
- static const unsigned char TOLOWER_TABLE[256];
From a108609c3d6175a4e84cc03eba14218686e40982 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Mon, 13 May 2019 15:58:45 -0700
Subject: [PATCH 10/78] Added function in dist.sh to generate
markdown-formatted changelogs
---
CHANGELOG.md | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++
dist.sh | 19 +++++++++
2 files changed, 137 insertions(+)
create mode 100644 CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..2120c5d
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,118 @@
+## [1.3.1-hb0] - 2019-05-13
+***
+- Minor tweaks for Homebrew-core compliance
+## [1.3.1] - 2019-05-12
+***
+- Minor build-related improvements. No API or core functionality changes
+## [1.3.0] - 2019-04-22
+***
+- Added new callback API. Significant improvements to performance and reliability
+## [1.2.0] - 2019-03-01
+***
+- ZeroTier core version upgrade to 1.2.12, major bugfixes, improved platform compatibility, revamped build process
+## [1.1.6] - 2018-02-08
+***
+- Improved concurrent thread performance
+## [1.1.4] - 2017-06-06
+***
+- Important Dual-stack IPv4/IPv6 bug fix
+## [1.1.3] - 2017-06-06
+***
+- Updated picoTCP to 1.4.0, improved selftest
+## [1.1.2] - 2017-06-06
+***
+- Minor ZTO source update, improved selftest, documentation
+## [1.1.1] - 2017-06-06
+***
+- Updated ZTO source to 1.2.4, bug fixes
+## [1.1.0] - 2017-06-06
+***
+- Added new socket multiplexing logic, significant restructuring of picoTCP stack driver
+## [1.0.0] - 2017-06-06
+***
+- Refactored library structure. Dynamic loading of stack no longer required. lwIP Support dropped
+## [0.9.0] - 2017-06-06
+***
+- Updated ZTO source for tptr feature
+## [0.8.0] - 2017-06-06
+***
+- Updated ZTO source to 1.2.0, bug fixes
+## [0.7.0] - 2017-06-06
+***
+- Updated ZTO source to 1.1.17, updated documentation, bug fixes
+## [0.6.2] - 2017-06-06
+***
+- Updated ZTO source for reliability
+## [0.6.1] - 2017-06-06
+***
+- Stack driver support for IPv4 XOR IPv6
+## [0.6.0] - 2017-06-06
+***
+- Updated ZTO source to 1.1.14
+## [0.5.0] - 2017-06-06
+***
+- Implemented driver for picoTCP network stack
+## [0.4.2] - 2017-06-06
+***
+- IPv6-related fixes
+## [0.4.1] - 2017-06-06
+***
+- Added IPv6 support to lwIP stack driver
+## [0.4.0] - 2017-06-06
+***
+- Upgraded to lwIP 2.0.0
+## [0.3.5] - 2017-06-06
+***
+- Introduced prettier and less complex Swift API
+## [0.3.4] - 2017-06-06
+***
+- Improved debugging traces
+## [0.3.3] - 2017-06-06
+***
+- Improved API parameter naming consistency
+## [0.3.2] - 2017-06-06
+***
+- Improved proxy server controls
+## [0.3.1] - 2017-06-06
+***
+- API consistency improvements
+## [0.3.0] - 2017-06-06
+***
+- Updated ZTO source to 1.1.4
+## [0.2.1] - 2017-06-06
+***
+- Normalized zt_ API naming conventions
+## [0.2.0] - 2017-06-06
+***
+- Old netcon project moved into its own repo
+
+
+[1.3.1-hb0]: https://github.com/zerotier/libzt/compare/1.3.1..1.3.1-hb0
+[1.3.1]: https://github.com/zerotier/libzt/compare/1.3.0..1.3.1
+[1.3.0]: https://github.com/zerotier/libzt/compare/1.2.0..1.3.0
+[1.2.0]: https://github.com/zerotier/libzt/compare/1.1.6..1.2.0
+[1.1.6]: https://github.com/zerotier/libzt/compare/1.1.4..1.1.6
+[1.1.4]: https://github.com/zerotier/libzt/compare/1.1.3..1.1.4
+[1.1.3]: https://github.com/zerotier/libzt/compare/1.1.2..1.1.3
+[1.1.2]: https://github.com/zerotier/libzt/compare/1.1.1..1.1.2
+[1.1.1]: https://github.com/zerotier/libzt/compare/1.1.0..1.1.1
+[1.1.0]: https://github.com/zerotier/libzt/compare/1.0.0..1.1.0
+[1.0.0]: https://github.com/zerotier/libzt/compare/0.9.0..1.0.0
+[0.9.0]: https://github.com/zerotier/libzt/compare/0.8.0..0.9.0
+[0.8.0]: https://github.com/zerotier/libzt/compare/0.7.0..0.8.0
+[0.7.0]: https://github.com/zerotier/libzt/compare/0.6.2..0.7.0
+[0.6.2]: https://github.com/zerotier/libzt/compare/0.6.1..0.6.2
+[0.6.1]: https://github.com/zerotier/libzt/compare/0.6.0..0.6.1
+[0.6.0]: https://github.com/zerotier/libzt/compare/0.5.0..0.6.0
+[0.5.0]: https://github.com/zerotier/libzt/compare/0.4.2..0.5.0
+[0.4.2]: https://github.com/zerotier/libzt/compare/0.4.1..0.4.2
+[0.4.1]: https://github.com/zerotier/libzt/compare/0.4.0..0.4.1
+[0.4.0]: https://github.com/zerotier/libzt/compare/0.3.5..0.4.0
+[0.3.5]: https://github.com/zerotier/libzt/compare/0.3.4..0.3.5
+[0.3.4]: https://github.com/zerotier/libzt/compare/0.3.3..0.3.4
+[0.3.3]: https://github.com/zerotier/libzt/compare/0.3.2..0.3.3
+[0.3.2]: https://github.com/zerotier/libzt/compare/0.3.1..0.3.2
+[0.3.1]: https://github.com/zerotier/libzt/compare/0.3.0..0.3.1
+[0.3.0]: https://github.com/zerotier/libzt/compare/0.2.1..0.3.0
+[0.2.1]: https://github.com/zerotier/libzt/compare/0.2.0..0.2.1
+[0.2.0]: https://github.com/zerotier/libzt/compare/e073a35b72781a8947e197419677e82b9ed9f9bc..0.2.0
diff --git a/dist.sh b/dist.sh
index 0bb7ba0..f850519 100755
--- a/dist.sh
+++ b/dist.sh
@@ -598,6 +598,25 @@ bdist()
package_everything "release"
}
+# Generate a markdown CHANGELOG from git-log
+update_changelog()
+{
+ first_commit=$(git rev-list --max-parents=0 HEAD)
+ git for-each-ref --sort=-refname --format="## [%(refname:short)] - %(taggerdate:short) &(newline)*** &(newline)- %(subject) %(body)" refs/tags > CHANGELOG.md
+ gsed -i '''s/\&(newline)/\n/' CHANGELOG.md # replace first instance
+ gsed -i '''s/\&(newline)/\n/' CHANGELOG.md # replace second instance
+ echo -e "\n" >> CHANGELOG.md
+ for curr_tag in $(git tag -l --sort=-v:refname)
+ do
+ prev_tag=$(git describe --abbrev=0 ${curr_tag}^)
+ if [ -z "${prev_tag}" ]
+ then
+ prev_tag=${first_commit}
+ fi
+ echo "[${curr_tag}]: https://github.com/zerotier/libzt/compare/${prev_tag}..${curr_tag}" >> CHANGELOG.md
+ done
+}
+
# List all functions in this script (just for convenience)
list()
{
From 24ee19183931b40e1c9547a2b7ff87f5f0dc820b Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 14 May 2019 11:12:16 -0700
Subject: [PATCH 11/78] Removed submodule lwip and lwip-contrib
---
.gitmodules | 10 ----------
ext/lwip | 1 -
ext/lwip-contrib | 1 -
3 files changed, 12 deletions(-)
delete mode 160000 ext/lwip
delete mode 160000 ext/lwip-contrib
diff --git a/.gitmodules b/.gitmodules
index e55c450..19f0e34 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,13 +1,3 @@
-[submodule "zto"]
- path = zto
- url = https://github.com/zerotier/ZeroTierOne.git
- branch = dev
-[submodule "ext/lwip"]
- path = ext/lwip
- url = https://git.savannah.nongnu.org/git/lwip.git
-[submodule "ext/lwip-contrib"]
- path = ext/lwip-contrib
- url = https://git.savannah.nongnu.org/git/lwip/lwip-contrib.git
[submodule "ext/ZeroTierOne"]
path = ext/ZeroTierOne
url = https://github.com/zerotier/ZeroTierOne.git
diff --git a/ext/lwip b/ext/lwip
deleted file mode 160000
index 159e31b..0000000
--- a/ext/lwip
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 159e31b689577dbf69cf0683bbaffbd71fa5ee10
diff --git a/ext/lwip-contrib b/ext/lwip-contrib
deleted file mode 160000
index 35b011d..0000000
--- a/ext/lwip-contrib
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 35b011d4cf4c4b480f8859c456587a884ec9d287
From 3562625cd938c1eaa8a1ce45507db9be83c1a4cf Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 14 May 2019 11:35:41 -0700
Subject: [PATCH 12/78] Added forked joseph-henry/lwip as new lwip submodule
---
.gitmodules | 3 +++
ext/lwip | 1 +
2 files changed, 4 insertions(+)
create mode 160000 ext/lwip
diff --git a/.gitmodules b/.gitmodules
index 19f0e34..8defb23 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "ext/ZeroTierOne"]
path = ext/ZeroTierOne
url = https://github.com/zerotier/ZeroTierOne.git
+[submodule "ext/lwip"]
+ path = ext/lwip
+ url = https://github.com/joseph-henry/lwip.git
diff --git a/ext/lwip b/ext/lwip
new file mode 160000
index 0000000..b3a9394
--- /dev/null
+++ b/ext/lwip
@@ -0,0 +1 @@
+Subproject commit b3a939417e936a933ba287aee79eff8662198cad
From d5b064623e1161196fd5bc14668e83bec2c27717 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 14 May 2019 11:56:01 -0700
Subject: [PATCH 13/78] Added forked joseph-henry/lwip-contrib as new
lwip-contrib submodule
---
.gitmodules | 3 +++
ext/lwip-contrib | 1 +
2 files changed, 4 insertions(+)
create mode 160000 ext/lwip-contrib
diff --git a/.gitmodules b/.gitmodules
index 8defb23..7862383 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,3 +4,6 @@
[submodule "ext/lwip"]
path = ext/lwip
url = https://github.com/joseph-henry/lwip.git
+[submodule "ext/lwip-contrib"]
+ path = ext/lwip-contrib
+ url = https://github.com/joseph-henry/lwip-contrib.git
diff --git a/ext/lwip-contrib b/ext/lwip-contrib
new file mode 160000
index 0000000..35b011d
--- /dev/null
+++ b/ext/lwip-contrib
@@ -0,0 +1 @@
+Subproject commit 35b011d4cf4c4b480f8859c456587a884ec9d287
From ecd10fa46e7587cb04cc52d18df73014f2a78d2c Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Wed, 15 May 2019 10:31:16 -0700
Subject: [PATCH 14/78] Added Homebrew blurb, fixed test example, removed
patches from Makefile
---
Makefile | 4 ++--
README.md | 30 ++++++++++++++++++++++++++++--
test/simple.cpp | 13 +++++++------
3 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index 77ea515..c5be365 100644
--- a/Makefile
+++ b/Makefile
@@ -22,8 +22,8 @@ update:
# Patch submodules (issue update first)
patch:
- -cd ext/lwip; git apply ../lwip.patch;
- -cd ext/lwip-contrib; git apply ../lwip-contrib.patch;
+ #-cd ext/lwip; git apply ../lwip.patch;
+ #-cd ext/lwip-contrib; git apply ../lwip-contrib.patch;
#-cd ext/ZeroTierOne; git apply ../ZeroTierOne.patch;
# Target-specific clean
diff --git a/README.md b/README.md
index 99adf66..c74e2d4 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,26 @@ The ZeroTier SDK is composed of two libraries: `libztcore` which is the platfor
-For a complete example, see [test/simple.cpp](test/simple.cpp) or [test/example.cpp](test/example.cpp). With no error checking, a paraphrased example is as follows:
+## Downloads / Installation
+
+ Tarballs:
+
+ - [libzt-release.tar.gz](https://download.zerotier.com/dist/sdk/libzt-1.3.0-release.tar.gz) // [libzt-debug.tar.gz](https://download.zerotier.com/dist/sdk/libzt-1.3.0-debug.tar.gz) // [libzt-source.tar.gz](https://download.zerotier.com/dist/sdk/libzt-1.3.0-source.tar.gz)
+
+Homebrew
+
+```
+brew install libzt
+```
+
+***
+
+
+
+## Example
+
+ - Complete example: [test/simple.cpp](test/simple.cpp)
+ - Slightly more thorough example: [test/example.cpp](test/example.cpp)
```
#include "ZeroTier.h"
@@ -38,11 +57,18 @@ int main()
...
```
+After you've created a virtual network and added its `nwid` to the sample code, run:
+
+```
+clang++ example.cpp -o example -lzt
+./example
+```
+
The complete API specification can be found here: [API.md](API.md)
***
-## Build
+## Build from source
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:
diff --git a/test/simple.cpp b/test/simple.cpp
index 7f0bdbd..6c39833 100644
--- a/test/simple.cpp
+++ b/test/simple.cpp
@@ -1,10 +1,10 @@
+#include
+
#include
#include
#include
#include
-#include "ZeroTier.h"
-
bool node_ready = false;
bool network_ready = false;
@@ -49,20 +49,21 @@ int main()
// Set up ZeroTier service and wai for callbacks
int port = 9994;
- int nwid = 0x0123456789abcdef;
- zts_start("test/path", &myZeroTierEventCallback, port);
+ uint64_t nwid = 0x0123456789abcdef;
+ zts_start("zt_config/path", &myZeroTierEventCallback, port);
printf("Waiting for node to come online...\n");
while (!node_ready) { sleep(1); }
zts_join(nwid);
printf("Joined virtual network. Requesting configuration...\n");
while (!network_ready) { sleep(1); }
+ printf("I am %llx\n", zts_get_node_id());
// Socket API example
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");
+ printf("error connecting to remote host (%s)\n", remoteIp);
}
if ((err = zts_write(fd, str, strlen(str))) < 0) {
printf("error writing to socket\n");
@@ -70,4 +71,4 @@ int main()
zts_close(fd);
zts_stop();
return 0;
-}
\ No newline at end of file
+}
From 48d8dccff83ce0c0952c5c0059a34de349cace41 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Thu, 16 May 2019 14:45:32 -0700
Subject: [PATCH 15/78] Updated submodule revision for lwip to include errno
patch
---
ext/lwip | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ext/lwip b/ext/lwip
index b3a9394..3bb5b07 160000
--- a/ext/lwip
+++ b/ext/lwip
@@ -1 +1 @@
-Subproject commit b3a939417e936a933ba287aee79eff8662198cad
+Subproject commit 3bb5b0722ea01edd8dee439ba62eeee788d2894e
From dcfd4b032a3dcd85a65c79418463b812e84a5f37 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 11 Jun 2019 16:31:59 -0700
Subject: [PATCH 16/78] Minor build fixes for Windows
---
Makefile | 6 +++---
src/Controls.hpp | 4 ++++
src/Sockets.cpp | 7 -------
src/VirtualTap.cpp | 6 ++++++
src/lwipDriver.cpp | 2 +-
5 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
index c5be365..6b3ff5d 100644
--- a/Makefile
+++ b/Makefile
@@ -5,9 +5,9 @@ else
DIST_BUILD_SCRIPT := ./dist.sh
endif
-EXECUTABLES = cmake
-build_reqs := $(foreach exec,$(EXECUTABLES),\
- $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
+#EXECUTABLES = cmake
+#build_reqs := $(foreach exec,$(EXECUTABLES),\
+# $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
.PHONY: list
list:
diff --git a/src/Controls.hpp b/src/Controls.hpp
index 4b3870e..c78246b 100644
--- a/src/Controls.hpp
+++ b/src/Controls.hpp
@@ -33,6 +33,10 @@
#ifndef LIBZT_CONTROLS_HPP
#define LIBZT_CONTROLS_HPP
+#ifdef _WIN32
+#include
+#endif
+
namespace ZeroTier {
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/Sockets.cpp b/src/Sockets.cpp
index df65521..844c90a 100644
--- a/src/Sockets.cpp
+++ b/src/Sockets.cpp
@@ -38,16 +38,9 @@
#include "ZeroTierConstants.h"
#include "Options.h"
#include "Debug.hpp"
-#include "Controls.hpp"
#ifdef SDK_JNI
#include
-#ifndef _MSC_VER
- //#include
- //#include
- //#include
- //#include
-#endif
#endif
namespace ZeroTier {
diff --git a/src/VirtualTap.cpp b/src/VirtualTap.cpp
index a0dd2cb..190b599 100644
--- a/src/VirtualTap.cpp
+++ b/src/VirtualTap.cpp
@@ -79,7 +79,9 @@ VirtualTap::VirtualTap(
memset(vtap_full_name, 0, sizeof(vtap_full_name));
snprintf(vtap_full_name, sizeof(vtap_full_name), "libzt%llx", (unsigned long long)_nwid);
_dev = vtap_full_name;
+#ifndef _WIN32
::pipe(_shutdownSignalPipe);
+#endif
// Start virtual tap thread and stack I/O loops
_thread = Thread::start(this);
}
@@ -90,13 +92,17 @@ VirtualTap::~VirtualTap()
nd->nwid = _nwid;
postEvent(ZTS_EVENT_NETWORK_DOWN, (void*)nd);
_run = false;
+#ifndef _WIN32
::write(_shutdownSignalPipe[1],"\0",1);
+#endif
_phy.whack();
lwip_remove_netif(netif);
netif = NULL;
Thread::join(_thread);
+#ifndef _WIN32
::close(_shutdownSignalPipe[0]);
::close(_shutdownSignalPipe[1]);
+#endif
}
void VirtualTap::lastConfigUpdate(uint64_t lastConfigUpdateTime)
diff --git a/src/lwipDriver.cpp b/src/lwipDriver.cpp
index f69d28d..db8dffe 100644
--- a/src/lwipDriver.cpp
+++ b/src/lwipDriver.cpp
@@ -155,7 +155,7 @@ void lwip_driver_init()
#if defined(_WIN32)
sys_init(); // Required for win32 init of critical sections
#endif
- void *st = sys_thread_new(ZTS_LWIP_DRIVER_THREAD_NAME, main_lwip_driver_loop,
+ void *st = (void*)sys_thread_new(ZTS_LWIP_DRIVER_THREAD_NAME, main_lwip_driver_loop,
NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
}
From a514508c20cdb3d9b1a5dcf76ef9fdcb7ae446be Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Mon, 17 Jun 2019 14:31:15 -0700
Subject: [PATCH 17/78] Updated lwip-contrib submodule revision
---
ext/lwip-contrib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ext/lwip-contrib b/ext/lwip-contrib
index 35b011d..4fd612c 160000
--- a/ext/lwip-contrib
+++ b/ext/lwip-contrib
@@ -1 +1 @@
-Subproject commit 35b011d4cf4c4b480f8859c456587a884ec9d287
+Subproject commit 4fd612c9c72dfcd1db6618bd59c1a17d9f5b55f8
From 9f93552740fc3117e2a0fed80a46022c13408221 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Mon, 17 Jun 2019 16:03:30 -0700
Subject: [PATCH 18/78] Minor changes for Windows build
---
include/ZeroTier.h | 51 +++++++++++++++++++++++++---------------------
1 file changed, 28 insertions(+), 23 deletions(-)
diff --git a/include/ZeroTier.h b/include/ZeroTier.h
index a60849b..bb22d8d 100644
--- a/include/ZeroTier.h
+++ b/include/ZeroTier.h
@@ -35,7 +35,10 @@
#include "ZeroTierConstants.h"
-#include
+#if defined(_MSC_VER)
+#include
+typedef int ssize_t;
+#endif
#ifdef _WIN32
#ifdef ADD_EXPORTS
@@ -92,7 +95,11 @@ typedef uint16_t zts_in_port_t;
typedef uint8_t zts_sa_family_t;
struct zts_in_addr {
+#if defined(_WIN32)
+ zts_in_addr_t S_addr;
+#else
zts_in_addr_t s_addr;
+#endif
};
struct zts_in6_addr {
@@ -105,34 +112,34 @@ struct zts_in6_addr {
struct zts_sockaddr_in {
uint8_t sin_len;
- zts_sa_family_t sin_family;
- zts_in_port_t sin_port;
- struct zts_in_addr sin_addr;
+ zts_sa_family_t sin_family;
+ zts_in_port_t sin_port;
+ struct zts_in_addr sin_addr;
#define SIN_ZERO_LEN 8
- char sin_zero[SIN_ZERO_LEN];
+ char sin_zero[SIN_ZERO_LEN];
};
struct zts_sockaddr_in6 {
- uint8_t sin6_len; /* length of this structure */
- zts_sa_family_t sin6_family; /* AF_INET6 */
- zts_in_port_t sin6_port; /* Transport layer port # */
- uint32_t sin6_flowinfo; /* IPv6 flow information */
- struct zts_in6_addr sin6_addr; /* IPv6 address */
- uint32_t sin6_scope_id; /* Set of interfaces for scope */
+ uint8_t sin6_len; // length of this structure
+ zts_sa_family_t sin6_family; // AF_INET6
+ zts_in_port_t sin6_port; // Transport layer port #
+ uint32_t sin6_flowinfo; // IPv6 flow information
+ struct zts_in6_addr sin6_addr; // IPv6 address
+ uint32_t sin6_scope_id; // Set of interfaces for scope
};
struct zts_sockaddr {
- uint8_t sa_len;
+ uint8_t sa_len;
zts_sa_family_t sa_family;
- char sa_data[14];
+ char sa_data[14];
};
struct zts_sockaddr_storage {
- uint8_t s2_len;
+ uint8_t s2_len;
zts_sa_family_t ss_family;
- char s2_data1[2];
- uint32_t s2_data2[3];
- uint32_t s2_data3[3];
+ char s2_data1[2];
+ uint32_t s2_data2[3];
+ uint32_t s2_data3[3];
};
#if !defined(zts_iovec)
@@ -156,16 +163,14 @@ struct zts_msghdr {
* Structure used for manipulating linger option.
*/
struct zts_linger {
- int l_onoff; /* option on/off */
- int l_linger; /* linger time in seconds */
+ int l_onoff; // option on/off
+ int l_linger; // linger time in seconds
};
-/*
-typedef struct fd_set
+typedef struct zts_fd_set
{
unsigned char fd_bits [(FD_SETSIZE+7)/8];
-} fd_set;
-*/
+} zts_fd_set;
#ifdef __cplusplus
}
From f6f79b6305dfe634fdb07a2381a25e6f379a0227 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Mon, 17 Jun 2019 16:46:17 -0700
Subject: [PATCH 19/78] Minor changes for Windows build
---
include/ZeroTier.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/include/ZeroTier.h b/include/ZeroTier.h
index bb22d8d..1d78588 100644
--- a/include/ZeroTier.h
+++ b/include/ZeroTier.h
@@ -76,11 +76,6 @@ typedef int socklen_t;
#include
#endif
-#if defined(_MSC_VER)
-#include
-typedef SSIZE_T ssize_t;
-#endif
-
//namespace ZeroTier {
#ifdef __cplusplus
From 17e5b8172d9d227af147955c126bbab0fc800fdb Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Tue, 18 Jun 2019 11:06:05 -0700
Subject: [PATCH 20/78] Minor changes for Windows build
---
src/Controls.cpp | 18 ++++++++++++------
src/Service.cpp | 1 -
src/VirtualTap.hpp | 4 ----
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/Controls.cpp b/src/Controls.cpp
index c2b8152..7265f09 100644
--- a/src/Controls.cpp
+++ b/src/Controls.cpp
@@ -94,9 +94,6 @@ bool _run_lwip_tcpip = false;
//bool _startupError = false;
-pthread_t service_thread;
-pthread_t callback_thread;
-
// Global reference to ZeroTier service
OneService *service;
@@ -272,7 +269,7 @@ int __zts_can_perform_service_operation()
void _api_sleep(int interval_ms)
{
-#if defined(_WIN32)
+#if defined (_WIN32)
Sleep(interval_ms);
#else
struct timespec sleepValue = {0};
@@ -283,11 +280,14 @@ void _api_sleep(int interval_ms)
int _change_nice(int increment)
{
+#ifndef _WIN32
if (increment == 0) {
return 0;
}
int priority = getpriority(PRIO_PROCESS, 0);
return setpriority(PRIO_PROCESS, 0, priority+increment);
+#endif
+ return 0;
}
//////////////////////////////////////////////////////////////////////////////
@@ -406,7 +406,10 @@ void *_zts_run_service(void *arg)
// TODO: Find a more elegant solution
_api_sleep(ZTS_CALLBACK_PROCESSING_INTERVAL*2);
_run_callbacks = false;
+#ifndef _WIN32
pthread_exit(0);
+#endif
+ return NULL;
}
#ifdef __cplusplus
@@ -566,13 +569,16 @@ int zts_start(
WSAStartup(MAKEWORD(2, 2), &wsaData);
HANDLE serviceThread = CreateThread(NULL, 0, _zts_run_service, (void*)params, 0, NULL);
HANDLE callbackThread = CreateThread(NULL, 0, _zts_run_callbacks, NULL, 0, NULL);
-#endif
+#else
+ pthread_t service_thread;
+ pthread_t callback_thread;
if ((err = pthread_create(&service_thread, NULL, _zts_run_service, NULL)) != 0) {
retval = err;
}
if ((err = pthread_create(&callback_thread, NULL, _zts_run_callbacks, NULL)) != 0) {
retval = err;
}
+#endif
#if defined(__linux__)
pthread_setname_np(service_thread, ZTS_SERVICE_THREAD_NAME);
pthread_setname_np(callback_thread, ZTS_EVENT_CALLBACK_THREAD_NAME);
@@ -674,7 +680,7 @@ int zts_restart()
_userCallbackMethodRef = _tmpUserCallbackMethodRef;
return zts_start(tmpPath.c_str(), NULL, tmpPort);
#else
- return zts_start(tmpPath.c_str(), _tmpUserEventCallbackFunc, tmpPort);
+ return ::zts_start(tmpPath.c_str(), _tmpUserEventCallbackFunc, tmpPort);
#endif
}
#ifdef SDK_JNI
diff --git a/src/Service.cpp b/src/Service.cpp
index ebf8277..effb198 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -27,7 +27,6 @@
#include
#include
#include
-#include
#include
#include
-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 network 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)
+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 network stack and virtual link are exclusive to your app and traffic is fully encrypted end-to-end.
-The ZeroTier source code is open source and is licensed under the GNU GPL v3 (not LGPL). If you'd like to embed it in a closed-source commercial product or appliance, please e-mail contact@zerotier.com to discuss commercial licensing. Otherwise it can be used for free.
+ZeroTier is licensed under the BSL version 1.1. See LICENSE.txt and the ZeroTier pricing page for details. 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.).
diff --git a/LICENSE.GPL-3 b/LICENSE.GPL-3
deleted file mode 100644
index 94a9ed0..0000000
--- a/LICENSE.GPL-3
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..9784015
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,149 @@
+-----------------------------------------------------------------------------
+
+Business Source License 1.1
+
+License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
+"Business Source License" is a trademark of MariaDB Corporation Ab.
+
+-----------------------------------------------------------------------------
+
+Parameters
+
+Licensor: ZeroTier, Inc.
+Licensed Work: ZeroTier Network Virtualization Engine 1.4.4
+ The Licensed Work is (c)2019 ZeroTier, Inc.
+Additional Use Grant: You may make use of the Licensed Work, provided you
+ do not use it in any of the following ways:
+
+ * Sell hosted ZeroTier services as a "SaaS" Product
+
+ (1) Operate or sell access to ZeroTier root servers,
+ network controllers, or authorization key or certificate
+ generation components of the Licensed Work as a
+ for-profit service, regardless of whether the use of
+ these components is sold alone or is bundled with other
+ services. Note that this does not apply to the use of
+ ZeroTier behind the scenes to operate a service not
+ related to ZeroTier network administration.
+
+ * Create Non-Open-Source Commercial Derviative Works
+
+ (2) Link or directly include the Licensed Work in a
+ commercial or for-profit application or other product
+ not distributed under an Open Source Initiative (OSI)
+ compliant license. See: https://opensource.org/licenses
+
+ (3) Remove the name, logo, copyright, or other branding
+ material from the Licensed Work to create a "rebranded"
+ or "white labeled" version to distribute as part of
+ any commercial or for-profit product or service.
+
+ * Certain Government Uses
+
+ (4) Use or deploy the Licensed Work in a government
+ setting in support of any active government function
+ or operation with the exception of the following:
+ physical or mental health care, family and social
+ services, social welfare, senior care, child care, and
+ the care of persons with disabilities.
+
+Change Date: 2023-01-01
+
+Change License: Apache License version 2.0 as published by the Apache
+ Software Foundation
+ https://www.apache.org/licenses/
+
+Alternative Licensing
+
+If you would like to use the Licensed Work in any way that conflicts with
+the stipulations of the Additional Use Grant, contact ZeroTier, Inc. to
+obtain an alternative commercial license.
+
+Visit us on the web at: https://www.zerotier.com/
+
+Notice
+
+The Business Source License (this document, or the "License") is not an Open
+Source license. However, the Licensed Work will eventually be made available
+under an Open Source License, as stated in this License.
+
+For more information on the use of the Business Source License for ZeroTier
+products, please visit our pricing page which contains license details and
+and license FAQ: https://zerotier.com/pricing
+
+For more information on the use of the Business Source License generally,
+please visit the Adopting and Developing Business Source License FAQ at
+https://mariadb.com/bsl-faq-adopting.
+
+-----------------------------------------------------------------------------
+
+Business Source License 1.1
+
+Terms
+
+The Licensor hereby grants you the right to copy, modify, create derivative
+works, redistribute, and make non-production use of the Licensed Work. The
+Licensor may make an Additional Use Grant, above, permitting limited
+production use.
+
+Effective on the Change Date, or the fourth anniversary of the first publicly
+available distribution of a specific version of the Licensed Work under this
+License, whichever comes first, the Licensor hereby grants you rights under
+the terms of the Change License, and the rights granted in the paragraph
+above terminate.
+
+If your use of the Licensed Work does not comply with the requirements
+currently in effect as described in this License, you must purchase a
+commercial license from the Licensor, its affiliated entities, or authorized
+resellers, or you must refrain from using the Licensed Work.
+
+All copies of the original and modified Licensed Work, and derivative works
+of the Licensed Work, are subject to this License. This License applies
+separately for each version of the Licensed Work and the Change Date may vary
+for each version of the Licensed Work released by Licensor.
+
+You must conspicuously display this License on each original or modified copy
+of the Licensed Work. If you receive the Licensed Work in original or
+modified form from a third party, the terms and conditions set forth in this
+License apply to your use of that work.
+
+Any use of the Licensed Work in violation of this License will automatically
+terminate your rights under this License for the current and all other
+versions of the Licensed Work.
+
+This License does not grant you any right in any trademark or logo of
+Licensor or its affiliates (provided that you may use a trademark or logo of
+Licensor as expressly required by this License).
+
+TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
+AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
+EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
+TITLE.
+
+-----------------------------------------------------------------------------
+
+MariaDB hereby grants you permission to use this License’s text to license
+your works, and to refer to it using the trademark "Business Source License",
+as long as you comply with the Covenants of Licensor below.
+
+Covenants of Licensor
+
+In consideration of the right to use this License’s text and the "Business
+Source License" name and trademark, Licensor covenants to MariaDB, and to all
+other recipients of the licensed work to be provided by Licensor:
+
+1. To specify as the Change License the GPL Version 2.0 or any later version,
+ or a license that is compatible with GPL Version 2.0 or a later version,
+ where "compatible" means that software provided under the Change License can
+ be included in a program with software provided under GPL Version 2.0 or a
+ later version. Licensor may specify additional Change Licenses without
+ limitation.
+
+2. To either: (a) specify an additional grant of rights to use that does not
+ impose any additional restriction on the right granted in this License, as
+ the Additional Use Grant; or (b) insert the text "None".
+
+3. To specify a Change Date.
+
+4. Not to modify this License in any other way.
\ No newline at end of file
diff --git a/dist.sh b/dist.sh
index ad1e388..c7dfa17 100755
--- a/dist.sh
+++ b/dist.sh
@@ -510,7 +510,7 @@ package_licenses()
mkdir -p $DEST_DIR
cp $CURR_DIR/ext/lwip/COPYING $DEST_DIR/LWIP-LICENSE.BSD
cp $CURR_DIR/ext/concurrentqueue/LICENSE.md $DEST_DIR/CONCURRENTQUEUE-LICENSE.BSD
- cp $CURR_DIR/LICENSE.GPL-3 $DEST_DIR/ZEROTIER-LICENSE.GPL-3
+ cp $CURR_DIR/LICENSE.txt $DEST_DIR/ZEROTIER-LICENSE.BSL-1.1
cp $CURR_DIR/include/net/ROUTE_H-LICENSE.APSL $DEST_DIR/ROUTE_H-LICENSE.APSL
cp $CURR_DIR/include/net/ROUTE_H-LICENSE $DEST_DIR/ROUTE_H-LICENSE
}
@@ -572,7 +572,7 @@ package_everything()
doc/errno.h
licenses/LWIP-LICENSE.BSD
licenses/CONCURRENTQUEUE-LICENSE.BSD
- licenses/ZEROTIER-LICENSE.GPL-3
+ licenses/ZEROTIER-LICENSE.BSL-1.1
licenses/ROUTE_H-LICENSE.APSL
licenses/ROUTE_H-LICENSE
licenses/LWIP-LICENSE.BSD"
diff --git a/ext/lwip.patch b/ext/lwip.patch
index 6ef5d1c..d0ef7c8 100644
--- a/ext/lwip.patch
+++ b/ext/lwip.patch
@@ -1,18 +1,87 @@
-diff --git a/src/include/lwip/errno.h b/src/include/lwip/errno.h
-index 48d6b539..9f59afc8 100644
---- a/src/include/lwip/errno.h
-+++ b/src/include/lwip/errno.h
-@@ -174,7 +174,12 @@ extern "C" {
- #define EMEDIUMTYPE 124 /* Wrong medium type */
+diff --git a/src/api/sockets.c b/src/api/sockets.c
+index 2d231739..a0c24829 100644
+--- a/src/api/sockets.c
++++ b/src/api/sockets.c
+@@ -38,6 +38,7 @@
+ */
- #ifndef errno
--extern int errno;
-+//extern int errno;
-+#if defined(__linux__) && !defined(__ANDROID__)
-+ #include
-+#else
-+ extern int errno;
-+#endif
- #endif
+ #include "lwip/opt.h"
++#include "ZeroTierConstants.h"
- #else /* LWIP_PROVIDE_ERRNO */
+ #if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
+
+@@ -281,6 +282,7 @@ static struct lwip_select_cb *select_cb_list;
+ #define sock_set_errno(sk, e) do { \
+ const int sockerr = (e); \
+ set_errno(sockerr); \
++ zts_errno = sockerr; \
+ } while (0)
+
+ /* Forward declaration of some functions */
+diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c
+index 039b7963..6647c90c 100644
+--- a/src/core/ipv6/nd6.c
++++ b/src/core/ipv6/nd6.c
+@@ -1644,9 +1644,27 @@ nd6_is_prefix_in_netif(const ip6_addr_t *ip6addr, struct netif *netif)
+ * addresses (from autoconfiguration) have no implied subnet assignment, and
+ * are thus effectively /128 assignments. See RFC 5942 for more on this. */
+ for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
+- if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
++ /*if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
+ netif_ip6_addr_isstatic(netif, i) &&
+- ip6_addr_netcmp(ip6addr, netif_ip6_addr(netif, i))) {
++ ip6_addr_netcmp(ip6addr, netif_ip6_addr(netif, i))) {*/
++ int prefix_match = 0;
++ if (ip6_addr_is_zt_6plane(ip6addr)) {
++ prefix_match = ip6_addr_6plane_cmp(ip6addr, netif_ip6_addr(netif, i));
++ DEBUG_INFO("6plane, prefix_match=%d", prefix_match);
++ }
++ if (ip6_addr_is_zt_adhoc(ip6addr)) {
++ prefix_match = ip6_addr_adhoc_cmp(ip6addr, netif_ip6_addr(netif, i));
++ DEBUG_INFO("adhoc, prefix_match=%d", prefix_match);
++ }
++ if (ip6_addr_is_zt_rfc4193(ip6addr)) {
++ prefix_match = ip6_addr_rfc4193_cmp(ip6addr, netif_ip6_addr(netif, i));
++ DEBUG_INFO("rfc4193, prefix_match=%d", prefix_match);
++ }
++ if (!prefix_match) {
++ prefix_match = ip6_addr_netcmp(ip6addr, netif_ip6_addr(netif, i));
++ DEBUG_INFO("traditional match, prefix_match=%d", prefix_match);
++ }
++ if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && prefix_match) {
+ return 1;
+ }
+ }
+diff --git a/src/include/lwip/ip6_addr.h b/src/include/lwip/ip6_addr.h
+index 29c2a34d..205b0e1f 100644
+--- a/src/include/lwip/ip6_addr.h
++++ b/src/include/lwip/ip6_addr.h
+@@ -160,6 +160,28 @@ typedef struct ip6_addr ip6_addr_t;
+ #define ip6_addr_netcmp(addr1, addr2) (ip6_addr_netcmp_zoneless((addr1), (addr2)) && \
+ ip6_addr_cmp_zone((addr1), (addr2)))
+
++/* Determine if an address *could* be a ZeroTier 6PLANE address */
++#define ip6_addr_is_zt_6plane(addr1) (((addr1)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xfc000000UL))
++
++/* Compare first 40 bits of address (ff + first 32 bits of nwid XOR'd with second 32 bits of nwid) */
++#define ip6_addr_6plane_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
++ ((addr1)->addr[1] & PP_HTONL(0xff000000UL)) == ((addr2)->addr[1] & PP_HTONL(0xff000000UL)))
++
++/* Determine if an address *could* be a ZeroTier Ad-hoc address */
++#define ip6_addr_is_zt_adhoc(addr1) (((addr1)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL))
++
++/* Compare first 40 bits of address (ff + first 32 bits of nwid XOR'd with second 32 bits of nwid) */
++#define ip6_addr_adhoc_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
++ ((addr1)->addr[1] & PP_HTONL(0xff000000UL)) == ((addr2)->addr[1] & PP_HTONL(0xff000000UL)))
++
++/* Determine if an address *could* be an RFC4193 address */
++#define ip6_addr_is_zt_rfc4193(addr1) (((addr1)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xfd000000UL))
++
++/* Compare first 72 bits of address (fd + 64 bits of nwid) */
++#define ip6_addr_rfc4193_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \
++ ((addr1)->addr[1] == (addr2)->addr[1]) && \
++ ((addr1)->addr[2] & PP_HTONL(0xff000000UL)) == ((addr2)->addr[2] & PP_HTONL(0xff000000UL)))
++
+ /* Exact-host comparison *after* ip6_addr_netcmp() succeeded, for efficiency. */
+ #define ip6_addr_nethostcmp(addr1, addr2) (((addr1)->addr[2] == (addr2)->addr[2]) && \
+ ((addr1)->addr[3] == (addr2)->addr[3]))
diff --git a/include/Xcode-Bridging-Header.h b/include/Xcode-Bridging-Header.h
index 482033a..1317ec1 100644
--- a/include/Xcode-Bridging-Header.h
+++ b/include/Xcode-Bridging-Header.h
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
diff --git a/include/ZeroTier.h b/include/ZeroTier.h
index 216efaa..ee42aed 100644
--- a/include/ZeroTier.h
+++ b/include/ZeroTier.h
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
@@ -82,9 +69,6 @@ typedef unsigned int socklen_t;
extern "C" {
#endif
-// Custom errno to prevent conflicts with platform's own errno
-extern int zts_errno;
-
typedef uint32_t zts_in_addr_t;
typedef uint16_t zts_in_port_t;
typedef uint8_t zts_sa_family_t;
@@ -230,7 +214,7 @@ struct zts_node_details
/**
* Whether multipath support is enabled. If true, this node will
- * be capable of utilizing multiple physical links simultaneosly
+ * be capable of utilizing multiple physical links simultaneously
* to create higher quality or more robust aggregate links.
*
* See: https://www.zerotier.com/manual.shtml#2_1_5
@@ -678,7 +662,7 @@ ZT_SOCKET_API int ZTCALL zts_get_address(
* @param nodeId Node ID
* @return
*/
-ZT_SOCKET_API void ZTCALL zts_get_6plane_addr(
+ZT_SOCKET_API int ZTCALL zts_get_6plane_addr(
struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
/**
@@ -690,7 +674,7 @@ ZT_SOCKET_API void ZTCALL zts_get_6plane_addr(
* @param nodeId Node ID
* @return
*/
-ZT_SOCKET_API void ZTCALL zts_get_rfc4193_addr(
+ZT_SOCKET_API int ZTCALL zts_get_rfc4193_addr(
struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
/**
diff --git a/include/ZeroTierConstants.h b/include/ZeroTierConstants.h
index 579b2bb..d818dca 100644
--- a/include/ZeroTierConstants.h
+++ b/include/ZeroTierConstants.h
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
@@ -33,21 +20,32 @@
#ifndef ZEROTIER_CONSTANTS_H
#define ZEROTIER_CONSTANTS_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Custom errno to prevent conflicts with platform's own errno
+extern int zts_errno;
+
+#ifdef __cplusplus
+}
+#endif
+
//////////////////////////////////////////////////////////////////////////////
// Control API error codes //
//////////////////////////////////////////////////////////////////////////////
-// Everything is ok
+// No error.
#define ZTS_ERR_OK 0
-// A argument provided by the user application is invalid (e.g. out of range, NULL, etc)
+// A argument provided is invalid (e.g. out of range, NULL, etc)
#define ZTS_ERR_INVALID_ARG -1
-// The service isn't initialized or is for some reason currently unavailable. Try again.
+// The service isn't initialized or is currently unavailable. Try again.
#define ZTS_ERR_SERVICE -2
-// For some reason this API operation is not permitted or doesn't make sense at this time.
+// This API operation is not permitted or doesn't make sense at this time.
#define ZTS_ERR_INVALID_OP -3
-// The call succeeded, but no object or relevant result was available
+// The call succeeded, but no object or relevant result was available.
#define ZTS_ERR_NO_RESULT -4
-// General internal failure
+// General internal failure. Consider filing a bug report.
#define ZTS_ERR_GENERAL -5
/**
diff --git a/ports/Homebrew/libzt.rb b/ports/Homebrew/libzt.rb
index 68cf0cf..13b2cd7 100644
--- a/ports/Homebrew/libzt.rb
+++ b/ports/Homebrew/libzt.rb
@@ -31,7 +31,7 @@ class Libzt < Formula
system "cmake", ".", *std_cmake_args
system "cmake", "--build", "."
system "make", "install"
- cp "LICENSE.GPL-3", "#{prefix}/LICENSE"
+ cp "LICENSE.txt", "#{prefix}/LICENSE"
end
def caveats
diff --git a/src/Controls.cpp b/src/Controls.cpp
index c7d4a8a..c7c5ae9 100644
--- a/src/Controls.cpp
+++ b/src/Controls.cpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
@@ -142,6 +129,7 @@ void postEvent(int eventCode, void *arg)
} if (ADDR_EVENT_TYPE(eventCode)) {
msg->addr = (struct zts_addr_details*)arg;
}
+
_callbackMsgQueue.enqueue(msg);
}
@@ -514,7 +502,7 @@ int zts_deorbit(uint64_t moonWorldId)
#endif
int zts_start(
- const char *path, userCallbackFunc callback, int port)
+ const char *path, void (*callback)(struct zts_callback_msg*), int port)
{
Mutex::Lock _l(_service_lock);
lwip_driver_init();
@@ -726,6 +714,24 @@ JNIEXPORT jlong JNICALL Java_com_zerotier_libzt_ZeroTier_get_1node_1id(
}
#endif
+int zts_get_6plane_addr(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId)
+{
+ if (!addr || !nwid || !nodeId) {
+ return ZTS_ERR_INVALID_ARG;
+ }
+ InetAddress _6planeAddr = InetAddress::makeIpv66plane(nwid,nodeId);
+ memcpy(addr, _6planeAddr.rawIpData(), sizeof(struct sockaddr_storage));
+}
+
+int zts_get_rfc4193_addr(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId)
+{
+ if (!addr || !nwid || !nodeId) {
+ return ZTS_ERR_INVALID_ARG;
+ }
+ InetAddress _rfc4193Addr = InetAddress::makeIpv6rfc4193(nwid,nodeId);
+ memcpy(addr, _rfc4193Addr.rawIpData(), sizeof(struct sockaddr_storage));
+}
+
//////////////////////////////////////////////////////////////////////////////
// Peers //
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/Controls.hpp b/src/Controls.hpp
index 2981546..06b464d 100644
--- a/src/Controls.hpp
+++ b/src/Controls.hpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
diff --git a/src/Debug.hpp b/src/Debug.hpp
index 8651888..fc35225 100644
--- a/src/Debug.hpp
+++ b/src/Debug.hpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
diff --git a/src/Intercept.cpp b/src/Intercept.cpp
deleted file mode 100644
index e69de29..0000000
diff --git a/src/Intercept.hpp b/src/Intercept.hpp
deleted file mode 100644
index e69de29..0000000
diff --git a/src/Options.h b/src/Options.h
index 3b7970f..f4ca86e 100644
--- a/src/Options.h
+++ b/src/Options.h
@@ -1,3 +1,16 @@
+/*
+ * Copyright (c)2013-2020 ZeroTier, Inc.
+ *
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
+ *
+ * Change Date: 2024-01-01
+ *
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
+ */
+/****/
+
#ifndef LIBZT_OPTIONS_H
#define LIBZT_OPTIONS_H
diff --git a/src/Service.cpp b/src/Service.cpp
index effb198..24f14da 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
#include
#include
@@ -868,10 +855,10 @@ public:
postEvent(ZTS_EVENT_NETWORK_REQUESTING_CONFIG, (void*)prepare_network_details_msg(nwid));
break;
case ZT_NETWORK_STATUS_OK:
- if (tap->hasIpv4Addr() && lwip_is_netif_up(tap->netif)) {
+ if (tap->hasIpv4Addr() && lwip_is_netif_up(tap->netif4)) {
postEvent(ZTS_EVENT_NETWORK_READY_IP4, (void*)prepare_network_details_msg(nwid));
}
- if (tap->hasIpv6Addr() && lwip_is_netif_up(tap->netif)) {
+ if (tap->hasIpv6Addr() && lwip_is_netif_up(tap->netif6)) {
postEvent(ZTS_EVENT_NETWORK_READY_IP6, (void*)prepare_network_details_msg(nwid));
}
// In addition to the READY messages, send one OK message
diff --git a/src/Service.hpp b/src/Service.hpp
index d977c5e..cc44b61 100644
--- a/src/Service.hpp
+++ b/src/Service.hpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
#ifndef ZT_ONESERVICE_HPP
#define ZT_ONESERVICE_HPP
diff --git a/src/Sockets.cpp b/src/Sockets.cpp
index 844c90a..b64323f 100644
--- a/src/Sockets.cpp
+++ b/src/Sockets.cpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
@@ -56,8 +43,6 @@ extern bool _run_lwip_tcpip;
extern "C" {
#endif
-extern int zts_errno;
-
#ifdef SDK_JNI
void ss2zta(JNIEnv *env, struct sockaddr_storage *ss, jobject addr);
void zta2ss(JNIEnv *env, struct sockaddr_storage *ss, jobject addr);
@@ -74,7 +59,7 @@ JNIEXPORT jint JNICALL Java_com_zerotier_libzt_ZeroTier_socket(
JNIEnv *env, jobject thisObj, jint family, jint type, jint protocol)
{
int retval = zts_socket(family, type, protocol);
- return retval > -1 ? retval : -(zts_errno); // Encode lwip errno in return value for JNI functions only
+ return retval > -1 ? retval : -(zts_errno); // Encode lwIP errno into return value for JNI functions only
}
#endif
diff --git a/src/VirtualTap.cpp b/src/VirtualTap.cpp
index 190b599..b4272d9 100644
--- a/src/VirtualTap.cpp
+++ b/src/VirtualTap.cpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
@@ -96,8 +83,10 @@ VirtualTap::~VirtualTap()
::write(_shutdownSignalPipe[1],"\0",1);
#endif
_phy.whack();
- lwip_remove_netif(netif);
- netif = NULL;
+ lwip_remove_netif(netif4);
+ netif4 = NULL;
+ lwip_remove_netif(netif6);
+ netif6 = NULL;
Thread::join(_thread);
#ifndef _WIN32
::close(_shutdownSignalPipe[0]);
@@ -144,7 +133,7 @@ bool VirtualTap::hasIpv6Addr()
bool VirtualTap::addIp(const InetAddress &ip)
{
- //char ipbuf[128];
+ char ipbuf[128];
//ip.toString(ipbuf);
//DEBUG_INFO("addr=%s", ipbuf);
@@ -152,9 +141,13 @@ bool VirtualTap::addIp(const InetAddress &ip)
This limitation can be removed if some changes
are made in the netif driver. */
if (ip.isV4() && hasIpv4Addr()) {
+ ip.toString(ipbuf);
+ DEBUG_INFO("failed to add IP (%s), only one per type per netif allowed\n", ipbuf);
return false;
}
if (ip.isV6() && hasIpv6Addr()) {
+ ip.toString(ipbuf);
+ DEBUG_INFO("failed to add IP (%s), only one per type per netif allowed\n", ipbuf);
return false;
}
diff --git a/src/VirtualTap.hpp b/src/VirtualTap.hpp
index a66b3ce..3703e96 100644
--- a/src/VirtualTap.hpp
+++ b/src/VirtualTap.hpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
@@ -169,7 +156,8 @@ public:
// Lower-level lwIP netif handling and traffic handling readiness //
//////////////////////////////////////////////////////////////////////////////
- void *netif = NULL;
+ void *netif4 = NULL;
+ void *netif6 = NULL;
/**
* The last time that this virtual tap received a network config update from the core
diff --git a/src/lwipDriver.cpp b/src/lwipDriver.cpp
index db8dffe..454b602 100644
--- a/src/lwipDriver.cpp
+++ b/src/lwipDriver.cpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
@@ -76,6 +63,7 @@ namespace ZeroTier {
bool _has_exited = false;
int hibernationDelayMultiplier = 1;
+int netifCount = 0;
extern bool _run_lwip_tcpip;
Mutex lwip_driver_m;
@@ -178,6 +166,9 @@ void lwip_driver_shutdown()
void lwip_remove_netif(void *netif)
{
+ if (!netif) {
+ return;
+ }
struct netif *n = (struct netif*)netif;
LOCK_TCPIP_CORE();
netif_remove(n);
@@ -188,6 +179,9 @@ void lwip_remove_netif(void *netif)
err_t lwip_eth_tx(struct netif *n, struct pbuf *p)
{
+ if (!n) {
+ return ERR_IF;
+ }
struct pbuf *q;
char buf[ZT_MAX_MTU+32];
char *bufptr;
@@ -212,7 +206,6 @@ err_t lwip_eth_tx(struct netif *n, struct pbuf *p)
int len = totalLength - sizeof(struct eth_hdr);
int proto = Utils::ntoh((uint16_t)ethhdr->type);
tap->_handler(tap->_arg, NULL, tap->_nwid, src_mac, dest_mac, proto, 0, data, len);
-/*
if (ZT_MSG_TRANSFER == true) {
char flagbuf[32];
memset(&flagbuf, 0, 32);
@@ -223,10 +216,11 @@ err_t lwip_eth_tx(struct netif *n, struct pbuf *p)
MAC mac;
mac.setTo(ethhdr->dest.addr, 6);
mac.toAddress(tap->_nwid).toString(nodeBuf);
- DEBUG_TRANS("len=%5d dst=%s [%s TX <-- %s] proto=0x%04x %s", totalLength, macBuf, nodeBuf, tap->nodeId().c_str(),
+ /*
+ DEBUG_TRANS("len=%5d dst=%s [%s TX <-- %s] ethertype=0x%04x %s", totalLength, macBuf, nodeBuf, tap->nodeId().c_str(),
Utils::ntoh(ethhdr->type), flagbuf);
+ */
}
-*/
return ERR_OK;
}
@@ -244,7 +238,7 @@ void lwip_eth_rx(VirtualTap *tap, const MAC &from, const MAC &to, unsigned int e
from.copyTo(ethhdr.src.addr, 6);
to.copyTo(ethhdr.dest.addr, 6);
ethhdr.type = Utils::hton((uint16_t)etherType);
-/*
+
if (ZT_MSG_TRANSFER == true) {
char flagbuf[32];
memset(&flagbuf, 0, 32);
@@ -255,10 +249,12 @@ void lwip_eth_rx(VirtualTap *tap, const MAC &from, const MAC &to, unsigned int e
MAC mac;
mac.setTo(ethhdr.src.addr, 6);
mac.toAddress(tap->_nwid).toString(nodeBuf);
- DEBUG_TRANS("len=%5d dst=%s [%s RX --> %s] proto=0x%04x %s", len, macBuf, nodeBuf, tap->nodeId().c_str(),
+ /*
+ DEBUG_TRANS("len=%5d dst=%s [%s RX --> %s] ethertype=0x%04x %s", len, macBuf, nodeBuf, tap->nodeId().c_str(),
Utils::ntoh(ethhdr.type), flagbuf);
+ */
}
-*/
+
p = pbuf_alloc(PBUF_RAW, len+sizeof(struct eth_hdr), PBUF_RAM);
if (!p) {
DEBUG_ERROR("dropped packet: unable to allocate memory for pbuf");
@@ -285,9 +281,18 @@ void lwip_eth_rx(VirtualTap *tap, const MAC &from, const MAC &to, unsigned int e
}
// Feed packet into stack
int err;
- if ((err = ((struct netif *)tap->netif)->input(p, (struct netif *)tap->netif)) != ERR_OK) {
- DEBUG_ERROR("packet input error (%d)", err);
- pbuf_free(p);
+
+ if (Utils::ntoh(ethhdr.type) == 0x800 || Utils::ntoh(ethhdr.type) == 0x806) {
+ if ((err = ((struct netif *)tap->netif4)->input(p, (struct netif *)tap->netif4)) != ERR_OK) {
+ DEBUG_ERROR("packet input error (%d)", err);
+ pbuf_free(p);
+ }
+ }
+ if (Utils::ntoh(ethhdr.type) == 0x86DD) {
+ if ((err = ((struct netif *)tap->netif6)->input(p, (struct netif *)tap->netif6)) != ERR_OK) {
+ DEBUG_ERROR("packet input error (%d)", err);
+ pbuf_free(p);
+ }
}
}
@@ -315,6 +320,9 @@ static void print_netif_info(struct netif *n) {
bool lwip_is_netif_up(void *n)
{
+ if (!n) {
+ return false;
+ }
LOCK_TCPIP_CORE();
bool result = netif_is_up((struct netif*)n);
UNLOCK_TCPIP_CORE();
@@ -328,7 +336,7 @@ bool lwip_is_netif_up(void *n)
static void netif_remove_callback(struct netif *n)
{
// Called from core, no need to lock
- if (!n->state) {
+ if (!n || !n->state) {
return;
}
VirtualTap *tap = (VirtualTap *)n->state;
@@ -349,7 +357,7 @@ static void netif_remove_callback(struct netif *n)
static void netif_link_callback(struct netif *n)
{
// Called from core, no need to lock
- if (!n->state) {
+ if (!n || !n->state) {
return;
}
VirtualTap *tap = (VirtualTap *)n->state;
@@ -374,6 +382,9 @@ static void netif_link_callback(struct netif *n)
void lwip_set_callbacks(struct netif *n)
{
+ if (!n) {
+ return;
+ }
#if LWIP_NETIF_STATUS_CALLBACK
// Not currently used
netif_set_status_callback(n, netif_status_callback);
@@ -388,13 +399,13 @@ void lwip_set_callbacks(struct netif *n)
static struct zts_netif_details *lwip_prepare_netif_status_msg(struct netif *n)
{
+ if (!n || !n->state) {
+ return NULL;
+ }
VirtualTap *tap = (VirtualTap*)(n->state);
struct zts_netif_details *ifd = new zts_netif_details;
- // nwid
ifd->nwid = tap->_nwid;
- // mtu
ifd->mtu = n->mtu;
- // MAC
memcpy(&(ifd->mac), n->hwaddr, n->hwaddr_len);
ifd->mac = htonll(ifd->mac) >> 16;
return ifd;
@@ -402,10 +413,13 @@ static struct zts_netif_details *lwip_prepare_netif_status_msg(struct netif *n)
static err_t netif_init(struct netif *n)
{
+ if (!n || !n->state) {
+ return ERR_IF;
+ }
// Called from netif code, no need to lock
n->hwaddr_len = 6;
- n->name[0] = 'z';
- n->name[1] = '4';
+ n->name[0] = '4';
+ n->name[1] = 'a'+netifCount;
n->linkoutput = lwip_eth_tx;
n->output = etharp_output;
n->mtu = LWIP_MTU < ZT_MAX_MTU ? LWIP_MTU : ZT_MAX_MTU;
@@ -422,6 +436,31 @@ static err_t netif_init(struct netif *n)
return ERR_OK;
}
+static err_t netif_init6(struct netif *n)
+{
+ if (!n || !n->state) {
+ return ERR_IF;
+ }
+ n->hwaddr_len = sizeof(n->hwaddr);
+ VirtualTap *tap = (VirtualTap*)(n->state);
+ tap->_mac.copyTo(n->hwaddr, n->hwaddr_len);
+ // Called from netif code, no need to lock
+ n->hwaddr_len = 6;
+ n->name[0] = '6';
+ n->name[1] = 'a'+netifCount;
+ n->linkoutput = lwip_eth_tx;
+ n->output_ip6 = ethip6_output;
+ n->mtu = LWIP_MTU < ZT_MAX_MTU ? LWIP_MTU : ZT_MAX_MTU;
+ n->flags = NETIF_FLAG_BROADCAST
+ | NETIF_FLAG_ETHARP
+ | NETIF_FLAG_ETHERNET
+ | NETIF_FLAG_IGMP
+ | NETIF_FLAG_MLD6
+ | NETIF_FLAG_LINK_UP
+ | NETIF_FLAG_UP;
+ return ERR_OK;
+}
+
void lwip_init_interface(void *tapref, const MAC &mac, const InetAddress &ip)
{
char ipbuf[INET6_ADDRSTRLEN];
@@ -429,52 +468,64 @@ void lwip_init_interface(void *tapref, const MAC &mac, const InetAddress &ip)
VirtualTap *vtap = (VirtualTap*)tapref;
struct netif *n = NULL;
- if (vtap->netif) {
- n = (struct netif*)vtap->netif;
- }
- else {
- n = new struct netif;
- }
+ bool isNewNetif = false;
if (ip.isV4()) {
+ if (vtap->netif4) {
+ n = (struct netif*)vtap->netif4;
+ }
+ else {
+ n = new struct netif;
+ isNewNetif = true;
+ netifCount++;
+ }
char nmbuf[INET6_ADDRSTRLEN];
- static ip4_addr_t ipaddr, netmask, gw;
+ static ip4_addr_t ip4, netmask, gw;
IP4_ADDR(&gw,127,0,0,1);
- ipaddr.addr = *((u32_t *)ip.rawIpData());
+ ip4.addr = *((u32_t *)ip.rawIpData());
netmask.addr = *((u32_t *)ip.netmask().rawIpData());
LOCK_TCPIP_CORE();
- netif_add(n, &ipaddr, &netmask, &gw, tapref, netif_init, tcpip_input);
+ netif_add(n, &ip4, &netmask, &gw, (void*)vtap, netif_init, tcpip_input);
+ vtap->netif4 = (void*)n;
postEvent(ZTS_EVENT_NETIF_UP, (void*)lwip_prepare_netif_status_msg(n));
UNLOCK_TCPIP_CORE();
-/*
snprintf(macbuf, ZTS_MAC_ADDRSTRLEN, "%02x:%02x:%02x:%02x:%02x:%02x",
n->hwaddr[0], n->hwaddr[1], n->hwaddr[2],
n->hwaddr[3], n->hwaddr[4], n->hwaddr[5]);
- DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s, nm=%s]",n,
- macbuf, ip.toString(ipbuf), ip.netmask().toString(nmbuf));
-*/
- vtap->netif = (void*)n;
+ DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s, nm=%s, tap=%p]",n,
+ macbuf, ip.toString(ipbuf), ip.netmask().toString(nmbuf), vtap);
}
if (ip.isV6()) {
- static ip6_addr_t ipaddr;
- memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
- n->ip6_autoconfig_enabled = 1;
-
+ if (vtap->netif6) {
+ n = (struct netif*)vtap->netif6;
+ }
+ else {
+ n = new struct netif;
+ isNewNetif = true;
+ netifCount++;
+ }
+ static ip6_addr_t ip6;
+ memcpy(&(ip6.addr), ip.rawIpData(), sizeof(ip6.addr));
LOCK_TCPIP_CORE();
- netif_ip6_addr_set(n, 1, &ipaddr);
- netif_create_ip6_linklocal_address(n, 1);
- netif_ip6_addr_set_state(n, 0, IP6_ADDR_TENTATIVE);
- netif_ip6_addr_set_state(n, 1, IP6_ADDR_TENTATIVE);
+ if (isNewNetif) {
+ vtap->netif6 = (void*)n;
+ netif_add(n, NULL, NULL, NULL, (void*)vtap, netif_init6, ethernet_input);
+ n->ip6_autoconfig_enabled = 1;
+ vtap->_mac.copyTo(n->hwaddr, n->hwaddr_len);
+ netif_create_ip6_linklocal_address(n, 1);
+ netif_set_link_up(n);
+ netif_set_up(n);
+ netif_set_default(n);
+ }
+ netif_add_ip6_address(n,&ip6,NULL);
n->output_ip6 = ethip6_output;
- postEvent(ZTS_EVENT_NETIF_UP, (void*)lwip_prepare_netif_status_msg(n));
UNLOCK_TCPIP_CORE();
-/*
+ postEvent(ZTS_EVENT_NETIF_UP, (void*)lwip_prepare_netif_status_msg(n));
snprintf(macbuf, ZTS_MAC_ADDRSTRLEN, "%02x:%02x:%02x:%02x:%02x:%02x",
n->hwaddr[0], n->hwaddr[1], n->hwaddr[2],
n->hwaddr[3], n->hwaddr[4], n->hwaddr[5]);
- DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s]", n,
- macbuf, ip.toString(ipbuf));
-*/
+ DEBUG_INFO("initialized netif=%p as [mac=%s, addr=%s, tap=%p]", n,
+ macbuf, ip.toString(ipbuf), vtap);
}
}
diff --git a/src/lwipDriver.hpp b/src/lwipDriver.hpp
index 4b7dffe..7467c7e 100644
--- a/src/lwipDriver.hpp
+++ b/src/lwipDriver.hpp
@@ -1,28 +1,15 @@
/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2019 ZeroTier, Inc. https://www.zerotier.com/
+ * Copyright (c)2013-2020 ZeroTier, Inc.
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * Use of this software is governed by the Business Source License included
+ * in the LICENSE.TXT file in the project's root directory.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Change Date: 2024-01-01
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
+ * On the date above, in accordance with the Business Source License, use
+ * of this software will be governed by version 2.0 of the Apache License.
*/
+/****/
/**
* @file
diff --git a/src/lwipRawDriver.cpp b/src/lwipRawDriver.cpp
deleted file mode 100644
index e69de29..0000000
diff --git a/src/lwipRawDriver.hpp b/src/lwipRawDriver.hpp
deleted file mode 100644
index e69de29..0000000
From 2b60ab27ea2e73f332e6408983ac48dedc4a6568 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Wed, 15 Apr 2020 16:08:40 -0700
Subject: [PATCH 35/78] Add network and peer caching toggles to API, fix 6PLANE
and RFC4193 address computation
---
include/ZeroTier.h | 30 ++++++++++++++++++++++++++++
src/Controls.cpp | 19 ++++++++++++++++--
src/Options.h | 20 -------------------
src/Service.cpp | 50 ++++++++++++++++++++++------------------------
4 files changed, 71 insertions(+), 48 deletions(-)
diff --git a/include/ZeroTier.h b/include/ZeroTier.h
index ee42aed..bf92169 100644
--- a/include/ZeroTier.h
+++ b/include/ZeroTier.h
@@ -466,6 +466,36 @@ struct zts_peer_list
extern "C" {
#endif
+/**
+ * @brief Enable or disable whether the service will cache network details (enabled by default)
+ *
+ * This can potentially shorten (startup) times. This allows the service to nearly instantly
+ * inform the network stack of an address to use for this peer so that it can
+ * create an interface. This can be disabled for cases where one may not want network
+ * config details to be written to storage. This is especially useful for situations where
+ * address assignments do not change often.
+ *
+ * @usage Should be called before zts_start() if you intend on changing its state.
+ *
+ * @param enabled Whether or not this feature is enabled
+ */
+ZT_SOCKET_API void ZTCALL zts_set_network_caching(bool enabled);
+
+/**
+ * @brief Enable or disable whether the service will cache peer details (enabled by default)
+ *
+ * This can potentially shorten (connection) times. This allows the service to
+ * re-use previously discovered paths to a peer, this prevents the service from having
+ * to go through the entire transport-triggered link provisioning process. This is especially
+ * useful for situations where paths to peers do not change often. This is enabled by default
+ * and can be disabled for cases where one may not want peer details to be written to storage.
+ *
+ * @usage Should be called before zts_start() if you intend on changing its state.
+ *
+ * @param enabled Whether or not this feature is enabled
+ */
+ZT_SOCKET_API void ZTCALL zts_set_peer_caching(bool enabled);
+
/**
* @brief Starts the ZeroTier service and notifies user application of events via callback
*
diff --git a/src/Controls.cpp b/src/Controls.cpp
index c7c5ae9..cc466b3 100644
--- a/src/Controls.cpp
+++ b/src/Controls.cpp
@@ -79,6 +79,9 @@ bool _run_service = false;
bool _run_callbacks = false;
bool _run_lwip_tcpip = false;
+bool _network_caching_enabled = true;
+bool _peer_caching_enabled = true;
+
//bool _startupError = false;
// Global reference to ZeroTier service
@@ -501,6 +504,16 @@ int zts_deorbit(uint64_t moonWorldId)
#ifdef SDK_JNI
#endif
+void zts_set_network_caching(bool enabled)
+{
+ _network_caching_enabled = enabled;
+}
+
+void zts_set_peer_caching(bool enabled)
+{
+ _peer_caching_enabled = enabled;
+}
+
int zts_start(
const char *path, void (*callback)(struct zts_callback_msg*), int port)
{
@@ -720,7 +733,8 @@ int zts_get_6plane_addr(struct sockaddr_storage *addr, const uint64_t nwid, cons
return ZTS_ERR_INVALID_ARG;
}
InetAddress _6planeAddr = InetAddress::makeIpv66plane(nwid,nodeId);
- memcpy(addr, _6planeAddr.rawIpData(), sizeof(struct sockaddr_storage));
+ struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr;
+ memcpy(in6->sin6_addr.s6_addr, _6planeAddr.rawIpData(), sizeof(struct in6_addr));
}
int zts_get_rfc4193_addr(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId)
@@ -729,7 +743,8 @@ int zts_get_rfc4193_addr(struct sockaddr_storage *addr, const uint64_t nwid, con
return ZTS_ERR_INVALID_ARG;
}
InetAddress _rfc4193Addr = InetAddress::makeIpv6rfc4193(nwid,nodeId);
- memcpy(addr, _rfc4193Addr.rawIpData(), sizeof(struct sockaddr_storage));
+ struct sockaddr_in6 *in6 = (struct sockaddr_in6*)addr;
+ memcpy(in6->sin6_addr.s6_addr, _rfc4193Addr.rawIpData(), sizeof(struct in6_addr));
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/Options.h b/src/Options.h
index f4ca86e..74708dd 100644
--- a/src/Options.h
+++ b/src/Options.h
@@ -77,24 +77,4 @@
*/
#define ZTS_LWIP_MAX_RX_QUEUE_LEN 1024
-//////////////////////////////////////////////////////////////////////////////
-// Service behaviour //
-//////////////////////////////////////////////////////////////////////////////
-
-/**
- * Whether the service will cache peer details (such as known paths). This will
- * make startup and reachability time shorter but is generally only effective
- * for networks with a somewhat static topology. In other words this would not be
- * recommended for use on mobile devices.
- */
-#define PEER_CACHING 0
-
-/**
- * Whether the service will cache network details. This will shorten startup
- * times. This allows the service to nearly instantly inform the network stack
- * of an address to use for this peer so that it can create an interface. This
- * is only recommended for networks whose IP assignments do not change often.
- */
-#define NETWORK_CACHING 1
-
#endif
\ No newline at end of file
diff --git a/src/Service.cpp b/src/Service.cpp
index 24f14da..b3bc011 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -90,6 +90,8 @@ namespace ZeroTier { typedef VirtualTap EthernetTap; }
namespace ZeroTier {
extern void postEvent(uint64_t id, int eventCode);
+extern bool _network_caching_enabled;
+extern bool _peer_caching_enabled;
namespace {
@@ -422,10 +424,8 @@ public:
}
}
#endif
-
-#if NETWORK_CACHING
// Join existing networks in networks.d
- {
+ if (_network_caching_enabled) {
std::vector networksDotD(OSUtils::listDirectory((_homePath + ZT_PATH_SEPARATOR_S "networks.d").c_str()));
for(std::vector::iterator f(networksDotD.begin());f!=networksDotD.end();++f) {
std::size_t dot = f->find_last_of('.');
@@ -433,8 +433,6 @@ public:
_node->join(Utils::hexStrToU64(f->substr(0,dot).c_str()),(void *)0,(void *)0);
}
}
-#endif
-
// Main I/O loop
_nextBackgroundTaskDeadline = 0;
int64_t clockShouldBe = OSUtils::now();
@@ -773,13 +771,13 @@ public:
*nuptr = (void *)0;
delete n.tap;
_nets.erase(nwid);
-#if NETWORK_CACHING
- if (op == ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY) {
- char nlcpath[256];
- OSUtils::ztsnprintf(nlcpath,sizeof(nlcpath),"%s" ZT_PATH_SEPARATOR_S "networks.d" ZT_PATH_SEPARATOR_S "%.16llx.local.conf",_homePath.c_str(),nwid);
- OSUtils::rm(nlcpath);
+ if (_network_caching_enabled) {
+ if (op == ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY) {
+ char nlcpath[256];
+ OSUtils::ztsnprintf(nlcpath,sizeof(nlcpath),"%s" ZT_PATH_SEPARATOR_S "networks.d" ZT_PATH_SEPARATOR_S "%.16llx.local.conf",_homePath.c_str(),nwid);
+ OSUtils::rm(nlcpath);
+ }
}
-#endif
} else {
_nets.erase(nwid);
}
@@ -970,19 +968,19 @@ public:
case ZT_STATE_OBJECT_PLANET:
OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "planet",_homePath.c_str());
break;
-#if NETWORK_CACHING
case ZT_STATE_OBJECT_NETWORK_CONFIG:
- OSUtils::ztsnprintf(dirname,sizeof(dirname),"%s" ZT_PATH_SEPARATOR_S "networks.d",_homePath.c_str());
- OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.16llx.conf",dirname,(unsigned long long)id[0]);
- secure = true;
+ if (_network_caching_enabled) {
+ OSUtils::ztsnprintf(dirname,sizeof(dirname),"%s" ZT_PATH_SEPARATOR_S "networks.d",_homePath.c_str());
+ OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.16llx.conf",dirname,(unsigned long long)id[0]);
+ secure = true;
+ }
break;
-#endif
-#if PEER_CACHING
case ZT_STATE_OBJECT_PEER:
- OSUtils::ztsnprintf(dirname,sizeof(dirname),"%s" ZT_PATH_SEPARATOR_S "peers.d",_homePath.c_str());
- OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.10llx.peer",dirname,(unsigned long long)id[0]);
+ if (_peer_caching_enabled) {
+ OSUtils::ztsnprintf(dirname,sizeof(dirname),"%s" ZT_PATH_SEPARATOR_S "peers.d",_homePath.c_str());
+ OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.10llx.peer",dirname,(unsigned long long)id[0]);
+ }
break;
-#endif
default:
return;
}
@@ -1032,16 +1030,16 @@ public:
case ZT_STATE_OBJECT_PLANET:
OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "planet",_homePath.c_str());
break;
-#if NETWORK_CACHING
case ZT_STATE_OBJECT_NETWORK_CONFIG:
- OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "networks.d" ZT_PATH_SEPARATOR_S "%.16llx.conf",_homePath.c_str(),(unsigned long long)id[0]);
+ if (_network_caching_enabled) {
+ OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "networks.d" ZT_PATH_SEPARATOR_S "%.16llx.conf",_homePath.c_str(),(unsigned long long)id[0]);
+ }
break;
-#endif
-#if PEER_CACHING
case ZT_STATE_OBJECT_PEER:
- OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "peers.d" ZT_PATH_SEPARATOR_S "%.10llx.peer",_homePath.c_str(),(unsigned long long)id[0]);
+ if (_peer_caching_enabled) {
+ OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "peers.d" ZT_PATH_SEPARATOR_S "%.10llx.peer",_homePath.c_str(),(unsigned long long)id[0]);
+ }
break;
-#endif
default:
return -1;
}
From 41c8f019a0182ac84f7f9be6ae2e7d9dda06cd88 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Thu, 16 Apr 2020 12:26:50 -0700
Subject: [PATCH 36/78] Remove old WindowsCppApp example
---
.../ExampleWindowsCppApp.sln | 31 ----
.../ExampleWindowsCppApp.cpp | Bin 6782 -> 0 bytes
.../ExampleWindowsCppApp.vcxproj | 174 ------------------
.../ExampleWindowsCppApp.vcxproj.filters | 33 ----
.../ExampleWindowsCppApp/stdafx.cpp | Bin 616 -> 0 bytes
.../ExampleWindowsCppApp/stdafx.h | Bin 642 -> 0 bytes
.../ExampleWindowsCppApp/targetver.h | Bin 630 -> 0 bytes
7 files changed, 238 deletions(-)
delete mode 100644 examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp.sln
delete mode 100644 examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.cpp
delete mode 100644 examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj
delete mode 100644 examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj.filters
delete mode 100644 examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/stdafx.cpp
delete mode 100644 examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/stdafx.h
delete mode 100644 examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/targetver.h
diff --git a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp.sln b/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp.sln
deleted file mode 100644
index 429a747..0000000
--- a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp.sln
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2027
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExampleWindowsCppApp", "ExampleWindowsCppApp\ExampleWindowsCppApp.vcxproj", "{D6BC8888-0498-4BDB-AFAF-21090A39082A}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Debug|x64.ActiveCfg = Debug|x64
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Debug|x64.Build.0 = Debug|x64
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Debug|x86.ActiveCfg = Debug|Win32
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Debug|x86.Build.0 = Debug|Win32
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Release|x64.ActiveCfg = Release|x64
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Release|x64.Build.0 = Release|x64
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Release|x86.ActiveCfg = Release|Win32
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}.Release|x86.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {68E97C56-8BB2-44E4-8536-069924BC9707}
- EndGlobalSection
-EndGlobal
diff --git a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.cpp b/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.cpp
deleted file mode 100644
index dcd37ba26d38187d0d5c682bca9f2612d366a926..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 6782
zcmbuEeQy&-5XSf4RO)xQrUE&r32zmZc&P+w2vNg}uxUyuvK-rS+&V9f&xC;Z>TRFj
z&W-oZJ|_WWk-OWSot=5+*_pZHzkjcXYvJ4Qjs9lgkI)Y%;V87iFy3XM8GZ@BYGzgc
zo@p!(rbF|l{iLyZ%YM+&?XVL)z1O4qtE-Oa&^xW4klgv@r(_W{VXY8)V&NMdBwW~3FXS^3z
z=DHt-UCrik^-$L=O7&y|NM_pQC`#{1kK1E%6KU&d9a4Ejkt@#!(N-);Gno2yL*Df=T`}8!kTe8P@f2_R?hvp0pS$G^#z~aOM
z;?&oUwjMu>6=RJVPi||h>POW=G=P&M(}>y~b2P#w=N$|p24}jCqNJf$-F59VqhA+G
z5E{m4J2v~#5-?>143OaOsjj0Ki`|I%M40y#yNSkrn0jU`$-<79-3m{_b49bI)ejZd
z*ShZL?xlV_w={CE(9CY|kDdAvUpVMi4aJpX?F0X@*?0@P4e2!V}_Vn(OkBA-5IJ{h`+7;tyUJlJ~XN@?bR!4y1n~48UffyaO9j
z4j60X=Q)H{m4WLq^DJjv2JMmlkw=VS`=ewQum#(6_+RrbI`=HcILl`$+mr%?B>=Q#dlw67I@I`QRD
z6?!~HiTnlfT}h4#F9z}ixv|FP>ua3_&Q8xYmKEI#i%W`m)gSBy6-UT2zM*D0{8YAp
z?y-IrjZ{Va^jg(M$M?~8_MSw&S-2lP!KNc|d0&h^PmZb#k1j8{SRa}=b!W1iI3%5J
z0aY6B_u{Ucl16C9JpU}*R-d!7(AJ%}qA8!cis-G9?(-19o@7OxWK#%@Vl6n<4rN(b
z3n$%nxK>7)&Vp)d*X!}Fyq=lrim{L($G`}@VEy?kOm|Nm$oX<~V8`N&S#hym`YEz%
zt_YMhlaFAI)xmntmy2~BNxhG&mm@~?(#A$-nQ^CHa#`roA$}-ONm`9p^oMp*8xd&v|XI%B8dLMwXL7ITHh&2CmeRc8n-h@U1L-BMI_O
zuXx(kJ+VTH447+terN2Yk~Z`%ku3UDSZ49RtInM}j}di-j6?MW8%Oeu-bLO{y;`)^
ztu&3Z8g7*|cvR;-@m0Az8&0G3P8i(Q`s9aeI4vx_5qSUuu-l$Mx;o;gZ%^pKn~w1B
z3iaO9x5T6q@o}O#b}rja1>?`z8j%M)kPRUZAaemqSnl#v5Vuay9Cj`I7vUDD6w~4dCK4m?7k>jwDdJm=#)#0|)
z(bDm@B)!-M_runiZXat)FK;Hc+R)%#mA7ktbSN8odt)EopMTfBPt`MT>poLA{ao+j
z8`GRKf4+94AJ(%g-K6)#d75ti*}5ebKQJ2#-o=m
zdL*=c-e!2?ZWmE+h{dpl_tb6uxW6gQDH^jG$aOskSEBa!#c5|{Lpu^*@(1?QrKeun
z?^dSvq+Q6h|f{rK6KW`R1p-I}DS4jt=swxT_-$9EgVbJNx?CIO@A1d_H{
z@3*wtzCwJB_sJgL$+$=%amgW(=sd#^B#Oe64*!?L-*T1sx4FZO3D0`40H{}b~*xL_0{v1zz2Re?!
zBCpZ4@|A>aN3OPtWD=h1QhiGZxMYfIstrheMDzDKO@yJ2i(*HQ}`c!s6Y__
diff --git a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj b/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj
deleted file mode 100644
index 5581f98..0000000
--- a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 15.0
- {D6BC8888-0498-4BDB-AFAF-21090A39082A}
- Win32Proj
- ExampleWindowsCppApp
- 10.0.16299.0
-
-
-
- Application
- true
- v141
- Unicode
-
-
- Application
- false
- v141
- true
- Unicode
-
-
- Application
- true
- v141
- Unicode
-
-
- Application
- false
- v141
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
- Use
- Level3
- Disabled
- true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- C:\libzt\include;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- C:\libzt\bin\lib\Debug;%(AdditionalLibraryDirectories)
- ws2_32.lib;iphlpapi.lib;Shlwapi.lib;zt-static.lib;%(AdditionalDependencies)
-
-
-
-
- Use
- Level3
- Disabled
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Use
- Level3
- MaxSpeed
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- C:\libzt\include;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- true
- true
- C:\libzt\bin\lib\Release;%(AdditionalLibraryDirectories)
- zt-static.lib;ws2_32.lib;shlwapi.lib;iphlpapi.lib;%(AdditionalDependencies)
-
-
-
-
- Use
- Level3
- MaxSpeed
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- C:\libzt\include;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- true
- true
- zt-static.lib;ws2_32.lib;iphlpapi.lib;Shlwapi.lib;%(AdditionalDependencies)
- C:\libzt\examples\cpp\ExampleWindowsCppApp\ExampleWindowsCppApp\Debug;%(AdditionalLibraryDirectories)
-
-
-
-
-
-
-
-
-
- Create
- Create
- Create
- Create
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj.filters b/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj.filters
deleted file mode 100644
index 64d4196..0000000
--- a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/ExampleWindowsCppApp.vcxproj.filters
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Header Files
-
-
- Header Files
-
-
-
-
- Source Files
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/stdafx.cpp b/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/stdafx.cpp
deleted file mode 100644
index d090f4677a40d5cbb340dc28006bc0b61edb71a8..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 616
zcmZ`%L2kk@5S%ko|6swnaPJL4D{dT$M6WJM6r&KM5LEK{wliyy096&O?Ra-*W_SJb
zJ;MwRC$z}mQQ(3pb~y5Lcrj1J84d4p{uKzQ?9`%Ue9OCln%;_089gW7?0FWVqm>q|
zKhHREG+h5?Jz+#8((+0T9tSEA)7J1aM0^o*Van#VPPy)g@92@Lil@(Bo75i3mE)OF
z(eRRXu}hUVy$uHD`z}PH?eEZqQ(Gmfd8qDxo)#TdNQ*KG<~LNLz6HY)w`^kmp^FaV
zhnbYTxkjfxZLr3YrYWh;f~H;55Tp9t*`Be|&~tk0)NKbevyOVs+-v6M{e&Feu_4PG
cZ}{NLSlx6h%~KhX*r~$QlVGpl`c|a+7nyfzLI3~&
diff --git a/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/stdafx.h b/examples/cpp/ExampleWindowsCppApp/ExampleWindowsCppApp/stdafx.h
deleted file mode 100644
index 94d4ed877dbfd8cd2c783931c444cad664143b10..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 642
zcmaJ<%Z`FT5UjJw{sYnLM(@V#$-9^R0UQRwu#ECB^7Cp{4I>V}Q
z8vEtLe;CsQ`f9DHxFP?Ev!}!l=AXA(tbaPXB)?e2)ZxZ=WBxB^dUob-#=8i1_Gje&
z#NH7xP7*QWxk;u;fEfw0WxN;+co0fK2Vs4B9U*sm0{`t1wOo&Foy0~*EXI^K{
z&F{}p2USW{Xp2p>*G`#oJ!s%(q!H-M(Ty4fmG}kNtEQTB%)V1m=}BwwfWPvrT#@e@
zH0NG}74Ao{glS)#QXA|NYdIfY7hrMp+Ji@H`t9kzWx_SD6;~Ri;cvXH)6CO{-I1p_IJPQ#X=r
zigZeSqQguJz35q;zt9^Q_C^^>*mmuXUCp&pw^fPoGX+dho4RCrySs7j@9_UipWkA5
OQDt4mH~x-^Z~X_?9czaG
From d7be0b7052308ec64b1b50fe20b817545bfc2ad2 Mon Sep 17 00:00:00 2001
From: Joseph Henry
Date: Fri, 17 Apr 2020 10:32:43 -0700
Subject: [PATCH 37/78] Remove outdated examples
---
examples/cpp/earthtest.cpp | 39 -
examples/cpp/ipv4simple/ipv4client.cpp | 96 -
examples/cpp/ipv4simple/ipv4client_udp.cpp | 109 -
examples/cpp/ipv4simple/ipv4server.cpp | 119 -
examples/cpp/ipv4simple/ipv4server_udp.cpp | 107 -
examples/cpp/ipv6adhoc/ipv6adhocclient.cpp | 114 -
examples/cpp/ipv6adhoc/ipv6adhocserver.cpp | 127 -
examples/cpp/ipv6simple/ipv6client.cpp | 96 -
examples/cpp/ipv6simple/ipv6server.cpp | 106 -
examples/cpp/sharedlib/ipv4client_shared.cpp | 215 --
examples/cpp/sharedlib/ipv4server_shared.cpp | 222 --
test/example.cpp | 280 --
test/selftest.cpp | 3411 ------------------
test/simple.cpp | 92 -
14 files changed, 5133 deletions(-)
delete mode 100644 examples/cpp/earthtest.cpp
delete mode 100644 examples/cpp/ipv4simple/ipv4client.cpp
delete mode 100644 examples/cpp/ipv4simple/ipv4client_udp.cpp
delete mode 100644 examples/cpp/ipv4simple/ipv4server.cpp
delete mode 100644 examples/cpp/ipv4simple/ipv4server_udp.cpp
delete mode 100644 examples/cpp/ipv6adhoc/ipv6adhocclient.cpp
delete mode 100644 examples/cpp/ipv6adhoc/ipv6adhocserver.cpp
delete mode 100644 examples/cpp/ipv6simple/ipv6client.cpp
delete mode 100644 examples/cpp/ipv6simple/ipv6server.cpp
delete mode 100644 examples/cpp/sharedlib/ipv4client_shared.cpp
delete mode 100644 examples/cpp/sharedlib/ipv4server_shared.cpp
delete mode 100644 test/example.cpp
delete mode 100644 test/selftest.cpp
delete mode 100644 test/simple.cpp
diff --git a/examples/cpp/earthtest.cpp b/examples/cpp/earthtest.cpp
deleted file mode 100644
index df51df9..0000000
--- a/examples/cpp/earthtest.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-
-#include "libzt.h"
-
-int main(int argc, char **argv)
-{
- uint64_t nwid = 0x8056c2e21c000001;
- zts_startjoin(".", nwid);
- fprintf(stderr, "%llx", (unsigned long long)zts_get_node_id());
- zts_leave(nwid);
- zts_stop();
- return 0;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv4simple/ipv4client.cpp b/examples/cpp/ipv4simple/ipv4client.cpp
deleted file mode 100644
index 9d0100b..0000000
--- a/examples/cpp/ipv4simple/ipv4client.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-
-#include "libzt.h"
-
-char *msg = (char*)"welcome to the machine";
-
-int main(int argc, char **argv)
-{
- if (argc != 5) {
- printf("\nlibzt example client\n");
- printf("client [config_file_path] [nwid] [remote_addr] [remote_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- std::string remote_addr = argv[3];
- int remote_port = atoi(argv[4]);
- int r=0, w=0, err=0, sockfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in in4;
- in4.sin_port = htons(remote_port);
- in4.sin_addr.s_addr = inet_addr(remote_addr.c_str());
- in4.sin_family = AF_INET;
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = zts_connect(sockfd, (const struct sockaddr *)&in4, sizeof(in4))) < 0) {
- printf("error connecting to remote host (%d)\n", err);
- }
-
- printf("sending to server...\n");
- w = zts_write(sockfd, msg, strlen(msg));
-
- printf("reading from server...\n");
- r = zts_read(sockfd, rbuf, strlen(msg));
-
- printf("Sent : %s\n", msg);
- printf("Received : %s\n", rbuf);
-
- err = zts_close(sockfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv4simple/ipv4client_udp.cpp b/examples/cpp/ipv4simple/ipv4client_udp.cpp
deleted file mode 100644
index 273c797..0000000
--- a/examples/cpp/ipv4simple/ipv4client_udp.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-
-#include "libzt.h"
-
-char *msg = (char*)"welcome to the machine";
-
-int main(int argc, char **argv)
-{
- if (argc != 5) {
- printf("\nlibzt example client\n");
- printf("client [config_file_path] [nwid] [remote_addr] [remote_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- std::string remote_addr = argv[3];
- int remote_port = atoi(argv[4]);
- int r=0, w=0, err=0, sockfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in in4;
- in4.sin_port = htons(remote_port);
- in4.sin_addr.s_addr = INADDR_ANY;
- in4.sin_family = AF_INET;
-
- struct sockaddr_in remote4;
- remote4.sin_port = htons(remote_port);
- remote4.sin_addr.s_addr = inet_addr(remote_addr.c_str());
- remote4.sin_family = AF_INET;
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = zts_bind(sockfd, (struct sockaddr *)&in4, sizeof(struct sockaddr_in)) < 0)) {
- printf("error binding to interface (%d)\n", err);
- }
- int flags = 0;
- int len = strlen(msg);
-
- while(true) {
- sleep(1);
- if ((err = zts_sendto(sockfd, msg, len, flags, (const struct sockaddr *)&remote4, sizeof(remote4))) < 0) {
- printf("error sending message to remote host (%d)\n", err);
- }
- printf("sent=%d\n", err);
- }
- /*
- printf("reading from server...\n");
- r = zts_read(sockfd, rbuf, strlen(msg));
-
- printf("Sent : %s\n", msg);
- printf("Received : %s\n", rbuf);
- */
- err = zts_close(sockfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv4simple/ipv4server.cpp b/examples/cpp/ipv4simple/ipv4server.cpp
deleted file mode 100644
index 260e9e4..0000000
--- a/examples/cpp/ipv4simple/ipv4server.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-#include "libzt.h"
-
-int main(int argc, char **argv)
-{
- if (argc != 4) {
- printf("\nlibzt example server\n");
- printf("server [config_file_path] [nwid] [bind_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- int bind_port = atoi(argv[3]);
- int w=0, r=0, err=0, sockfd, accfd;
- char rbuf[1000];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in in4, acc_in4;
- in4.sin_port = htons(bind_port);
- in4.sin_addr.s_addr = INADDR_ANY;
- in4.sin_family = AF_INET;
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = zts_bind(sockfd, (struct sockaddr *)&in4, sizeof(struct sockaddr_in)) < 0)) {
- printf("error binding to interface (%d)\n", err);
- }
-
- if ((err = zts_listen(sockfd, 100)) < 0) {
- printf("error placing socket in LISTENING state (%d)\n", err);
- }
-
- socklen_t client_addrlen = sizeof(sockaddr_in);
- if ((accfd = zts_accept(sockfd, (struct sockaddr *)&acc_in4, &client_addrlen)) < 0) {
- printf("error accepting connection (%d)\n", err);
- }
-
- socklen_t peer_addrlen = sizeof(struct sockaddr_storage);
- zts_getpeername(accfd, (struct sockaddr*)&acc_in4, &peer_addrlen);
- printf("accepted connection from %s : %d\n", inet_ntoa(acc_in4.sin_addr), ntohs(acc_in4.sin_port));
-
- int tot = 0;
- printf("reading from client...\n");
- while(true) {
- memset(rbuf, 0, sizeof rbuf);
- if (tot == 500000)
- {
- break;
- }
- r = zts_read(accfd, rbuf, sizeof rbuf);
- printf("r=%d\n", r);
- printf("Received : %s\n", rbuf);
- tot+= r;
- printf("tot=%d\n", tot);
- }
- printf("tot=%d\n", tot);
-
- printf("sending to client...\n");
- w = zts_write(accfd, rbuf, strlen(rbuf));
- printf("w=%d\n", r);
-
- printf("Received : %s\n", rbuf);
-
- err = zts_close(sockfd);
- err = zts_close(accfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv4simple/ipv4server_udp.cpp b/examples/cpp/ipv4simple/ipv4server_udp.cpp
deleted file mode 100644
index 1a7f5eb..0000000
--- a/examples/cpp/ipv4simple/ipv4server_udp.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-#include "libzt.h"
-
-int main(int argc, char **argv)
-{
- if (argc != 4) {
- printf("\nlibzt example server\n");
- printf("server [config_file_path] [nwid] [bind_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- int bind_port = atoi(argv[3]);
- int w=0, r=0, err=0, sockfd = 0, accfd = 0, flags = 0;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in in4, acc_in4;
- in4.sin_port = htons(bind_port);
- in4.sin_addr.s_addr = INADDR_ANY;
- in4.sin_family = AF_INET;
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
- if ((err = zts_bind(sockfd, (struct sockaddr *)&in4, sizeof(struct sockaddr_in)) < 0)) {
- printf("error binding to interface (%d)\n", err);
- }
-
-/*
- socklen_t peer_addrlen = sizeof(struct sockaddr_storage);
- zts_getpeername(accfd, (struct sockaddr*)&acc_in4, &peer_addrlen);
- DEBUG_INFO("accepted connection from %s : %d", inet_ntoa(acc_in4.sin_addr), ntohs(acc_in4.sin_port));
-*/
-
- printf("reading from client...\n");
- socklen_t addrlen = sizeof(acc_in4);
- memset(&acc_in4, 0, sizeof acc_in4);
-
- while(true) {
- memset(&rbuf, 0, sizeof rbuf);
- r = zts_recvfrom(accfd, rbuf, sizeof(rbuf), flags, (struct sockaddr *)&acc_in4, &addrlen);
- if (r >= 0) {
- char *ip = inet_ntoa(acc_in4.sin_addr);
- printf("Received : r=%d, %s -- from: %s : %d\n", r, rbuf, ip, ntohs(acc_in4.sin_port));
- }
- }
-
-/*
- printf("sending to client...\n");
- w = zts_write(accfd, rbuf, strlen(rbuf));
-
-*/
-
- err = zts_close(sockfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv6adhoc/ipv6adhocclient.cpp b/examples/cpp/ipv6adhoc/ipv6adhocclient.cpp
deleted file mode 100644
index ab1ee0e..0000000
--- a/examples/cpp/ipv6adhoc/ipv6adhocclient.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-
-#include "libzt.h"
-
-char *msg = (char*)"welcome to the machine";
-
-uint64_t generate_adhoc_nwid_from_port(int port)
-{
- std::string padding;
- if(port < 10) {
- padding = "000";
- } else if(port < 100) {
- padding = "00";
- } else if(port < 1000) {
- padding = "0";
- }
- // We will join ad-hoc network ffSSSSEEEE000000
- // Where SSSS = start port
- // EEEE = end port
- padding = padding + std::to_string(port); // SSSS
- std::string nwidstr = "ff" + padding + padding + "000000"; // ff + SSSS + EEEE + 000000
- return strtoull(nwidstr.c_str(), NULL, 16);
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 5) {
- printf("\nlibzt example client\n");
- printf("client [config_file_path] [nwid] [remote_addr] [remote_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- std::string remote_addr = argv[3];
- int remote_port = atoi(argv[4]);
- int r=0, w=0, err=0, sockfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in6 in6;
- in6.sin6_port = htons(remote_port);
- inet_pton(AF_INET6, remote_addr.c_str(), &(in6.sin6_addr));
- in6.sin6_family = AF_INET6;
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = generate_adhoc_nwid_from_port(remote_port);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = zts_connect(sockfd, (const struct sockaddr *)&in6, sizeof(in6))) < 0) {
- printf("error connecting to remote host (%d)\n", err);
- }
-
- printf("sending to server...\n");
- w = zts_write(sockfd, msg, strlen(msg));
-
- printf("reading from server...\n");
- r = zts_read(sockfd, rbuf, strlen(msg));
-
- printf("Sent : %s\n", msg);
- printf("Received : %s\n", rbuf);
-
- err = zts_close(sockfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv6adhoc/ipv6adhocserver.cpp b/examples/cpp/ipv6adhoc/ipv6adhocserver.cpp
deleted file mode 100644
index 512a568..0000000
--- a/examples/cpp/ipv6adhoc/ipv6adhocserver.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-
-#include "libzt.h"
-
-uint64_t generate_adhoc_nwid_from_port(int port)
-{
- std::string padding;
- if(port < 10) {
- padding = "000";
- } else if(port < 100) {
- padding = "00";
- } else if(port < 1000) {
- padding = "0";
- }
- // We will join ad-hoc network ffSSSSEEEE000000
- // Where SSSS = start port
- // EEEE = end port
- padding = padding + std::to_string(port); // SSSS
- std::string nwidstr = "ff" + padding + padding + "000000"; // ff + SSSS + EEEE + 000000
- return strtoull(nwidstr.c_str(), NULL, 16);
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 4) {
- printf("\nlibzt example server\n");
- printf("server [config_file_path] [bind_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- int bind_port = atoi(argv[2]);
- uint64_t nwid = generate_adhoc_nwid_from_port(bind_port);
- int w=0, r=0, err=0, sockfd, accfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in6 in6, acc_in6;
- in6.sin6_port = htons(bind_port);
- in6.sin6_family = AF_INET6;
- in6.sin6_addr = in6addr_any;
-
- fprintf(stderr, "nwid=%llx\n", (unsigned long long)nwid);
- exit(-1);
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- nwid = generate_adhoc_nwid_from_port(bind_port);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = zts_bind(sockfd, (struct sockaddr *)&in6, sizeof(struct sockaddr_in6)) < 0)) {
- printf("error binding to interface (%d)\n", err);
- }
-
- if ((err = zts_listen(sockfd, 100)) < 0) {
- printf("error placing socket in LISTENING state (%d)\n", err);
- }
-
- socklen_t client_addrlen = sizeof(sockaddr_in6);
- if ((accfd = zts_accept(sockfd, (struct sockaddr *)&acc_in6, &client_addrlen)) < 0) {
- printf("error accepting connection (%d)\n", err);
- }
-
- socklen_t peer_addrlen = sizeof(struct sockaddr_storage);
- zts_getpeername(accfd, (struct sockaddr*)&acc_in6, &peer_addrlen);
- //printf("accepted connection from %s : %d", inet_ntoa(acc_in6.sin6_addr), ntohs(acc_in6.sin6_port));
-
- printf("reading from client...\n");
- r = zts_read(accfd, rbuf, sizeof rbuf);
-
- printf("sending to client...\n");
- w = zts_write(accfd, rbuf, strlen(rbuf));
-
- printf("Received : %s\n", rbuf);
-
- err = zts_close(sockfd);
- err = zts_close(accfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv6simple/ipv6client.cpp b/examples/cpp/ipv6simple/ipv6client.cpp
deleted file mode 100644
index 3bf3099..0000000
--- a/examples/cpp/ipv6simple/ipv6client.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-
-#include "libzt.h"
-
-char *msg = (char*)"welcome to the machine";
-
-int main(int argc, char **argv)
-{
- if (argc != 5) {
- printf("\nlibzt example client\n");
- printf("client [config_file_path] [nwid] [remote_addr] [remote_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- std::string remote_addr = argv[3];
- int remote_port = atoi(argv[4]);
- int r=0, w=0, err=0, sockfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in6 in6;
- in6.sin6_port = htons(remote_port);
- inet_pton(AF_INET6, remote_addr.c_str(), &(in6.sin6_addr));
- in6.sin6_family = AF_INET6;
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = zts_connect(sockfd, (const struct sockaddr *)&in6, sizeof(in6))) < 0) {
- printf("error connecting to remote host (%d)\n", err);
- }
-
- printf("sending to server...\n");
- w = zts_write(sockfd, msg, strlen(msg));
-
- printf("reading from server...\n");
- r = zts_read(sockfd, rbuf, strlen(msg));
-
- printf("Sent : %s\n", msg);
- printf("Received : %s\n", rbuf);
-
- err = zts_close(sockfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/ipv6simple/ipv6server.cpp b/examples/cpp/ipv6simple/ipv6server.cpp
deleted file mode 100644
index 7062d4f..0000000
--- a/examples/cpp/ipv6simple/ipv6server.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-
-#if defined(_WIN32)
-#include
-#include
-#else
-#include
-#include
-#include
-#include
-#include
-#endif
-
-#include "libzt.h"
-
-int main(int argc, char **argv)
-{
- if (argc != 4) {
- printf("\nlibzt example server\n");
- printf("server [config_file_path] [nwid] [bind_port]\n");
- exit(0);
- }
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- int bind_port = atoi(argv[3]);
- int w=0, r=0, err=0, sockfd, accfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in6 in6, acc_in6;
- in6.sin6_port = htons(bind_port);
- in6.sin6_family = AF_INET6;
- in6.sin6_addr = in6addr_any;
-
- // --- BEGIN EXAMPLE CODE
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = zts_bind(sockfd, (struct sockaddr *)&in6, sizeof(struct sockaddr_in6)) < 0)) {
- printf("error binding to interface (%d)\n", err);
- }
-
- if ((err = zts_listen(sockfd, 100)) < 0) {
- printf("error placing socket in LISTENING state (%d)\n", err);
- }
-
- socklen_t client_addrlen = sizeof(sockaddr_in6);
- if ((accfd = zts_accept(sockfd, (struct sockaddr *)&acc_in6, &client_addrlen)) < 0) {
- printf("error accepting connection (%d)\n", err);
- }
-
- socklen_t peer_addrlen = sizeof(struct sockaddr_storage);
- zts_getpeername(accfd, (struct sockaddr*)&acc_in6, &peer_addrlen);
- //DEBUG_INFO("accepted connection from %s : %d", inet_ntoa(acc_in6.sin6_addr), ntohs(acc_in6.sin6_port));
-
- printf("reading from client...\n");
- r = zts_read(accfd, rbuf, sizeof rbuf);
-
- printf("sending to client...\n");
- w = zts_write(accfd, rbuf, strlen(rbuf));
-
- printf("Received : %s\n", rbuf);
-
- err = zts_close(sockfd);
- err = zts_close(accfd);
-
- return err;
-}
\ No newline at end of file
diff --git a/examples/cpp/sharedlib/ipv4client_shared.cpp b/examples/cpp/sharedlib/ipv4client_shared.cpp
deleted file mode 100644
index 83a0782..0000000
--- a/examples/cpp/sharedlib/ipv4client_shared.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#if !defined(_MSC_VER)
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "libzt.h"
-
-// function pointers which will have values assigned once the dynamic library is loaded
-
-int (*_zts_set_service_port)(int portno);
-int (*_zts_start)(const char *path, bool blocking);
-int (*_zts_startjoin)(const char*, uint64_t);
-void (*_zts_stop)(void);
-int (*_zts_core_running)(void);
-int (*_zts_stack_running)(void);
-int (*_zts_ready)(void);
-int (*_zts_join)(const uint64_t);
-int (*_zts_leave)(const uint64_t);
-void (*_zts_get_path)(char *homePath, const size_t len);
-uint64_t (*_zts_get_node_id)(void);
-int (*_zts_has_address)(const uint64_t);
-int (*_zts_get_num_assigned_addresses)(const uint64_t nwid);
-int (*_zts_get_address_at_index)(const uint64_t nwid, const int index, struct sockaddr_storage *addr);
-int (*_zts_get_address)(const uint64_t nwid, struct sockaddr_storage *addr, const int address_family);
-void (*_zts_get_6plane_addr)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
-void (*_zts_get_rfc4193_addr)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
-unsigned long (*_zts_get_peer_count)(void);
-int (*_zts_get_peer_address)(char *peer, const uint64_t nodeId);
-int (*_zts_socket)(int socket_family, int socket_type, int protocol);
-int (*_zts_connect)(int fd, const struct sockaddr *addr, socklen_t addrlen);
-int (*_zts_bind)(int fd, const struct sockaddr *addr, socklen_t addrlen);
-int (*_zts_listen)(int fd, int backlog);
-int (*_zts_accept)(int fd, struct sockaddr *addr, socklen_t *addrlen);
-#if defined(__linux__)
-int (*_zts_accept4)(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags);
-#endif
-int (*_zts_setsockopt)(int fd, int level, int optname, const void *optval, socklen_t optlen);
-int (*_zts_getsockopt)(int fd, int level, int optname, void *optval, socklen_t *optlen);
-int (*_zts_getsockname)(int fd, struct sockaddr *addr, socklen_t *addrlen);
-int (*_zts_getpeername)(int fd, struct sockaddr *addr, socklen_t *addrlen);
-int (*_zts_gethostname)(char *name, size_t len);
-int (*_zts_sethostname)(const char *name, size_t len);
-struct hostent *(*_zts_gethostbyname)(const char *name);
-int (*_zts_close)(int fd);
-int(*_zts_fcntl)(int fd, int cmd, int flags);
-int (*_zts_ioctl)(int fd, unsigned long request, void *argp);
-ssize_t (*_zts_send)(int fd, const void *buf, size_t len, int flags);
-ssize_t (*_zts_sendto)(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen);
-ssize_t (*_zts_sendmsg)(int fd, const struct msghdr *msg, int flags);
-ssize_t (*_zts_recv)(int fd, void *buf, size_t len, int flags);
-ssize_t (*_zts_recvfrom)(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen);
-ssize_t (*_zts_recvmsg)(int fd, struct msghdr *msg,int flags);
-int (*_zts_read)(int fd, void *buf, size_t len);
-int (*_zts_write)(int fd, const void *buf, size_t len);
-int (*_zts_shutdown)(int fd, int how);
-int (*_zts_add_dns_nameserver)(struct sockaddr *addr);
-int (*_zts_del_dns_nameserver)(struct sockaddr *addr);
-
-
-void load_library_symbols(char *library_path)
-{
- void *libHandle = dlopen(library_path, RTLD_LAZY);
- if (libHandle == NULL) {
- DEBUG_ERROR("unable to load dynamic libs: %s", dlerror());
- exit(-1);
- }
-
- // Load symbols from library (call these directly)
-
- _zts_set_service_port = (int(*)(int portno))dlsym(libHandle, "zts_set_service_port");
- _zts_start = (int(*)(const char *path, bool blocking))dlsym(libHandle, "zts_start");
- _zts_startjoin = (int(*)(const char*, uint64_t))dlsym(libHandle, "zts_startjoin");
- _zts_stop = (void(*)(void))dlsym(libHandle, "zts_stop");
- _zts_core_running = (int(*)(void))dlsym(libHandle, "zts_core_running");
- _zts_stack_running = (int(*)(void))dlsym(libHandle, "zts_stack_running");
- _zts_ready = (int(*)(void))dlsym(libHandle, "zts_ready");
- _zts_join = (int(*)(const uint64_t))dlsym(libHandle, "zts_join");
- _zts_leave = (int(*)(const uint64_t))dlsym(libHandle, "zts_leave");
- _zts_get_path = (void(*)(char *homePath, const size_t len))dlsym(libHandle, "zts_get_path");
- _zts_get_node_id = (uint64_t(*)(void))dlsym(libHandle, "zts_get_node_id");
- _zts_has_address = (int(*)(const uint64_t))dlsym(libHandle, "zts_has_address");
- _zts_get_num_assigned_addresses = (int(*)(const uint64_t nwid))dlsym(libHandle, "zts_get_num_assigned_addresses");
- _zts_get_address_at_index = (int(*)(const uint64_t nwid, const int index, struct sockaddr_storage *addr))dlsym(libHandle, "zts_get_address_at_index");
- _zts_get_address = (int(*)(const uint64_t nwid, struct sockaddr_storage *addr, const int address_family))dlsym(libHandle, "zts_get_address");
- _zts_get_6plane_addr = (void(*)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId))dlsym(libHandle, "zts_get_6plane_addr");
- _zts_get_rfc4193_addr = (void(*)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId))dlsym(libHandle, "zts_get_rfc4193_addr");
- _zts_get_peer_count = (unsigned long(*)(void))dlsym(libHandle, "zts_get_peer_count");
- _zts_get_peer_address = (int(*)(char *peer, const uint64_t nodeId))dlsym(libHandle, "zts_get_peer_address");
- _zts_socket = (int(*)(int socket_family, int socket_type, int protocol))dlsym(libHandle, "zts_socket");
- _zts_connect = (int(*)(int fd, const struct sockaddr *addr, socklen_t addrlen))dlsym(libHandle, "zts_connect");
- _zts_bind = (int(*)(int fd, const struct sockaddr *addr, socklen_t addrlen))dlsym(libHandle, "zts_bind");
- _zts_listen = (int(*)(int fd, int backlog))dlsym(libHandle, "zts_listen");
- _zts_accept = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_accept");
- #if defined(__linux__)
- _zts_accept4 = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags))dlsym(libHandle, "zts_accept4");
- #endif
- _zts_setsockopt = (int(*)(int fd, int level, int optname, const void *optval, socklen_t optlen))dlsym(libHandle, "zts_setsockopt");
- _zts_getsockopt = (int(*)(int fd, int level, int optname, void *optval, socklen_t *optlen))dlsym(libHandle, "zts_getsockopt");
- _zts_getsockname = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_getsockname");
- _zts_getpeername = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_getpeername");
- _zts_gethostname = (int(*)(char *name, size_t len))dlsym(libHandle, "zts_gethostname");
- _zts_sethostname = (int(*)(const char *name, size_t len))dlsym(libHandle, "zts_sethostname");
- _zts_gethostbyname = (struct hostent*(*)(const char *name))dlsym(libHandle, "zts_gethostbyname");
- _zts_close = (int(*)(int fd))dlsym(libHandle, "zts_close");
- _zts_fcntl = (int(*)(int fd, int cmd, int flags))dlsym(libHandle, "zts_fcntl");
- _zts_ioctl = (int(*)(int fd, unsigned long request, void *argp))dlsym(libHandle, "zts_ioctl");
- _zts_send = (ssize_t(*)(int fd, const void *buf, size_t len, int flags))dlsym(libHandle, "zts_send");
- _zts_sendto = (ssize_t(*)(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen))dlsym(libHandle, "zts_sendto");
- _zts_sendmsg = (ssize_t(*)(int fd, const struct msghdr *msg, int flags))dlsym(libHandle, "zts_sendmsg");
- _zts_recv = (ssize_t(*)(int fd, void *buf, size_t len, int flags))dlsym(libHandle, "zts_recv");
- _zts_recvfrom = (ssize_t(*)(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_recvfrom");
- _zts_recvmsg = (ssize_t(*)(int fd, struct msghdr *msg,int flags))dlsym(libHandle, "zts_recvmsg");
- _zts_read = (int(*)(int fd, void *buf, size_t len))dlsym(libHandle, "zts_read");
- _zts_write = (int(*)(int fd, const void *buf, size_t len))dlsym(libHandle, "zts_write");
- _zts_shutdown = (int(*)(int fd, int how))dlsym(libHandle, "zts_shutdown");
- _zts_add_dns_nameserver = (int(*)(struct sockaddr *addr))dlsym(libHandle, "zts_add_dns_nameserver");
-}
-
-char *msg = (char*)"welcome to the machine";
-
-int main(int argc, char **argv)
-{
- if (argc != 5) {
- printf("\nlibzt example client\n");
- printf("client [config_file_path] [nwid] [remote_addr] [remote_port]\n");
- exit(0);
- }
-
-#ifdef __linux__
- char *library_path = (char*)"./libzt.so";
-#endif
-#ifdef __APPLE__
- char *library_path = (char*)"./libzt.dylib";
-#endif
- load_library_symbols(library_path);
-
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- std::string remote_addr = argv[3];
- int remote_port = atoi(argv[4]);
- int r=0, w=0, err=0, sockfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in in4;
- in4.sin_port = htons(remote_port);
- in4.sin_addr.s_addr = inet_addr(remote_addr.c_str());
- in4.sin_family = AF_INET;
-
- //
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- _zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = _zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = _zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
-
- if ((err = _zts_connect(sockfd, (const struct sockaddr *)&in4, sizeof(in4))) < 0) {
- printf("error connecting to remote host (%d)\n", err);
- }
-
- printf("sending to server...\n");
- w = _zts_write(sockfd, msg, strlen(msg));
-
- printf("reading from server...\n");
- r = _zts_read(sockfd, rbuf, strlen(msg));
-
- printf("Sent : %s\n", msg);
- printf("Received : %s\n", rbuf);
-
- err = _zts_close(sockfd);
-
- return err;
-}
-
-#endif // _MSC_VER
\ No newline at end of file
diff --git a/examples/cpp/sharedlib/ipv4server_shared.cpp b/examples/cpp/sharedlib/ipv4server_shared.cpp
deleted file mode 100644
index e5262cb..0000000
--- a/examples/cpp/sharedlib/ipv4server_shared.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * ZeroTier SDK - Network Virtualization Everywhere
- * Copyright (C) 2011-2017 ZeroTier, Inc. https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#if !defined(_MSC_VER)
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "libzt.h"
-
-// function pointers which will have values assigned once the dynamic library is loaded
-
-int (*_zts_set_service_port)(int portno);
-int (*_zts_start)(const char *path, bool blocking);
-int (*_zts_startjoin)(const char*, uint64_t);
-void (*_zts_stop)(void);
-int (*_zts_core_running)(void);
-int (*_zts_stack_running)(void);
-int (*_zts_ready)(void);
-int (*_zts_join)(const uint64_t);
-int (*_zts_leave)(const uint64_t);
-void (*_zts_get_path)(char *homePath, const size_t len);
-uint64_t (*_zts_get_node_id)(void);
-int (*_zts_has_address)(const uint64_t);
-int (*_zts_get_num_assigned_addresses)(const uint64_t nwid);
-int (*_zts_get_address_at_index)(const uint64_t nwid, const int index, struct sockaddr_storage *addr);
-int (*_zts_get_address)(const uint64_t nwid, struct sockaddr_storage *addr, const int address_family);
-void (*_zts_get_6plane_addr)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
-void (*_zts_get_rfc4193_addr)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId);
-unsigned long (*_zts_get_peer_count)(void);
-int (*_zts_get_peer_address)(char *peer, const uint64_t nodeId);
-int (*_zts_socket)(int socket_family, int socket_type, int protocol);
-int (*_zts_connect)(int fd, const struct sockaddr *addr, socklen_t addrlen);
-int (*_zts_bind)(int fd, const struct sockaddr *addr, socklen_t addrlen);
-int (*_zts_listen)(int fd, int backlog);
-int (*_zts_accept)(int fd, struct sockaddr *addr, socklen_t *addrlen);
-#if defined(__linux__)
-int (*_zts_accept4)(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags);
-#endif
-int (*_zts_setsockopt)(int fd, int level, int optname, const void *optval, socklen_t optlen);
-int (*_zts_getsockopt)(int fd, int level, int optname, void *optval, socklen_t *optlen);
-int (*_zts_getsockname)(int fd, struct sockaddr *addr, socklen_t *addrlen);
-int (*_zts_getpeername)(int fd, struct sockaddr *addr, socklen_t *addrlen);
-int (*_zts_gethostname)(char *name, size_t len);
-int (*_zts_sethostname)(const char *name, size_t len);
-struct hostent *(*_zts_gethostbyname)(const char *name);
-int (*_zts_close)(int fd);
-int(*_zts_fcntl)(int fd, int cmd, int flags);
-int (*_zts_ioctl)(int fd, unsigned long request, void *argp);
-ssize_t (*_zts_send)(int fd, const void *buf, size_t len, int flags);
-ssize_t (*_zts_sendto)(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen);
-ssize_t (*_zts_sendmsg)(int fd, const struct msghdr *msg, int flags);
-ssize_t (*_zts_recv)(int fd, void *buf, size_t len, int flags);
-ssize_t (*_zts_recvfrom)(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen);
-ssize_t (*_zts_recvmsg)(int fd, struct msghdr *msg,int flags);
-int (*_zts_read)(int fd, void *buf, size_t len);
-int (*_zts_write)(int fd, const void *buf, size_t len);
-int (*_zts_shutdown)(int fd, int how);
-int (*_zts_add_dns_nameserver)(struct sockaddr *addr);
-int (*_zts_del_dns_nameserver)(struct sockaddr *addr);
-
-
-void load_library_symbols(char *library_path)
-{
- void *libHandle = dlopen(library_path, RTLD_LAZY);
- if (libHandle == NULL) {
- DEBUG_ERROR("unable to load dynamic libs: %s", dlerror());
- exit(-1);
- }
-
- // Load symbols from library (call these directly)
-
- _zts_set_service_port = (int(*)(int portno))dlsym(libHandle, "zts_set_service_port");
- _zts_start = (int(*)(const char *path, bool blocking))dlsym(libHandle, "zts_start");
- _zts_startjoin = (int(*)(const char*, uint64_t))dlsym(libHandle, "zts_startjoin");
- _zts_stop = (void(*)(void))dlsym(libHandle, "zts_stop");
- _zts_core_running = (int(*)(void))dlsym(libHandle, "zts_core_running");
- _zts_stack_running = (int(*)(void))dlsym(libHandle, "zts_stack_running");
- _zts_ready = (int(*)(void))dlsym(libHandle, "zts_ready");
- _zts_join = (int(*)(const uint64_t))dlsym(libHandle, "zts_join");
- _zts_leave = (int(*)(const uint64_t))dlsym(libHandle, "zts_leave");
- _zts_get_path = (void(*)(char *homePath, const size_t len))dlsym(libHandle, "zts_get_path");
- _zts_get_node_id = (uint64_t(*)(void))dlsym(libHandle, "zts_get_node_id");
- _zts_has_address = (int(*)(const uint64_t))dlsym(libHandle, "zts_has_address");
- _zts_get_num_assigned_addresses = (int(*)(const uint64_t nwid))dlsym(libHandle, "zts_get_num_assigned_addresses");
- _zts_get_address_at_index = (int(*)(const uint64_t nwid, const int index, struct sockaddr_storage *addr))dlsym(libHandle, "zts_get_address_at_index");
- _zts_get_address = (int(*)(const uint64_t nwid, struct sockaddr_storage *addr, const int address_family))dlsym(libHandle, "zts_get_address");
- _zts_get_6plane_addr = (void(*)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId))dlsym(libHandle, "zts_get_6plane_addr");
- _zts_get_rfc4193_addr = (void(*)(struct sockaddr_storage *addr, const uint64_t nwid, const uint64_t nodeId))dlsym(libHandle, "zts_get_rfc4193_addr");
- _zts_get_peer_count = (unsigned long(*)(void))dlsym(libHandle, "zts_get_peer_count");
- _zts_get_peer_address = (int(*)(char *peer, const uint64_t nodeId))dlsym(libHandle, "zts_get_peer_address");
- _zts_socket = (int(*)(int socket_family, int socket_type, int protocol))dlsym(libHandle, "zts_socket");
- _zts_connect = (int(*)(int fd, const struct sockaddr *addr, socklen_t addrlen))dlsym(libHandle, "zts_connect");
- _zts_bind = (int(*)(int fd, const struct sockaddr *addr, socklen_t addrlen))dlsym(libHandle, "zts_bind");
- _zts_listen = (int(*)(int fd, int backlog))dlsym(libHandle, "zts_listen");
- _zts_accept = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_accept");
- #if defined(__linux__)
- _zts_accept4 = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags))dlsym(libHandle, "zts_accept4");
- #endif
- _zts_setsockopt = (int(*)(int fd, int level, int optname, const void *optval, socklen_t optlen))dlsym(libHandle, "zts_setsockopt");
- _zts_getsockopt = (int(*)(int fd, int level, int optname, void *optval, socklen_t *optlen))dlsym(libHandle, "zts_getsockopt");
- _zts_getsockname = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_getsockname");
- _zts_getpeername = (int(*)(int fd, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_getpeername");
- _zts_gethostname = (int(*)(char *name, size_t len))dlsym(libHandle, "zts_gethostname");
- _zts_sethostname = (int(*)(const char *name, size_t len))dlsym(libHandle, "zts_sethostname");
- _zts_gethostbyname = (struct hostent*(*)(const char *name))dlsym(libHandle, "zts_gethostbyname");
- _zts_close = (int(*)(int fd))dlsym(libHandle, "zts_close");
- _zts_fcntl = (int(*)(int fd, int cmd, int flags))dlsym(libHandle, "zts_fcntl");
- _zts_ioctl = (int(*)(int fd, unsigned long request, void *argp))dlsym(libHandle, "zts_ioctl");
- _zts_send = (ssize_t(*)(int fd, const void *buf, size_t len, int flags))dlsym(libHandle, "zts_send");
- _zts_sendto = (ssize_t(*)(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen))dlsym(libHandle, "zts_sendto");
- _zts_sendmsg = (ssize_t(*)(int fd, const struct msghdr *msg, int flags))dlsym(libHandle, "zts_sendmsg");
- _zts_recv = (ssize_t(*)(int fd, void *buf, size_t len, int flags))dlsym(libHandle, "zts_recv");
- _zts_recvfrom = (ssize_t(*)(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen))dlsym(libHandle, "zts_recvfrom");
- _zts_recvmsg = (ssize_t(*)(int fd, struct msghdr *msg,int flags))dlsym(libHandle, "zts_recvmsg");
- _zts_read = (int(*)(int fd, void *buf, size_t len))dlsym(libHandle, "zts_read");
- _zts_write = (int(*)(int fd, const void *buf, size_t len))dlsym(libHandle, "zts_write");
- _zts_shutdown = (int(*)(int fd, int how))dlsym(libHandle, "zts_shutdown");
- _zts_add_dns_nameserver = (int(*)(struct sockaddr *addr))dlsym(libHandle, "zts_add_dns_nameserver");
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 4) {
- printf("\nlibzt example server\n");
- printf("server [config_file_path] [nwid] [bind_port]\n");
- exit(0);
- }
-
-#ifdef __linux__
- char *library_path = (char*)"./libzt.so";
-#endif
-#ifdef __APPLE__
- char *library_path = (char*)"./libzt.dylib";
-#endif
- load_library_symbols(library_path);
-
- std::string path = argv[1];
- std::string nwidstr = argv[2];
- int bind_port = atoi(argv[3]);
- int w=0, r=0, err=0, sockfd, accfd;
- char rbuf[32];
- memset(rbuf, 0, sizeof rbuf);
-
- struct sockaddr_in in4, acc_in4;
- in4.sin_port = htons(bind_port);
- in4.sin_addr.s_addr = INADDR_ANY;
- in4.sin_family = AF_INET;
-
- //
-
- printf("Waiting for libzt to come online...\n");
- uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
- printf("nwid=%llx\n", (unsigned long long)nwid);
- _zts_startjoin(path.c_str(), nwid);
- uint64_t nodeId = _zts_get_node_id();
- printf("I am %llx\n", (unsigned long long)nodeId);
-
- if ((sockfd = _zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- printf("error creating ZeroTier socket\n");
- }
- if ((err = _zts_bind(sockfd, (struct sockaddr *)&in4, sizeof(struct sockaddr_in)) < 0)) {
- printf("error binding to interface (%d)\n", err);
- }
- if ((err = _zts_listen(sockfd, 100)) < 0) {
- printf("error placing socket in LISTENING state (%d)\n", err);
- }
- socklen_t client_addrlen = sizeof(sockaddr_in);
- if ((accfd = _zts_accept(sockfd, (struct sockaddr *)&acc_in4, &client_addrlen)) < 0) {
- printf("error accepting connection (%d)\n", err);
- }
-
- socklen_t peer_addrlen = sizeof(struct sockaddr_storage);
- _zts_getpeername(accfd, (struct sockaddr*)&acc_in4, &peer_addrlen);
- DEBUG_INFO("accepted connection from %s : %d\n", inet_ntoa(acc_in4.sin_addr), ntohs(acc_in4.sin_port));
-
- printf("reading from client...\n");
- r = _zts_read(accfd, rbuf, sizeof rbuf);
-
- printf("sending to client...\n");
- w = _zts_write(accfd, rbuf, strlen(rbuf));
-
- printf("Received : %s\n", rbuf);
-
- err = _zts_close(sockfd);
- err = _zts_close(accfd);
-
- return err;
-}
-
-#endif // _MSC_VER
diff --git a/test/example.cpp b/test/example.cpp
deleted file mode 100644
index 11ff33c..0000000
--- a/test/example.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-#include
-#include
-#include
-#include
-
-#include "ZeroTier.h"
-
-bool node_ready = false;
-bool network_ready = false;
-
-// Example callbacks
-void myZeroTierEventCallback(struct zts_callback_msg *msg)
-{
- //
- // Node events
- //
- if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
- printf("ZTS_EVENT_NODE_ONLINE, node=%llx\n", msg->node->address);
- node_ready = true;
- // ZeroTier service is running and online
- }
- if (msg->eventCode == ZTS_EVENT_NODE_OFFLINE) {
- printf("ZTS_EVENT_NODE_OFFLINE\n");
- node_ready = false;
- // ZeroTier service is running and online
- }
- if (msg->eventCode == ZTS_EVENT_NODE_NORMAL_TERMINATION) {
- printf("ZTS_EVENT_NODE_NORMAL_TERMINATION\n");
- // ZeroTier service has stopped
- }
-
- //
- // Virtual network events
- //
- if (msg->eventCode == ZTS_EVENT_NETWORK_NOT_FOUND) {
- printf("ZTS_EVENT_NETWORK_NOT_FOUND --- network=%llx\n", msg->network->nwid);
- // Is your nwid incorrect?
- }
- if (msg->eventCode == ZTS_EVENT_NETWORK_REQUESTING_CONFIG) {
- printf("ZTS_EVENT_NETWORK_REQUESTING_CONFIG --- network=%llx\n", msg->network->nwid);
- // Node is requesting network config details from controller, please wait
- }
- if (msg->eventCode == ZTS_EVENT_NETWORK_ACCESS_DENIED) {
- printf("ZTS_EVENT_NETWORK_ACCESS_DENIED --- network=%llx\n", msg->network->nwid);
- // This node is not authorized to join nwid
- }
- if (msg->eventCode == ZTS_EVENT_NETWORK_READY_IP4) {
- printf("ZTS_EVENT_NETWORK_READY_IP4 --- network=%llx\n", msg->network->nwid);
- network_ready = true;
- // IPv4 traffic can now be processed for nwid
- }
- if (msg->eventCode == ZTS_EVENT_NETWORK_READY_IP6) {
- printf("ZTS_EVENT_NETWORK_READY_IP6 --- network=%llx\n", msg->network->nwid);
- network_ready = true;
- }
- if (msg->eventCode == ZTS_EVENT_NETWORK_DOWN) {
- printf("ZTS_EVENT_NETWORK_DOWN --- network=%llx\n", msg->network->nwid);
- // Can happen if another thread called zts_leave()
- }
-
- //
- // Network stack events
- //
- if (msg->eventCode == ZTS_EVENT_NETIF_UP) {
- printf("ZTS_EVENT_NETIF_UP --- network=%llx, mac=%llx, mtu=%d\n",
- msg->netif->nwid,
- msg->netif->mac,
- msg->netif->mtu);
- network_ready = true;
- }
- if (msg->eventCode == ZTS_EVENT_NETIF_DOWN) {
- printf("ZTS_EVENT_NETIF_DOWN --- network=%llx, mac=%llx\n",
- msg->netif->nwid,
- msg->netif->mac);
-
- network_ready = true;
- }
-
- //
- // Address events
- //
- if (msg->eventCode == ZTS_EVENT_ADDR_ADDED_IP4) {
- char ipstr[INET_ADDRSTRLEN];
- struct sockaddr_in *in4 = (struct sockaddr_in*)&(msg->addr->addr);
- inet_ntop(AF_INET, &(in4->sin_addr), ipstr, INET_ADDRSTRLEN);
- printf("ZTS_EVENT_ADDR_NEW_IP4 --- addr=%s (on network=%llx)\n",
- ipstr, msg->addr->nwid);
- }
- if (msg->eventCode == ZTS_EVENT_ADDR_ADDED_IP6) {
- char ipstr[INET6_ADDRSTRLEN];
- struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&(msg->addr->addr);
- inet_ntop(AF_INET6, &(in6->sin6_addr), ipstr, INET6_ADDRSTRLEN);
- printf("ZTS_EVENT_ADDR_NEW_IP6 --- addr=%s (on network=%llx)\n",
- ipstr, msg->addr->nwid);
- }
- if (msg->eventCode == ZTS_EVENT_ADDR_REMOVED_IP4) {
- char ipstr[INET_ADDRSTRLEN];
- struct sockaddr_in *in4 = (struct sockaddr_in*)&(msg->addr->addr);
- inet_ntop(AF_INET, &(in4->sin_addr), ipstr, INET_ADDRSTRLEN);
- printf("ZTS_EVENT_ADDR_REMOVED_IP4 --- addr=%s (on network=%llx)\n",
- ipstr, msg->addr->nwid);
- }
- if (msg->eventCode == ZTS_EVENT_ADDR_REMOVED_IP6) {
- char ipstr[INET6_ADDRSTRLEN];
- struct sockaddr_in6 *in6 = (struct sockaddr_in6*)&(msg->addr->addr);
- inet_ntop(AF_INET6, &(in6->sin6_addr), ipstr, INET6_ADDRSTRLEN);
- printf("ZTS_EVENT_ADDR_REMOVED_IP6 --- addr=%s (on network=%llx)\n",
- ipstr, msg->addr->nwid);
- }
-
- //
- // Peer events
- //
- if (msg->eventCode == ZTS_EVENT_PEER_P2P) {
- printf("ZTS_EVENT_PEER_P2P --- node=%llx\n", msg->peer->address);
- // A direct path is known for nodeId
- }
- if (msg->eventCode == ZTS_EVENT_PEER_RELAY) {
- printf("ZTS_EVENT_PEER_RELAY --- node=%llx\n", msg->peer->address);
- // No direct path is known for nodeId
- }
-}
-
-void printPeerDetails(struct zts_peer_details *pd)
-{
- printf("\npeer=%llx, latency=%d, version=%d.%d.%d, pathCount=%d\n",
- pd->address,
- pd->latency,
- pd->versionMajor,
- pd->versionMinor,
- pd->versionRev,
- pd->pathCount);
- // Print all known paths for each peer
- for (int j=0; jpathCount; j++) {
- char ipstr[INET6_ADDRSTRLEN];
- int port;
- struct sockaddr *sa = (struct sockaddr *)&(pd->paths[j].address);
- if (sa->sa_family == AF_INET) {
- struct sockaddr_in *in4 = (struct sockaddr_in*)sa;
- inet_ntop(AF_INET, &(in4->sin_addr), ipstr, INET_ADDRSTRLEN);
- port = ntohs(in4->sin_port);
- }
- if (sa->sa_family == AF_INET6) {
- struct sockaddr_in6 *in6 = (struct sockaddr_in6*)sa;
- inet_ntop(AF_INET6, &(in6->sin6_addr), ipstr, INET6_ADDRSTRLEN);
- }
- printf("\tpath[%d]=%s, port=%d\n", j, ipstr, port);
- }
-}
-
-void getSinglePeerDetails(uint64_t peerId)
-{
- struct zts_peer_details pd;
- int err = zts_get_peer(&pd, peerId);
-
- if (err == ZTS_ERR_OK) {
- printf("(%d) call succeeded\n", err);
- } if (err == ZTS_ERR_INVALID_ARG) {
- printf("(%d) invalid argument\n", err);
- return;
- } if (err == ZTS_ERR_SERVICE) {
- printf("(%d) error: service is unavailable\n", err);
- return;
- } if (err == ZTS_ERR_INVALID_OP) {
- printf("(%d) error: invalid API operation\n", err);
- return;
- } if (err == ZTS_ERR_NO_RESULT) {
- printf("(%d) error: object or result not found\n", err);
- return;
- }
- if (err == 0) { // ZTS_ERR_OK
- printPeerDetails(&pd);
- }
-}
-
-// Similar to "zerotier-cli listpeers"
-void getAllPeerDetails()
-{
- struct zts_peer_details pd[128];
- /* This number should be large enough to handle the
- expected number of peers. This call can also get
- expensive for large numbers of peers. Consider using
- get_peer(struct zts_peer_details *pds, uint64_t peerId)
- instead */
- int num = 128;
- int err;
- if ((err = zts_get_peers(pd, &num)) < 0) {
- printf("error (%d)\n", err);
- return;
- }
- if (num) {
- printf("num=%d\n", num);
- for (int i=0; i.
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include