upgraded core to 1.2.0
This commit is contained in:
@@ -1,91 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(ZeroTierOneJNI)
|
||||
|
||||
find_package(Java COMPONENTS Development)
|
||||
message("JAVA_HOME: $ENV{JAVA_HOME}")
|
||||
|
||||
if(WIN32)
|
||||
set(Java_INCLUDE_DIRS $ENV{JAVA_HOME}/include)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(Java_INCLUDE_DIRS "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/JavaVM.framework/Headers")
|
||||
endif()
|
||||
|
||||
message("Java Include Dirs: ${Java_INCLUDE_DIRS}")
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DNOMINMAX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W3 /MP")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386 -arch x86_64 -Wall -O3 -flto -fPIE -fvectorize -fstack-protector -mmacosx-version-min=10.7 -Wno-unused-private-field")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti")
|
||||
endif()
|
||||
|
||||
set(src_files
|
||||
../ext/lz4/lz4.c
|
||||
../ext/json-parser/json.c
|
||||
../ext/http-parser/http_parser.c
|
||||
../node/C25519.cpp
|
||||
../node/CertificateOfMembership.cpp
|
||||
../node/Defaults.cpp
|
||||
../node/Dictionary.cpp
|
||||
../node/Identity.cpp
|
||||
../node/IncomingPacket.cpp
|
||||
../node/InetAddress.cpp
|
||||
../node/Multicaster.cpp
|
||||
../node/Network.cpp
|
||||
../node/NetworkConfig.cpp
|
||||
../node/Node.cpp
|
||||
../node/OutboundMulticast.cpp
|
||||
../node/Packet.cpp
|
||||
../node/Peer.cpp
|
||||
../node/Poly1305.cpp
|
||||
../node/Salsa20.cpp
|
||||
../node/SelfAwareness.cpp
|
||||
../node/SHA512.cpp
|
||||
../node/Switch.cpp
|
||||
../node/Topology.cpp
|
||||
../node/Utils.cpp
|
||||
../osdep/Http.cpp
|
||||
../osdep/OSUtils.cpp
|
||||
jni/com_zerotierone_sdk_Node.cpp
|
||||
jni/ZT_jniutils.cpp
|
||||
jni/ZT_jnicache.cpp
|
||||
)
|
||||
|
||||
set(include_dirs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../include/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../node/
|
||||
${Java_INCLUDE_DIRS})
|
||||
|
||||
if(WIN32)
|
||||
set(include_dirs
|
||||
${include_dirs}
|
||||
${Java_INCLUDE_DIRS}/win32)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${include_dirs}
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED ${src_files})
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".jnilib")
|
||||
endif()
|
||||
|
||||
set(link_libs )
|
||||
|
||||
if(WIN32)
|
||||
set(link_libs
|
||||
wsock32
|
||||
ws2_32
|
||||
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} ${link_libs})
|
||||
@@ -1,17 +0,0 @@
|
||||
ZeroTier One SDK - Android JNI Wrapper
|
||||
=====
|
||||
|
||||
|
||||
Building
|
||||
-----
|
||||
|
||||
Reqires:
|
||||
|
||||
* JDK
|
||||
* ANT
|
||||
* Android NDK
|
||||
|
||||
Required Environment Variables:
|
||||
|
||||
* NDK\_BUILD\_LOC - Path do the ndk-build script in the Android NDK
|
||||
* ANDROID\_PLATFORM - path to the directory android.jar lives (on Windows: C:\Users\<username>\AppData\Local\Android\sdk\platforms\android-21)
|
||||
@@ -1,118 +0,0 @@
|
||||
<project default="build_jar" name="ZeroTierOneSDK" basedir=".">
|
||||
<property environment="env"/>
|
||||
|
||||
<condition property="isWindows">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
|
||||
<condition property="isMac">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
|
||||
<target name="clean_ant">
|
||||
<delete dir="bin" failonerror="false"/>
|
||||
<delete dir="classes" failonerror="false"/>
|
||||
<delete dir="build_win32" failonerror="false"/>
|
||||
<delete dir="build_win64" failonerror="false"/>
|
||||
<delete dir="mac32_64" failonerror="false"/>
|
||||
<delete dir="libs" failonerror="false"/>
|
||||
<delete dir="obj" failonerror="false"/>
|
||||
</target>
|
||||
|
||||
<target name="build_java">
|
||||
<echo message="os.name = ${os.name}"/>
|
||||
<echo message="os.arch = ${os.arch}"/>
|
||||
<echo message="ant.java.version = ${ant.java.version}"/>
|
||||
<echo message="java.version = ${java.version}"/>
|
||||
<echo message="ndk.loc = ${env.NDK_BUILD_LOC}"/>
|
||||
<echo message="sdk.loc = ${env.ANDROID_PLATFORM}"/>
|
||||
<echo message="user.dir = ${user.dir}"/>
|
||||
<echo message="zt1.dir = ${env.ZT}"/>
|
||||
<mkdir dir="bin"/>
|
||||
<mkdir dir="classes"/>
|
||||
<javac srcdir="src"
|
||||
destdir="classes"
|
||||
source="1.7"
|
||||
target="1.7"
|
||||
classpath="${env.ANDROID_PLATFORM}/android.jar"
|
||||
includeantruntime="false"/>
|
||||
</target>
|
||||
|
||||
<target name="build_android">
|
||||
<exec dir="jni" executable="${env.NDK_BUILD_LOC}" failonerror="true">
|
||||
<arg value="ZT1=${env.ZT}"/>
|
||||
<arg value="V=1"/>
|
||||
<!-- <arg value="NDK_DEBUG=1"/> -->
|
||||
</exec>
|
||||
<copy file="libs/arm64-v8a/libZeroTierOneJNI.so"
|
||||
tofile="classes/lib/arm64-v8a/libZeroTierOneJNI.so"
|
||||
overwrite="true"/>
|
||||
<copy file="libs/armeabi/libZeroTierOneJNI.so"
|
||||
tofile="classes/lib/armeabi/libZeroTierOneJNI.so"
|
||||
overwrite="true"/>
|
||||
<copy file="libs/armeabi-v7a/libZeroTierOneJNI.so"
|
||||
tofile="classes/lib/armeabi-v7a/libZeroTierOneJNI.so"
|
||||
overwrite="true"/>
|
||||
<copy file="libs/mips/libZeroTierOneJNI.so"
|
||||
tofile="classes/lib/mips/libZeroTierOneJNI.so"
|
||||
overwrite="true"/>
|
||||
<copy file="libs/mips64/libZeroTierOneJNI.so"
|
||||
tofile="classes/lib/mips64/libZeroTierOne.so"
|
||||
overwrite="true"/>
|
||||
<copy file="libs/x86/libZeroTierOneJNI.so"
|
||||
tofile="classes/lib/x86/libZeroTierOneJNI.so"
|
||||
overwrite="true"/>
|
||||
<copy file="libs/x86_64/libZeroTierOneJNI.so"
|
||||
tofile="classes/lib/x86_64/libZeroTierOneJNI.so"
|
||||
overwrite="true"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="windows" if="isWindows">
|
||||
<mkdir dir="build_win32"/>
|
||||
<exec dir="build_win32/" executable="cmake" failonerror="true">
|
||||
<arg line=".. -G"Visual Studio 11 2012" -DCMAKE_BUILD_TYPE=Release"/>
|
||||
</exec>
|
||||
<exec dir="build_win32/" executable="cmake" failonerror="true">
|
||||
<arg line="--build . --config Release"/>
|
||||
</exec>
|
||||
<copy file="build_win32/Release/ZeroTierOneJNI.dll"
|
||||
tofile="classes/lib/ZeroTierOneJNI_win32.dll"
|
||||
overwrite="true"/>
|
||||
|
||||
<mkdir dir="build_win64"/>
|
||||
<exec dir="build_win64/" executable="cmake" failonerror="true">
|
||||
<arg line=".. -G"Visual Studio 11 2012 Win64" -DCMAKE_BUILD_TYPE=Release"/>
|
||||
</exec>
|
||||
<exec dir="build_win64/" executable="cmake" failonerror="true">
|
||||
<arg line="--build . --config Release"/>
|
||||
</exec>
|
||||
<copy file="build_win64/Release/ZeroTierOneJNI.dll"
|
||||
tofile="classes/lib/ZeroTierOneJNI_win64.dll"
|
||||
overwrite="true"/>
|
||||
</target>
|
||||
|
||||
<target name="mac" if="isMac">
|
||||
<mkdir dir="mac32_64"/>
|
||||
<exec dir="mac32_64/" executable="cmake" failonerror="true">
|
||||
<arg line=".. -DCMAKE_BUILD_TYPE=Release"/>
|
||||
</exec>
|
||||
<exec dir="mac32_64/" executable="cmake" failonerror="true">
|
||||
<arg line="--build . --config Release"/>
|
||||
</exec>
|
||||
<copy file="mac32_64/libZeroTierOneJNI.jnilib"
|
||||
tofile="classes/lib/libZeroTierOneJNI.jnilib"
|
||||
overwrite="true"/>
|
||||
</target>
|
||||
|
||||
<target name="build_jar" depends="build_java,build_android,windows,mac">
|
||||
<jar destfile="bin/ZeroTierOneSDK.jar" basedir="classes"/>
|
||||
</target>
|
||||
|
||||
<target name="docs">
|
||||
<echo message="Generating Javadocs"/>
|
||||
<mkdir dir="doc/"/>
|
||||
<javadoc sourcepath="src/"
|
||||
destdir="doc/"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,46 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := ZeroTierOneJNI
|
||||
LOCAL_C_INCLUDES := $(ZT1)/include
|
||||
LOCAL_C_INCLUDES += $(ZT1)/node
|
||||
LOCAL_LDLIBS := -llog -latomic
|
||||
# LOCAL_CFLAGS := -g
|
||||
|
||||
# ZeroTierOne SDK source files
|
||||
LOCAL_SRC_FILES := \
|
||||
$(ZT1)/node/C25519.cpp \
|
||||
$(ZT1)/node/Capability.cpp \
|
||||
$(ZT1)/node/CertificateOfMembership.cpp \
|
||||
$(ZT1)/node/CertificateOfOwnership.cpp \
|
||||
$(ZT1)/node/Identity.cpp \
|
||||
$(ZT1)/node/IncomingPacket.cpp \
|
||||
$(ZT1)/node/InetAddress.cpp \
|
||||
$(ZT1)/node/Membership.cpp \
|
||||
$(ZT1)/node/Multicaster.cpp \
|
||||
$(ZT1)/node/Network.cpp \
|
||||
$(ZT1)/node/NetworkConfig.cpp \
|
||||
$(ZT1)/node/Node.cpp \
|
||||
$(ZT1)/node/OutboundMulticast.cpp \
|
||||
$(ZT1)/node/Packet.cpp \
|
||||
$(ZT1)/node/Path.cpp \
|
||||
$(ZT1)/node/Peer.cpp \
|
||||
$(ZT1)/node/Poly1305.cpp \
|
||||
$(ZT1)/node/Revocation.cpp \
|
||||
$(ZT1)/node/Salsa20.cpp \
|
||||
$(ZT1)/node/SelfAwareness.cpp \
|
||||
$(ZT1)/node/SHA512.cpp \
|
||||
$(ZT1)/node/Switch.cpp \
|
||||
$(ZT1)/node/Tag.cpp \
|
||||
$(ZT1)/node/Topology.cpp \
|
||||
$(ZT1)/node/Utils.cpp
|
||||
|
||||
|
||||
# JNI Files
|
||||
LOCAL_SRC_FILES += \
|
||||
com_zerotierone_sdk_Node.cpp \
|
||||
ZT_jniutils.cpp \
|
||||
ZT_jnilookup.cpp
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
@@ -1,5 +0,0 @@
|
||||
# NDK_TOOLCHAIN_VERSION := clang3.5
|
||||
APP_STL := gnustl_static
|
||||
APP_CPPFLAGS := -O3 -fPIC -fPIE -Wall -fstack-protector -fexceptions -fno-strict-aliasing -Wno-deprecated-register -DZT_NO_TYPE_PUNNING=1
|
||||
APP_PLATFORM := android-14
|
||||
APP_ABI := all
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
#include "ZT_jnilookup.h"
|
||||
#include "ZT_jniutils.h"
|
||||
|
||||
JniLookup::JniLookup()
|
||||
: m_jvm(NULL)
|
||||
{
|
||||
LOGV("JNI Cache Created");
|
||||
}
|
||||
|
||||
JniLookup::JniLookup(JavaVM *jvm)
|
||||
: m_jvm(jvm)
|
||||
{
|
||||
LOGV("JNI Cache Created");
|
||||
}
|
||||
|
||||
JniLookup::~JniLookup()
|
||||
{
|
||||
LOGV("JNI Cache Destroyed");
|
||||
}
|
||||
|
||||
|
||||
void JniLookup::setJavaVM(JavaVM *jvm)
|
||||
{
|
||||
LOGV("Assigned JVM to object");
|
||||
m_jvm = jvm;
|
||||
}
|
||||
|
||||
|
||||
jclass JniLookup::findClass(const std::string &name)
|
||||
{
|
||||
if(!m_jvm)
|
||||
return NULL;
|
||||
|
||||
// get the class from the JVM
|
||||
JNIEnv *env = NULL;
|
||||
if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
|
||||
{
|
||||
LOGE("Error retreiving JNI Environment");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jclass cls = env->FindClass(name.c_str());
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
LOGE("Error finding class: %s", name.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return cls;
|
||||
}
|
||||
|
||||
|
||||
jmethodID JniLookup::findMethod(jclass cls, const std::string &methodName, const std::string &methodSig)
|
||||
{
|
||||
if(!m_jvm)
|
||||
return NULL;
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jmethodID mid = env->GetMethodID(cls, methodName.c_str(), methodSig.c_str());
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mid;
|
||||
}
|
||||
|
||||
jmethodID JniLookup::findStaticMethod(jclass cls, const std::string &methodName, const std::string &methodSig)
|
||||
{
|
||||
if(!m_jvm)
|
||||
return NULL;
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jmethodID mid = env->GetStaticMethodID(cls, methodName.c_str(), methodSig.c_str());
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mid;
|
||||
}
|
||||
|
||||
jfieldID JniLookup::findField(jclass cls, const std::string &fieldName, const std::string &typeStr)
|
||||
{
|
||||
if(!m_jvm)
|
||||
return NULL;
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jfieldID fid = env->GetFieldID(cls, fieldName.c_str(), typeStr.c_str());
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fid;
|
||||
}
|
||||
|
||||
jfieldID JniLookup::findStaticField(jclass cls, const std::string &fieldName, const std::string &typeStr)
|
||||
{
|
||||
if(!m_jvm)
|
||||
return NULL;
|
||||
|
||||
JNIEnv *env = NULL;
|
||||
if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jfieldID fid = env->GetStaticFieldID(cls, fieldName.c_str(), typeStr.c_str());
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return fid;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
#ifndef ZT_JNILOOKUP_H_
|
||||
#define ZT_JNILOOKUP_H_
|
||||
|
||||
#include <jni.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
class JniLookup {
|
||||
public:
|
||||
JniLookup();
|
||||
JniLookup(JavaVM *jvm);
|
||||
~JniLookup();
|
||||
|
||||
void setJavaVM(JavaVM *jvm);
|
||||
|
||||
jclass findClass(const std::string &name);
|
||||
jmethodID findMethod(jclass cls, const std::string &methodName, const std::string &methodSig);
|
||||
jmethodID findStaticMethod(jclass cls, const std::string &methodName, const std::string &methodSig);
|
||||
jfieldID findField(jclass cls, const std::string &fieldName, const std::string &typeStr);
|
||||
jfieldID findStaticField(jclass cls, const std::string &fieldName, const std::string &typeStr);
|
||||
private:
|
||||
JavaVM *m_jvm;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,941 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ZT_jniutils.h"
|
||||
#include "ZT_jnilookup.h"
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
extern JniLookup lookup;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
jobject createResultObject(JNIEnv *env, ZT_ResultCode code)
|
||||
{
|
||||
jclass resultClass = NULL;
|
||||
|
||||
jobject resultObject = NULL;
|
||||
|
||||
resultClass = lookup.findClass("com/zerotier/sdk/ResultCode");
|
||||
if(resultClass == NULL)
|
||||
{
|
||||
LOGE("Couldnt find ResultCode class");
|
||||
return NULL; // exception thrown
|
||||
}
|
||||
|
||||
std::string fieldName;
|
||||
switch(code)
|
||||
{
|
||||
case ZT_RESULT_OK:
|
||||
LOGV("ZT_RESULT_OK");
|
||||
fieldName = "RESULT_OK";
|
||||
break;
|
||||
case ZT_RESULT_FATAL_ERROR_OUT_OF_MEMORY:
|
||||
LOGV("ZT_RESULT_FATAL_ERROR_OUT_OF_MEMORY");
|
||||
fieldName = "RESULT_FATAL_ERROR_OUT_OF_MEMORY";
|
||||
break;
|
||||
case ZT_RESULT_FATAL_ERROR_DATA_STORE_FAILED:
|
||||
LOGV("RESULT_FATAL_ERROR_DATA_STORE_FAILED");
|
||||
fieldName = "RESULT_FATAL_ERROR_DATA_STORE_FAILED";
|
||||
break;
|
||||
case ZT_RESULT_ERROR_NETWORK_NOT_FOUND:
|
||||
LOGV("RESULT_FATAL_ERROR_DATA_STORE_FAILED");
|
||||
fieldName = "RESULT_ERROR_NETWORK_NOT_FOUND";
|
||||
break;
|
||||
case ZT_RESULT_FATAL_ERROR_INTERNAL:
|
||||
default:
|
||||
LOGV("RESULT_FATAL_ERROR_DATA_STORE_FAILED");
|
||||
fieldName = "RESULT_FATAL_ERROR_INTERNAL";
|
||||
break;
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(resultClass, fieldName.c_str(), "Lcom/zerotier/sdk/ResultCode;");
|
||||
if(env->ExceptionCheck() || enumField == NULL)
|
||||
{
|
||||
LOGE("Error on FindStaticField");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resultObject = env->GetStaticObjectField(resultClass, enumField);
|
||||
if(env->ExceptionCheck() || resultObject == NULL)
|
||||
{
|
||||
LOGE("Error on GetStaticObjectField");
|
||||
}
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
|
||||
jobject createVirtualNetworkStatus(JNIEnv *env, ZT_VirtualNetworkStatus status)
|
||||
{
|
||||
jobject statusObject = NULL;
|
||||
|
||||
jclass statusClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkStatus");
|
||||
if(statusClass == NULL)
|
||||
{
|
||||
return NULL; // exception thrown
|
||||
}
|
||||
|
||||
std::string fieldName;
|
||||
switch(status)
|
||||
{
|
||||
case ZT_NETWORK_STATUS_REQUESTING_CONFIGURATION:
|
||||
fieldName = "NETWORK_STATUS_REQUESTING_CONFIGURATION";
|
||||
break;
|
||||
case ZT_NETWORK_STATUS_OK:
|
||||
fieldName = "NETWORK_STATUS_OK";
|
||||
break;
|
||||
case ZT_NETWORK_STATUS_ACCESS_DENIED:
|
||||
fieldName = "NETWORK_STATUS_ACCESS_DENIED";
|
||||
break;
|
||||
case ZT_NETWORK_STATUS_NOT_FOUND:
|
||||
fieldName = "NETWORK_STATUS_NOT_FOUND";
|
||||
break;
|
||||
case ZT_NETWORK_STATUS_PORT_ERROR:
|
||||
fieldName = "NETWORK_STATUS_PORT_ERROR";
|
||||
break;
|
||||
case ZT_NETWORK_STATUS_CLIENT_TOO_OLD:
|
||||
fieldName = "NETWORK_STATUS_CLIENT_TOO_OLD";
|
||||
break;
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(statusClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkStatus;");
|
||||
|
||||
statusObject = env->GetStaticObjectField(statusClass, enumField);
|
||||
|
||||
return statusObject;
|
||||
}
|
||||
|
||||
jobject createEvent(JNIEnv *env, ZT_Event event)
|
||||
{
|
||||
jclass eventClass = NULL;
|
||||
jobject eventObject = NULL;
|
||||
|
||||
eventClass = lookup.findClass("com/zerotier/sdk/Event");
|
||||
if(eventClass == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string fieldName;
|
||||
switch(event)
|
||||
{
|
||||
case ZT_EVENT_UP:
|
||||
fieldName = "EVENT_UP";
|
||||
break;
|
||||
case ZT_EVENT_OFFLINE:
|
||||
fieldName = "EVENT_OFFLINE";
|
||||
break;
|
||||
case ZT_EVENT_ONLINE:
|
||||
fieldName = "EVENT_ONLINE";
|
||||
break;
|
||||
case ZT_EVENT_DOWN:
|
||||
fieldName = "EVENT_DOWN";
|
||||
break;
|
||||
case ZT_EVENT_FATAL_ERROR_IDENTITY_COLLISION:
|
||||
fieldName = "EVENT_FATAL_ERROR_IDENTITY_COLLISION";
|
||||
break;
|
||||
case ZT_EVENT_TRACE:
|
||||
fieldName = "EVENT_TRACE";
|
||||
break;
|
||||
case ZT_EVENT_USER_MESSAGE:
|
||||
break;
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotier/sdk/Event;");
|
||||
|
||||
eventObject = env->GetStaticObjectField(eventClass, enumField);
|
||||
|
||||
return eventObject;
|
||||
}
|
||||
|
||||
jobject createPeerRole(JNIEnv *env, ZT_PeerRole role)
|
||||
{
|
||||
jclass peerRoleClass = NULL;
|
||||
jobject peerRoleObject = NULL;
|
||||
|
||||
peerRoleClass = lookup.findClass("com/zerotier/sdk/PeerRole");
|
||||
if(peerRoleClass == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string fieldName;
|
||||
switch(role)
|
||||
{
|
||||
case ZT_PEER_ROLE_LEAF:
|
||||
fieldName = "PEER_ROLE_LEAF";
|
||||
break;
|
||||
case ZT_PEER_ROLE_MOON:
|
||||
fieldName = "PEER_ROLE_MOON";
|
||||
break;
|
||||
case ZT_PEER_ROLE_PLANET:
|
||||
fieldName = "PEER_ROLE_PLANET";
|
||||
break;
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(peerRoleClass, fieldName.c_str(), "Lcom/zerotier/sdk/PeerRole;");
|
||||
|
||||
peerRoleObject = env->GetStaticObjectField(peerRoleClass, enumField);
|
||||
|
||||
return peerRoleObject;
|
||||
}
|
||||
|
||||
jobject createVirtualNetworkType(JNIEnv *env, ZT_VirtualNetworkType type)
|
||||
{
|
||||
jclass vntypeClass = NULL;
|
||||
jobject vntypeObject = NULL;
|
||||
|
||||
vntypeClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkType");
|
||||
if(env->ExceptionCheck() || vntypeClass == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string fieldName;
|
||||
switch(type)
|
||||
{
|
||||
case ZT_NETWORK_TYPE_PRIVATE:
|
||||
fieldName = "NETWORK_TYPE_PRIVATE";
|
||||
break;
|
||||
case ZT_NETWORK_TYPE_PUBLIC:
|
||||
fieldName = "NETWORK_TYPE_PUBLIC";
|
||||
break;
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(vntypeClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkType;");
|
||||
vntypeObject = env->GetStaticObjectField(vntypeClass, enumField);
|
||||
return vntypeObject;
|
||||
}
|
||||
|
||||
jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT_VirtualNetworkConfigOperation op)
|
||||
{
|
||||
jclass vnetConfigOpClass = NULL;
|
||||
jobject vnetConfigOpObject = NULL;
|
||||
|
||||
vnetConfigOpClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkConfigOperation");
|
||||
if(env->ExceptionCheck() || vnetConfigOpClass == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string fieldName;
|
||||
switch(op)
|
||||
{
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP:
|
||||
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_UP";
|
||||
break;
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
|
||||
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE";
|
||||
break;
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN:
|
||||
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN";
|
||||
break;
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY:
|
||||
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY";
|
||||
break;
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(vnetConfigOpClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;");
|
||||
vnetConfigOpObject = env->GetStaticObjectField(vnetConfigOpClass, enumField);
|
||||
return vnetConfigOpObject;
|
||||
}
|
||||
|
||||
jobject newInetAddress(JNIEnv *env, const sockaddr_storage &addr)
|
||||
{
|
||||
LOGV("newInetAddress");
|
||||
jclass inetAddressClass = NULL;
|
||||
jmethodID inetAddress_getByAddress = NULL;
|
||||
|
||||
inetAddressClass = lookup.findClass("java/net/InetAddress");
|
||||
if(env->ExceptionCheck() || inetAddressClass == NULL)
|
||||
{
|
||||
LOGE("Error finding InetAddress class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inetAddress_getByAddress = lookup.findStaticMethod(
|
||||
inetAddressClass, "getByAddress", "([B)Ljava/net/InetAddress;");
|
||||
if(env->ExceptionCheck() || inetAddress_getByAddress == NULL)
|
||||
{
|
||||
LOGE("Erorr finding getByAddress() static method");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject inetAddressObj = NULL;
|
||||
switch(addr.ss_family)
|
||||
{
|
||||
case AF_INET6:
|
||||
{
|
||||
sockaddr_in6 *ipv6 = (sockaddr_in6*)&addr;
|
||||
jbyteArray buff = env->NewByteArray(16);
|
||||
if(buff == NULL)
|
||||
{
|
||||
LOGE("Error creating IPV6 byte array");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->SetByteArrayRegion(buff, 0, 16, (jbyte*)ipv6->sin6_addr.s6_addr);
|
||||
inetAddressObj = env->CallStaticObjectMethod(
|
||||
inetAddressClass, inetAddress_getByAddress, buff);
|
||||
}
|
||||
break;
|
||||
case AF_INET:
|
||||
{
|
||||
sockaddr_in *ipv4 = (sockaddr_in*)&addr;
|
||||
jbyteArray buff = env->NewByteArray(4);
|
||||
if(buff == NULL)
|
||||
{
|
||||
LOGE("Error creating IPV4 byte array");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->SetByteArrayRegion(buff, 0, 4, (jbyte*)&ipv4->sin_addr);
|
||||
inetAddressObj = env->CallStaticObjectMethod(
|
||||
inetAddressClass, inetAddress_getByAddress, buff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(env->ExceptionCheck() || inetAddressObj == NULL) {
|
||||
LOGE("Error creating InetAddress object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return inetAddressObj;
|
||||
}
|
||||
|
||||
jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
|
||||
{
|
||||
LOGV("newInetSocketAddress Called");
|
||||
jclass inetSocketAddressClass = NULL;
|
||||
jmethodID inetSocketAddress_constructor = NULL;
|
||||
|
||||
inetSocketAddressClass = lookup.findClass("java/net/InetSocketAddress");
|
||||
if(env->ExceptionCheck() || inetSocketAddressClass == NULL)
|
||||
{
|
||||
LOGE("Error finding InetSocketAddress Class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject inetAddressObject = NULL;
|
||||
|
||||
if(addr.ss_family != 0)
|
||||
{
|
||||
inetAddressObject = newInetAddress(env, addr);
|
||||
|
||||
if(env->ExceptionCheck() || inetAddressObject == NULL)
|
||||
{
|
||||
LOGE("Error creating new inet address");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inetSocketAddress_constructor = lookup.findMethod(
|
||||
inetSocketAddressClass, "<init>", "(Ljava/net/InetAddress;I)V");
|
||||
if(env->ExceptionCheck() || inetSocketAddress_constructor == NULL)
|
||||
{
|
||||
LOGE("Error finding InetSocketAddress constructor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int port = 0;
|
||||
switch(addr.ss_family)
|
||||
{
|
||||
case AF_INET6:
|
||||
{
|
||||
LOGV("IPV6 Address");
|
||||
sockaddr_in6 *ipv6 = (sockaddr_in6*)&addr;
|
||||
port = ntohs(ipv6->sin6_port);
|
||||
LOGV("Port %d", port);
|
||||
}
|
||||
break;
|
||||
case AF_INET:
|
||||
{
|
||||
LOGV("IPV4 Address");
|
||||
sockaddr_in *ipv4 = (sockaddr_in*)&addr;
|
||||
port = ntohs(ipv4->sin_port);
|
||||
LOGV("Port: %d", port);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jobject inetSocketAddressObject = env->NewObject(inetSocketAddressClass, inetSocketAddress_constructor, inetAddressObject, port);
|
||||
if(env->ExceptionCheck() || inetSocketAddressObject == NULL) {
|
||||
LOGE("Error creating InetSocketAddress object");
|
||||
}
|
||||
return inetSocketAddressObject;
|
||||
}
|
||||
|
||||
jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp)
|
||||
{
|
||||
LOGV("newPeerPhysicalPath Called");
|
||||
jclass pppClass = NULL;
|
||||
|
||||
jfieldID addressField = NULL;
|
||||
jfieldID lastSendField = NULL;
|
||||
jfieldID lastReceiveField = NULL;
|
||||
jfieldID preferredField = NULL;
|
||||
|
||||
jmethodID ppp_constructor = NULL;
|
||||
|
||||
pppClass = lookup.findClass("com/zerotier/sdk/PeerPhysicalPath");
|
||||
if(env->ExceptionCheck() || pppClass == NULL)
|
||||
{
|
||||
LOGE("Error finding PeerPhysicalPath class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addressField = lookup.findField(pppClass, "address", "Ljava/net/InetSocketAddress;");
|
||||
if(env->ExceptionCheck() || addressField == NULL)
|
||||
{
|
||||
LOGE("Error finding address field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lastSendField = lookup.findField(pppClass, "lastSend", "J");
|
||||
if(env->ExceptionCheck() || lastSendField == NULL)
|
||||
{
|
||||
LOGE("Error finding lastSend field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lastReceiveField = lookup.findField(pppClass, "lastReceive", "J");
|
||||
if(env->ExceptionCheck() || lastReceiveField == NULL)
|
||||
{
|
||||
LOGE("Error finding lastReceive field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
preferredField = lookup.findField(pppClass, "preferred", "Z");
|
||||
if(env->ExceptionCheck() || preferredField == NULL)
|
||||
{
|
||||
LOGE("Error finding preferred field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ppp_constructor = lookup.findMethod(pppClass, "<init>", "()V");
|
||||
if(env->ExceptionCheck() || ppp_constructor == NULL)
|
||||
{
|
||||
LOGE("Error finding PeerPhysicalPath constructor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject pppObject = env->NewObject(pppClass, ppp_constructor);
|
||||
if(env->ExceptionCheck() || pppObject == NULL)
|
||||
{
|
||||
LOGE("Error creating PPP object");
|
||||
return NULL; // out of memory
|
||||
}
|
||||
|
||||
jobject addressObject = newInetSocketAddress(env, ppp.address);
|
||||
if(env->ExceptionCheck() || addressObject == NULL) {
|
||||
LOGE("Error creating InetSocketAddress object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->SetObjectField(pppObject, addressField, addressObject);
|
||||
env->SetLongField(pppObject, lastSendField, ppp.lastSend);
|
||||
env->SetLongField(pppObject, lastReceiveField, ppp.lastReceive);
|
||||
env->SetBooleanField(pppObject, preferredField, ppp.preferred);
|
||||
|
||||
if(env->ExceptionCheck()) {
|
||||
LOGE("Exception assigning fields to PeerPhysicalPath object");
|
||||
}
|
||||
|
||||
return pppObject;
|
||||
}
|
||||
|
||||
jobject newPeer(JNIEnv *env, const ZT_Peer &peer)
|
||||
{
|
||||
LOGV("newPeer called");
|
||||
|
||||
jclass peerClass = NULL;
|
||||
|
||||
jfieldID addressField = NULL;
|
||||
jfieldID versionMajorField = NULL;
|
||||
jfieldID versionMinorField = NULL;
|
||||
jfieldID versionRevField = NULL;
|
||||
jfieldID latencyField = NULL;
|
||||
jfieldID roleField = NULL;
|
||||
jfieldID pathsField = NULL;
|
||||
|
||||
jmethodID peer_constructor = NULL;
|
||||
|
||||
peerClass = lookup.findClass("com/zerotier/sdk/Peer");
|
||||
if(env->ExceptionCheck() || peerClass == NULL)
|
||||
{
|
||||
LOGE("Error finding Peer class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addressField = lookup.findField(peerClass, "address", "J");
|
||||
if(env->ExceptionCheck() || addressField == NULL)
|
||||
{
|
||||
LOGE("Error finding address field of Peer object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
versionMajorField = lookup.findField(peerClass, "versionMajor", "I");
|
||||
if(env->ExceptionCheck() || versionMajorField == NULL)
|
||||
{
|
||||
LOGE("Error finding versionMajor field of Peer object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
versionMinorField = lookup.findField(peerClass, "versionMinor", "I");
|
||||
if(env->ExceptionCheck() || versionMinorField == NULL)
|
||||
{
|
||||
LOGE("Error finding versionMinor field of Peer object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
versionRevField = lookup.findField(peerClass, "versionRev", "I");
|
||||
if(env->ExceptionCheck() || versionRevField == NULL)
|
||||
{
|
||||
LOGE("Error finding versionRev field of Peer object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
latencyField = lookup.findField(peerClass, "latency", "I");
|
||||
if(env->ExceptionCheck() || latencyField == NULL)
|
||||
{
|
||||
LOGE("Error finding latency field of Peer object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
roleField = lookup.findField(peerClass, "role", "Lcom/zerotier/sdk/PeerRole;");
|
||||
if(env->ExceptionCheck() || roleField == NULL)
|
||||
{
|
||||
LOGE("Error finding role field of Peer object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pathsField = lookup.findField(peerClass, "paths", "[Lcom/zerotier/sdk/PeerPhysicalPath;");
|
||||
if(env->ExceptionCheck() || pathsField == NULL)
|
||||
{
|
||||
LOGE("Error finding paths field of Peer object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
peer_constructor = lookup.findMethod(peerClass, "<init>", "()V");
|
||||
if(env->ExceptionCheck() || peer_constructor == NULL)
|
||||
{
|
||||
LOGE("Error finding Peer constructor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject peerObject = env->NewObject(peerClass, peer_constructor);
|
||||
if(env->ExceptionCheck() || peerObject == NULL)
|
||||
{
|
||||
LOGE("Error creating Peer object");
|
||||
return NULL; // out of memory
|
||||
}
|
||||
|
||||
env->SetLongField(peerObject, addressField, (jlong)peer.address);
|
||||
env->SetIntField(peerObject, versionMajorField, peer.versionMajor);
|
||||
env->SetIntField(peerObject, versionMinorField, peer.versionMinor);
|
||||
env->SetIntField(peerObject, versionRevField, peer.versionRev);
|
||||
env->SetIntField(peerObject, latencyField, peer.latency);
|
||||
env->SetObjectField(peerObject, roleField, createPeerRole(env, peer.role));
|
||||
|
||||
jclass peerPhysicalPathClass = lookup.findClass("com/zerotier/sdk/PeerPhysicalPath");
|
||||
if(env->ExceptionCheck() || peerPhysicalPathClass == NULL)
|
||||
{
|
||||
LOGE("Error finding PeerPhysicalPath class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobjectArray arrayObject = env->NewObjectArray(
|
||||
peer.pathCount, peerPhysicalPathClass, NULL);
|
||||
if(env->ExceptionCheck() || arrayObject == NULL)
|
||||
{
|
||||
LOGE("Error creating PeerPhysicalPath[] array");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < peer.pathCount; ++i)
|
||||
{
|
||||
jobject path = newPeerPhysicalPath(env, peer.paths[i]);
|
||||
|
||||
env->SetObjectArrayElement(arrayObject, i, path);
|
||||
if(env->ExceptionCheck()) {
|
||||
LOGE("exception assigning PeerPhysicalPath to array");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
env->SetObjectField(peerObject, pathsField, arrayObject);
|
||||
|
||||
return peerObject;
|
||||
}
|
||||
|
||||
jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig)
|
||||
{
|
||||
jclass vnetConfigClass = NULL;
|
||||
jmethodID vnetConfig_constructor = NULL;
|
||||
jfieldID nwidField = NULL;
|
||||
jfieldID macField = NULL;
|
||||
jfieldID nameField = NULL;
|
||||
jfieldID statusField = NULL;
|
||||
jfieldID typeField = NULL;
|
||||
jfieldID mtuField = NULL;
|
||||
jfieldID dhcpField = NULL;
|
||||
jfieldID bridgeField = NULL;
|
||||
jfieldID broadcastEnabledField = NULL;
|
||||
jfieldID portErrorField = NULL;
|
||||
jfieldID netconfRevisionField = NULL;
|
||||
jfieldID assignedAddressesField = NULL;
|
||||
jfieldID routesField = NULL;
|
||||
|
||||
vnetConfigClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkConfig");
|
||||
if(vnetConfigClass == NULL)
|
||||
{
|
||||
LOGE("Couldn't find com.zerotier.sdk.VirtualNetworkConfig");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vnetConfig_constructor = lookup.findMethod(
|
||||
vnetConfigClass, "<init>", "()V");
|
||||
if(env->ExceptionCheck() || vnetConfig_constructor == NULL)
|
||||
{
|
||||
LOGE("Couldn't find VirtualNetworkConfig Constructor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject vnetConfigObj = env->NewObject(vnetConfigClass, vnetConfig_constructor);
|
||||
if(env->ExceptionCheck() || vnetConfigObj == NULL)
|
||||
{
|
||||
LOGE("Error creating new VirtualNetworkConfig object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nwidField = lookup.findField(vnetConfigClass, "nwid", "J");
|
||||
if(env->ExceptionCheck() || nwidField == NULL)
|
||||
{
|
||||
LOGE("Error getting nwid field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
macField = lookup.findField(vnetConfigClass, "mac", "J");
|
||||
if(env->ExceptionCheck() || macField == NULL)
|
||||
{
|
||||
LOGE("Error getting mac field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nameField = lookup.findField(vnetConfigClass, "name", "Ljava/lang/String;");
|
||||
if(env->ExceptionCheck() || nameField == NULL)
|
||||
{
|
||||
LOGE("Error getting name field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
statusField = lookup.findField(vnetConfigClass, "status", "Lcom/zerotier/sdk/VirtualNetworkStatus;");
|
||||
if(env->ExceptionCheck() || statusField == NULL)
|
||||
{
|
||||
LOGE("Error getting status field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
typeField = lookup.findField(vnetConfigClass, "type", "Lcom/zerotier/sdk/VirtualNetworkType;");
|
||||
if(env->ExceptionCheck() || typeField == NULL)
|
||||
{
|
||||
LOGE("Error getting type field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mtuField = lookup.findField(vnetConfigClass, "mtu", "I");
|
||||
if(env->ExceptionCheck() || mtuField == NULL)
|
||||
{
|
||||
LOGE("Error getting mtu field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dhcpField = lookup.findField(vnetConfigClass, "dhcp", "Z");
|
||||
if(env->ExceptionCheck() || dhcpField == NULL)
|
||||
{
|
||||
LOGE("Error getting dhcp field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bridgeField = lookup.findField(vnetConfigClass, "bridge", "Z");
|
||||
if(env->ExceptionCheck() || bridgeField == NULL)
|
||||
{
|
||||
LOGE("Error getting bridge field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
broadcastEnabledField = lookup.findField(vnetConfigClass, "broadcastEnabled", "Z");
|
||||
if(env->ExceptionCheck() || broadcastEnabledField == NULL)
|
||||
{
|
||||
LOGE("Error getting broadcastEnabled field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
portErrorField = lookup.findField(vnetConfigClass, "portError", "I");
|
||||
if(env->ExceptionCheck() || portErrorField == NULL)
|
||||
{
|
||||
LOGE("Error getting portError field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
netconfRevisionField = lookup.findField(vnetConfigClass, "netconfRevision", "J");
|
||||
if(env->ExceptionCheck() || netconfRevisionField == NULL)
|
||||
{
|
||||
LOGE("Error getting netconfRevision field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses",
|
||||
"[Ljava/net/InetSocketAddress;");
|
||||
if(env->ExceptionCheck() || assignedAddressesField == NULL)
|
||||
{
|
||||
LOGE("Error getting assignedAddresses field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
routesField = lookup.findField(vnetConfigClass, "routes",
|
||||
"[Lcom/zerotier/sdk/VirtualNetworkRoute;");
|
||||
if(env->ExceptionCheck() || routesField == NULL)
|
||||
{
|
||||
LOGE("Error getting routes field");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->SetLongField(vnetConfigObj, nwidField, vnetConfig.nwid);
|
||||
env->SetLongField(vnetConfigObj, macField, vnetConfig.mac);
|
||||
jstring nameStr = env->NewStringUTF(vnetConfig.name);
|
||||
if(env->ExceptionCheck() || nameStr == NULL)
|
||||
{
|
||||
return NULL; // out of memory
|
||||
}
|
||||
env->SetObjectField(vnetConfigObj, nameField, nameStr);
|
||||
|
||||
jobject statusObject = createVirtualNetworkStatus(env, vnetConfig.status);
|
||||
if(env->ExceptionCheck() || statusObject == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
env->SetObjectField(vnetConfigObj, statusField, statusObject);
|
||||
|
||||
jobject typeObject = createVirtualNetworkType(env, vnetConfig.type);
|
||||
if(env->ExceptionCheck() || typeObject == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
env->SetObjectField(vnetConfigObj, typeField, typeObject);
|
||||
|
||||
env->SetIntField(vnetConfigObj, mtuField, (int)vnetConfig.mtu);
|
||||
env->SetBooleanField(vnetConfigObj, dhcpField, vnetConfig.dhcp);
|
||||
env->SetBooleanField(vnetConfigObj, bridgeField, vnetConfig.bridge);
|
||||
env->SetBooleanField(vnetConfigObj, broadcastEnabledField, vnetConfig.broadcastEnabled);
|
||||
env->SetIntField(vnetConfigObj, portErrorField, vnetConfig.portError);
|
||||
|
||||
jclass inetSocketAddressClass = lookup.findClass("java/net/InetSocketAddress");
|
||||
if(env->ExceptionCheck() || inetSocketAddressClass == NULL)
|
||||
{
|
||||
LOGE("Error finding InetSocketAddress class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobjectArray assignedAddrArrayObj = env->NewObjectArray(
|
||||
vnetConfig.assignedAddressCount, inetSocketAddressClass, NULL);
|
||||
if(env->ExceptionCheck() || assignedAddrArrayObj == NULL)
|
||||
{
|
||||
LOGE("Error creating InetSocketAddress[] array");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < vnetConfig.assignedAddressCount; ++i)
|
||||
{
|
||||
jobject inetAddrObj = newInetSocketAddress(env, vnetConfig.assignedAddresses[i]);
|
||||
env->SetObjectArrayElement(assignedAddrArrayObj, i, inetAddrObj);
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
LOGE("Error assigning InetSocketAddress to array");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
env->SetObjectField(vnetConfigObj, assignedAddressesField, assignedAddrArrayObj);
|
||||
|
||||
jclass virtualNetworkRouteClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkRoute");
|
||||
if(env->ExceptionCheck() || virtualNetworkRouteClass == NULL)
|
||||
{
|
||||
LOGE("Error finding VirtualNetworkRoute class");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobjectArray routesArrayObj = env->NewObjectArray(
|
||||
vnetConfig.routeCount, virtualNetworkRouteClass, NULL);
|
||||
if(env->ExceptionCheck() || routesArrayObj == NULL)
|
||||
{
|
||||
LOGE("Error creating VirtualNetworkRoute[] array");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < vnetConfig.routeCount; ++i)
|
||||
{
|
||||
jobject routeObj = newVirtualNetworkRoute(env, vnetConfig.routes[i]);
|
||||
env->SetObjectArrayElement(routesArrayObj, i, routeObj);
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
LOGE("Error assigning VirtualNetworkRoute to array");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
env->SetObjectField(vnetConfigObj, routesField, routesArrayObj);
|
||||
|
||||
return vnetConfigObj;
|
||||
}
|
||||
|
||||
jobject newVersion(JNIEnv *env, int major, int minor, int rev)
|
||||
{
|
||||
// create a com.zerotier.sdk.Version object
|
||||
jclass versionClass = NULL;
|
||||
jmethodID versionConstructor = NULL;
|
||||
|
||||
versionClass = lookup.findClass("com/zerotier/sdk/Version");
|
||||
if(env->ExceptionCheck() || versionClass == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
versionConstructor = lookup.findMethod(
|
||||
versionClass, "<init>", "()V");
|
||||
if(env->ExceptionCheck() || versionConstructor == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject versionObj = env->NewObject(versionClass, versionConstructor);
|
||||
if(env->ExceptionCheck() || versionObj == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// copy data to Version object
|
||||
jfieldID majorField = NULL;
|
||||
jfieldID minorField = NULL;
|
||||
jfieldID revisionField = NULL;
|
||||
|
||||
majorField = lookup.findField(versionClass, "major", "I");
|
||||
if(env->ExceptionCheck() || majorField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
minorField = lookup.findField(versionClass, "minor", "I");
|
||||
if(env->ExceptionCheck() || minorField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
revisionField = lookup.findField(versionClass, "revision", "I");
|
||||
if(env->ExceptionCheck() || revisionField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->SetIntField(versionObj, majorField, (jint)major);
|
||||
env->SetIntField(versionObj, minorField, (jint)minor);
|
||||
env->SetIntField(versionObj, revisionField, (jint)rev);
|
||||
|
||||
return versionObj;
|
||||
}
|
||||
|
||||
jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route)
|
||||
{
|
||||
jclass virtualNetworkRouteClass = NULL;
|
||||
jmethodID routeConstructor = NULL;
|
||||
|
||||
virtualNetworkRouteClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkRoute");
|
||||
if(env->ExceptionCheck() || virtualNetworkRouteClass == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
routeConstructor = lookup.findMethod(virtualNetworkRouteClass, "<init>", "()V");
|
||||
if(env->ExceptionCheck() || routeConstructor == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject routeObj = env->NewObject(virtualNetworkRouteClass, routeConstructor);
|
||||
if(env->ExceptionCheck() || routeObj == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jfieldID targetField = NULL;
|
||||
jfieldID viaField = NULL;
|
||||
jfieldID flagsField = NULL;
|
||||
jfieldID metricField = NULL;
|
||||
|
||||
targetField = lookup.findField(virtualNetworkRouteClass, "target",
|
||||
"Ljava/net/InetSocketAddress;");
|
||||
if(env->ExceptionCheck() || targetField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
viaField = lookup.findField(virtualNetworkRouteClass, "via",
|
||||
"Ljava/net/InetSocketAddress;");
|
||||
if(env->ExceptionCheck() || targetField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
flagsField = lookup.findField(virtualNetworkRouteClass, "flags", "I");
|
||||
if(env->ExceptionCheck() || flagsField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
metricField = lookup.findField(virtualNetworkRouteClass, "metric", "I");
|
||||
if(env->ExceptionCheck() || metricField == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
jobject targetObj = newInetSocketAddress(env, route.target);
|
||||
jobject viaObj = newInetSocketAddress(env, route.via);
|
||||
|
||||
env->SetObjectField(routeObj, targetField, targetObj);
|
||||
env->SetObjectField(routeObj, viaField, viaObj);
|
||||
env->SetIntField(routeObj, flagsField, (jint)route.flags);
|
||||
env->SetIntField(routeObj, metricField, (jint)route.metric);
|
||||
|
||||
return routeObj;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ZT_jniutils_h_
|
||||
#define ZT_jniutils_h_
|
||||
#include <stdio.h>
|
||||
#include <jni.h>
|
||||
#include <ZeroTierOne.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LOG_TAG "ZeroTierOneJNI"
|
||||
|
||||
#if __ANDROID__
|
||||
#include <android/log.h>
|
||||
#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
|
||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
|
||||
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
||||
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
|
||||
#else
|
||||
#define LOGV(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define LOGI(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define LOGD(...) fprintf(stdout, __VA_ARGS__)
|
||||
#define LOGE(...) fprintf(stdout, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
jobject createResultObject(JNIEnv *env, ZT_ResultCode code);
|
||||
jobject createVirtualNetworkStatus(JNIEnv *env, ZT_VirtualNetworkStatus status);
|
||||
jobject createVirtualNetworkType(JNIEnv *env, ZT_VirtualNetworkType type);
|
||||
jobject createEvent(JNIEnv *env, ZT_Event event);
|
||||
jobject createPeerRole(JNIEnv *env, ZT_PeerRole role);
|
||||
jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT_VirtualNetworkConfigOperation op);
|
||||
|
||||
jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr);
|
||||
jobject newInetAddress(JNIEnv *env, const sockaddr_storage &addr);
|
||||
|
||||
jobject newMulticastGroup(JNIEnv *env, const ZT_MulticastGroup &mc);
|
||||
|
||||
jobject newPeer(JNIEnv *env, const ZT_Peer &peer);
|
||||
jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp);
|
||||
|
||||
jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &config);
|
||||
|
||||
jobject newVersion(JNIEnv *env, int major, int minor, int rev);
|
||||
|
||||
jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,133 +0,0 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class com_zerotier_sdk_Node */
|
||||
|
||||
#ifndef _Included_com_zerotierone_sdk_Node
|
||||
#define _Included_com_zerotierone_sdk_Node
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: node_init
|
||||
* Signature: (J)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: node_delete
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: processVirtualNetworkFrame
|
||||
* Signature: (JJJJJII[B[J)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame
|
||||
(JNIEnv *, jobject, jlong, jlong, jlong, jlong, jlong, jint, jint, jbyteArray, jlongArray);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: processWirePacket
|
||||
* Signature: (JJLjava/net/InetSockAddress;Ljava/net/InetSockAddress;[B[J)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket
|
||||
(JNIEnv *, jobject, jlong, jlong, jobject, jobject, jbyteArray, jlongArray);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: processBackgroundTasks
|
||||
* Signature: (JJ[J)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks
|
||||
(JNIEnv *, jobject, jlong, jlong, jlongArray);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: join
|
||||
* Signature: (JJ)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_join
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: leave
|
||||
* Signature: (JJ)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: multicastSubscribe
|
||||
* Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe
|
||||
(JNIEnv *, jobject, jlong, jlong, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: multicastUnsubscribe
|
||||
* Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe
|
||||
(JNIEnv *, jobject, jlong, jlong, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: address
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_com_zerotier_sdk_Node_address
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: status
|
||||
* Signature: (J)Lcom/zerotier/sdk/NodeStatus;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: networkConfig
|
||||
* Signature: (JJ)Lcom/zerotier/sdk/VirtualNetworkConfig;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networkConfig
|
||||
(JNIEnv *, jobject, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: version
|
||||
* Signature: ()Lcom/zerotier/sdk/Version;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_version
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: peers
|
||||
* Signature: (J)[Lcom/zerotier/sdk/Peer;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_zerotier_sdk_Node
|
||||
* Method: networks
|
||||
* Signature: (J)[Lcom/zerotier/sdk/VirtualNetworkConfig;
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_networks
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public interface DataStoreGetListener {
|
||||
|
||||
/**
|
||||
* Function to get an object from the data store
|
||||
*
|
||||
* <p>Object names can contain forward slash (/) path separators. They will
|
||||
* never contain .. or backslash (\), so this is safe to map as a Unix-style
|
||||
* path if the underlying storage permits. For security reasons we recommend
|
||||
* returning errors if .. or \ are used.</p>
|
||||
*
|
||||
* <p>The function must return the actual number of bytes read. If the object
|
||||
* doesn't exist, it should return -1. -2 should be returned on other errors
|
||||
* such as errors accessing underlying storage.</p>
|
||||
*
|
||||
* <p>If the read doesn't fit in the buffer, the max number of bytes should be
|
||||
* read. The caller may call the function multiple times to read the whole
|
||||
* object.</p>
|
||||
*
|
||||
* @param name Name of the object in the data store
|
||||
* @param out_buffer buffer to put the object in
|
||||
* @param bufferIndex index in the object to start reading
|
||||
* @param out_objectSize long[1] to be set to the actual size of the object if it exists.
|
||||
* @return the actual number of bytes read.
|
||||
*/
|
||||
public long onDataStoreGet(
|
||||
String name,
|
||||
byte[] out_buffer,
|
||||
long bufferIndex,
|
||||
long[] out_objectSize);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public interface DataStorePutListener {
|
||||
|
||||
/**
|
||||
* Function to store an object in the data store
|
||||
*
|
||||
* <p>If secure is true, the file should be set readable and writable only
|
||||
* to the user running ZeroTier One. What this means is platform-specific.</p>
|
||||
*
|
||||
* <p>Name semantics are the same as {@link DataStoreGetListener}. This must return
|
||||
* zero on success. You can return any OS-specific error code on failure, as these
|
||||
* may be visible in logs or error messages and might aid in debugging.</p>
|
||||
*
|
||||
* @param name Object name
|
||||
* @param buffer data to store
|
||||
* @param secure set to user read/write only.
|
||||
* @return 0 on success.
|
||||
*/
|
||||
public int onDataStorePut(
|
||||
String name,
|
||||
byte[] buffer,
|
||||
boolean secure);
|
||||
|
||||
/**
|
||||
* Function to delete an object from the data store
|
||||
*
|
||||
* @param name Object name
|
||||
* @return 0 on success.
|
||||
*/
|
||||
public int onDelete(
|
||||
String name);
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public enum Event {
|
||||
/**
|
||||
* Node has been initialized
|
||||
*
|
||||
* This is the first event generated, and is always sent. It may occur
|
||||
* before Node's constructor returns.
|
||||
*/
|
||||
EVENT_UP,
|
||||
|
||||
/**
|
||||
* Node is offline -- network does not seem to be reachable by any available strategy
|
||||
*/
|
||||
EVENT_OFFLINE,
|
||||
|
||||
/**
|
||||
* Node is online -- at least one upstream node appears reachable
|
||||
*
|
||||
* Meta-data: none
|
||||
*/
|
||||
EVENT_ONLINE,
|
||||
|
||||
/**
|
||||
* Node is shutting down
|
||||
*
|
||||
* <p>This is generated within Node's destructor when it is being shut down.
|
||||
* It's done for convenience, since cleaning up other state in the event
|
||||
* handler may appear more idiomatic.</p>
|
||||
*/
|
||||
EVENT_DOWN,
|
||||
|
||||
/**
|
||||
* Your identity has collided with another node's ZeroTier address
|
||||
*
|
||||
* <p>This happens if two different public keys both hash (via the algorithm
|
||||
* in Identity::generate()) to the same 40-bit ZeroTier address.</p>
|
||||
*
|
||||
* <p>This is something you should "never" see, where "never" is defined as
|
||||
* once per 2^39 new node initializations / identity creations. If you do
|
||||
* see it, you're going to see it very soon after a node is first
|
||||
* initialized.</p>
|
||||
*
|
||||
* <p>This is reported as an event rather than a return code since it's
|
||||
* detected asynchronously via error messages from authoritative nodes.</p>
|
||||
*
|
||||
* <p>If this occurs, you must shut down and delete the node, delete the
|
||||
* identity.secret record/file from the data store, and restart to generate
|
||||
* a new identity. If you don't do this, you will not be able to communicate
|
||||
* with other nodes.</p>
|
||||
*
|
||||
* <p>We'd automate this process, but we don't think silently deleting
|
||||
* private keys or changing our address without telling the calling code
|
||||
* is good form. It violates the principle of least surprise.</p>
|
||||
*
|
||||
* <p>You can technically get away with not handling this, but we recommend
|
||||
* doing so in a mature reliable application. Besides, handling this
|
||||
* condition is a good way to make sure it never arises. It's like how
|
||||
* umbrellas prevent rain and smoke detectors prevent fires. They do, right?</p>
|
||||
*/
|
||||
EVENT_FATAL_ERROR_IDENTITY_COLLISION,
|
||||
|
||||
/**
|
||||
* Trace (debugging) message
|
||||
*
|
||||
* <p>These events are only generated if this is a TRACE-enabled build.</p>
|
||||
*
|
||||
* <p>Meta-data: {@link String}, TRACE message</p>
|
||||
*/
|
||||
EVENT_TRACE
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.lang.String;
|
||||
|
||||
/**
|
||||
* Interface to handle callbacks for ZeroTier One events.
|
||||
*/
|
||||
public interface EventListener {
|
||||
/**
|
||||
* Callback for events with no other associated metadata
|
||||
*
|
||||
* @param event {@link Event} enum
|
||||
*/
|
||||
public void onEvent(Event event);
|
||||
|
||||
/**
|
||||
* Trace messages
|
||||
*
|
||||
* <p>These events are only generated if the underlying ZeroTierOne SDK is a TRACE-enabled build.</p>
|
||||
*
|
||||
* @param message the trace message
|
||||
*/
|
||||
public void onTrace(String message);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Simple library class for working with JNI (Java Native Interface)
|
||||
*
|
||||
* @see http://adamheinrich.com/2012/how-to-load-native-jni-library-from-jar
|
||||
*
|
||||
* @author Adam Heirnich <adam@adamh.cz>, http://www.adamh.cz
|
||||
*/
|
||||
public class NativeUtils {
|
||||
|
||||
/**
|
||||
* Private constructor - this class will never be instanced
|
||||
*/
|
||||
private NativeUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads library from current JAR archive
|
||||
*
|
||||
* The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after exiting.
|
||||
* Method uses String as filename because the pathname is "abstract", not system-dependent.
|
||||
*
|
||||
* @param filename The filename inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext
|
||||
* @throws IOException If temporary file creation or read/write operation fails
|
||||
* @throws IllegalArgumentException If source file (param path) does not exist
|
||||
* @throws IllegalArgumentException If the path is not absolute or if the filename is shorter than three characters (restriction of {@see File#createTempFile(java.lang.String, java.lang.String)}).
|
||||
*/
|
||||
public static void loadLibraryFromJar(String path) throws IOException {
|
||||
|
||||
if (!path.startsWith("/")) {
|
||||
throw new IllegalArgumentException("The path has to be absolute (start with '/').");
|
||||
}
|
||||
|
||||
// Obtain filename from path
|
||||
String[] parts = path.split("/");
|
||||
String filename = (parts.length > 1) ? parts[parts.length - 1] : null;
|
||||
|
||||
// Split filename to prexif and suffix (extension)
|
||||
String prefix = "";
|
||||
String suffix = null;
|
||||
if (filename != null) {
|
||||
parts = filename.split("\\.", 2);
|
||||
prefix = parts[0];
|
||||
suffix = (parts.length > 1) ? "."+parts[parts.length - 1] : null; // Thanks, davs! :-)
|
||||
}
|
||||
|
||||
// Check if the filename is okay
|
||||
if (filename == null || prefix.length() < 3) {
|
||||
throw new IllegalArgumentException("The filename has to be at least 3 characters long.");
|
||||
}
|
||||
|
||||
// Prepare temporary file
|
||||
File temp = File.createTempFile(prefix, suffix);
|
||||
temp.deleteOnExit();
|
||||
|
||||
if (!temp.exists()) {
|
||||
throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist.");
|
||||
}
|
||||
|
||||
// Prepare buffer for data copying
|
||||
byte[] buffer = new byte[1024];
|
||||
int readBytes;
|
||||
|
||||
// Open and check input stream
|
||||
InputStream is = NativeUtils.class.getResourceAsStream(path);
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("File " + path + " was not found inside JAR.");
|
||||
}
|
||||
|
||||
// Open output stream and copy data between source file in JAR and the temporary file
|
||||
OutputStream os = new FileOutputStream(temp);
|
||||
try {
|
||||
while ((readBytes = is.read(buffer)) != -1) {
|
||||
os.write(buffer, 0, readBytes);
|
||||
}
|
||||
} finally {
|
||||
// If read/write fails, close streams safely before throwing an exception
|
||||
os.close();
|
||||
is.close();
|
||||
}
|
||||
|
||||
// Finally, load the library
|
||||
System.load(temp.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
@@ -1,434 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A ZeroTier One node
|
||||
*/
|
||||
public class Node {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("ZeroTierOneJNI");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
try {
|
||||
if(System.getProperty("os.name").startsWith("Windows")) {
|
||||
System.out.println("Arch: " + System.getProperty("sun.arch.data.model"));
|
||||
if(System.getProperty("sun.arch.data.model").equals("64")) {
|
||||
NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win64.dll");
|
||||
} else {
|
||||
NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win32.dll");
|
||||
}
|
||||
} else if(System.getProperty("os.name").startsWith("Mac")) {
|
||||
NativeUtils.loadLibraryFromJar("/lib/libZeroTierOneJNI.jnilib");
|
||||
} else {
|
||||
// TODO: Linux
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TAG = "NODE";
|
||||
|
||||
/**
|
||||
* Node ID for JNI purposes.
|
||||
* Currently set to the now value passed in at the constructor
|
||||
*
|
||||
* -1 if the node has already been closed
|
||||
*/
|
||||
private long nodeId;
|
||||
|
||||
private final DataStoreGetListener getListener;
|
||||
private final DataStorePutListener putListener;
|
||||
private final PacketSender sender;
|
||||
private final EventListener eventListener;
|
||||
private final VirtualNetworkFrameListener frameListener;
|
||||
private final VirtualNetworkConfigListener configListener;
|
||||
|
||||
/**
|
||||
* Create a new ZeroTier One node
|
||||
*
|
||||
* <p>Note that this can take a few seconds the first time it's called, as it
|
||||
* will generate an identity.</p>
|
||||
*
|
||||
* @param now Current clock in milliseconds
|
||||
* @param getListener User written instance of the {@link DataStoreGetListener} interface called to get objects from persistent storage. This instance must be unique per Node object.
|
||||
* @param putListener User written intstance of the {@link DataStorePutListener} interface called to put objects in persistent storage. This instance must be unique per Node object.
|
||||
* @param sender
|
||||
* @param eventListener User written instance of the {@link EventListener} interface to receive status updates and non-fatal error notices. This instance must be unique per Node object.
|
||||
* @param frameListener
|
||||
* @param configListener User written instance of the {@link VirtualNetworkConfigListener} interface to be called when virtual LANs are created, deleted, or their config parameters change. This instance must be unique per Node object.
|
||||
*/
|
||||
public Node(long now,
|
||||
DataStoreGetListener getListener,
|
||||
DataStorePutListener putListener,
|
||||
PacketSender sender,
|
||||
EventListener eventListener,
|
||||
VirtualNetworkFrameListener frameListener,
|
||||
VirtualNetworkConfigListener configListener) throws NodeException
|
||||
{
|
||||
this.nodeId = now;
|
||||
|
||||
this.getListener = getListener;
|
||||
this.putListener = putListener;
|
||||
this.sender = sender;
|
||||
this.eventListener = eventListener;
|
||||
this.frameListener = frameListener;
|
||||
this.configListener = configListener;
|
||||
|
||||
ResultCode rc = node_init(now);
|
||||
if(rc != ResultCode.RESULT_OK)
|
||||
{
|
||||
// TODO: Throw Exception
|
||||
throw new NodeException(rc.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close this Node.
|
||||
*
|
||||
* <p>The Node object can no longer be used once this method is called.</p>
|
||||
*/
|
||||
public void close() {
|
||||
if(nodeId != -1) {
|
||||
node_delete(nodeId);
|
||||
nodeId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a frame from a virtual network port
|
||||
*
|
||||
* @param now Current clock in milliseconds
|
||||
* @param nwid ZeroTier 64-bit virtual network ID
|
||||
* @param sourceMac Source MAC address (least significant 48 bits)
|
||||
* @param destMac Destination MAC address (least significant 48 bits)
|
||||
* @param etherType 16-bit Ethernet frame type
|
||||
* @param vlanId 10-bit VLAN ID or 0 if none
|
||||
* @param frameData Frame payload data
|
||||
* @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks()
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode processVirtualNetworkFrame(
|
||||
long now,
|
||||
long nwid,
|
||||
long sourceMac,
|
||||
long destMac,
|
||||
int etherType,
|
||||
int vlanId,
|
||||
byte[] frameData,
|
||||
long[] nextBackgroundTaskDeadline) {
|
||||
return processVirtualNetworkFrame(
|
||||
nodeId, now, nwid, sourceMac, destMac, etherType, vlanId,
|
||||
frameData, nextBackgroundTaskDeadline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a packet received from the physical wire
|
||||
*
|
||||
* @param now Current clock in milliseconds
|
||||
* @param remoteAddress Origin of packet
|
||||
* @param packetData Packet data
|
||||
* @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks()
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode processWirePacket(
|
||||
long now,
|
||||
InetSocketAddress localAddress,
|
||||
InetSocketAddress remoteAddress,
|
||||
byte[] packetData,
|
||||
long[] nextBackgroundTaskDeadline) {
|
||||
return processWirePacket(
|
||||
nodeId, now, localAddress, remoteAddress, packetData,
|
||||
nextBackgroundTaskDeadline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform periodic background operations
|
||||
*
|
||||
* @param now Current clock in milliseconds
|
||||
* @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks()
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode processBackgroundTasks(long now, long[] nextBackgroundTaskDeadline) {
|
||||
return processBackgroundTasks(nodeId, now, nextBackgroundTaskDeadline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join a network
|
||||
*
|
||||
* <p>This may generate calls to the port config callback before it returns,
|
||||
* or these may be deffered if a netconf is not available yet.</p>
|
||||
*
|
||||
* <p>If we are already a member of the network, nothing is done and OK is
|
||||
* returned.</p>
|
||||
*
|
||||
* @param nwid 64-bit ZeroTier network ID
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode join(long nwid) {
|
||||
return join(nodeId, nwid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave a network
|
||||
*
|
||||
* <p>If a port has been configured for this network this will generate a call
|
||||
* to the port config callback with a NULL second parameter to indicate that
|
||||
* the port is now deleted.</p>
|
||||
*
|
||||
* @param nwid 64-bit network ID
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode leave(long nwid) {
|
||||
return leave(nodeId, nwid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to an Ethernet multicast group
|
||||
*
|
||||
* <p>For IPv4 ARP, the implementation must subscribe to 0xffffffffffff (the
|
||||
* broadcast address) but with an ADI equal to each IPv4 address in host
|
||||
* byte order. This converts ARP from a non-scalable broadcast protocol to
|
||||
* a scalable multicast protocol with perfect address specificity.</p>
|
||||
*
|
||||
* <p>If this is not done, ARP will not work reliably.</p>
|
||||
*
|
||||
* <p>Multiple calls to subscribe to the same multicast address will have no
|
||||
* effect. It is perfectly safe to do this.</p>
|
||||
*
|
||||
* <p>This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.</p>
|
||||
*
|
||||
* @param nwid 64-bit network ID
|
||||
* @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits)
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode multicastSubscribe(
|
||||
long nwid,
|
||||
long multicastGroup) {
|
||||
return multicastSubscribe(nodeId, nwid, multicastGroup, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to an Ethernet multicast group
|
||||
*
|
||||
* <p>ADI stands for additional distinguishing information. This defaults to zero
|
||||
* and is rarely used. Right now its only use is to enable IPv4 ARP to scale,
|
||||
* and this must be done.</p>
|
||||
*
|
||||
* <p>For IPv4 ARP, the implementation must subscribe to 0xffffffffffff (the
|
||||
* broadcast address) but with an ADI equal to each IPv4 address in host
|
||||
* byte order. This converts ARP from a non-scalable broadcast protocol to
|
||||
* a scalable multicast protocol with perfect address specificity.</p>
|
||||
*
|
||||
* <p>If this is not done, ARP will not work reliably.</p>
|
||||
*
|
||||
* <p>Multiple calls to subscribe to the same multicast address will have no
|
||||
* effect. It is perfectly safe to do this.</p>
|
||||
*
|
||||
* <p>This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.</p>
|
||||
*
|
||||
* @param nwid 64-bit network ID
|
||||
* @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits)
|
||||
* @param multicastAdi Multicast ADI (least significant 32 bits only, default: 0)
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode multicastSubscribe(
|
||||
long nwid,
|
||||
long multicastGroup,
|
||||
long multicastAdi) {
|
||||
return multicastSubscribe(nodeId, nwid, multicastGroup, multicastAdi);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unsubscribe from an Ethernet multicast group (or all groups)
|
||||
*
|
||||
* <p>If multicastGroup is zero (0), this will unsubscribe from all groups. If
|
||||
* you are not subscribed to a group this has no effect.</p>
|
||||
*
|
||||
* <p>This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.</p>
|
||||
*
|
||||
* @param nwid 64-bit network ID
|
||||
* @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits)
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode multicastUnsubscribe(
|
||||
long nwid,
|
||||
long multicastGroup) {
|
||||
return multicastUnsubscribe(nodeId, nwid, multicastGroup, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from an Ethernet multicast group (or all groups)
|
||||
*
|
||||
* <p>If multicastGroup is zero (0), this will unsubscribe from all groups. If
|
||||
* you are not subscribed to a group this has no effect.</p>
|
||||
*
|
||||
* <p>This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.</p>
|
||||
*
|
||||
* <p>ADI stands for additional distinguishing information. This defaults to zero
|
||||
* and is rarely used. Right now its only use is to enable IPv4 ARP to scale,
|
||||
* and this must be done.</p>
|
||||
*
|
||||
* @param nwid 64-bit network ID
|
||||
* @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits)
|
||||
* @param multicastAdi Multicast ADI (least significant 32 bits only, default: 0)
|
||||
* @return OK (0) or error code if a fatal error condition has occurred
|
||||
*/
|
||||
public ResultCode multicastUnsubscribe(
|
||||
long nwid,
|
||||
long multicastGroup,
|
||||
long multicastAdi) {
|
||||
return multicastUnsubscribe(nodeId, nwid, multicastGroup, multicastAdi);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this node's 40-bit ZeroTier address
|
||||
*
|
||||
* @return ZeroTier address (least significant 40 bits of 64-bit int)
|
||||
*/
|
||||
public long address() {
|
||||
return address(nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of this node
|
||||
*
|
||||
* @return @{link NodeStatus} struct with the current node status.
|
||||
*/
|
||||
public NodeStatus status() {
|
||||
return status(nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of known peer nodes
|
||||
*
|
||||
* @return List of known peers or NULL on failure
|
||||
*/
|
||||
public Peer[] peers() {
|
||||
return peers(nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of a virtual network
|
||||
*
|
||||
* @param nwid 64-bit network ID
|
||||
* @return {@link VirtualNetworkConfig} or NULL if we are not a member of this network
|
||||
*/
|
||||
public VirtualNetworkConfig networkConfig(long nwid) {
|
||||
return networkConfig(nodeId, nwid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerate and get status of all networks
|
||||
*
|
||||
* @return List of networks or NULL on failure
|
||||
*/
|
||||
public VirtualNetworkConfig[] networks() {
|
||||
return networks(nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ZeroTier One version
|
||||
*
|
||||
* @return {@link Version} object with ZeroTierOne version information.
|
||||
*/
|
||||
public Version getVersion() {
|
||||
return version();
|
||||
}
|
||||
|
||||
//
|
||||
// function declarations for JNI
|
||||
//
|
||||
private native ResultCode node_init(long now);
|
||||
|
||||
private native void node_delete(long nodeId);
|
||||
|
||||
private native ResultCode processVirtualNetworkFrame(
|
||||
long nodeId,
|
||||
long now,
|
||||
long nwid,
|
||||
long sourceMac,
|
||||
long destMac,
|
||||
int etherType,
|
||||
int vlanId,
|
||||
byte[] frameData,
|
||||
long[] nextBackgroundTaskDeadline);
|
||||
|
||||
private native ResultCode processWirePacket(
|
||||
long nodeId,
|
||||
long now,
|
||||
InetSocketAddress localAddress,
|
||||
InetSocketAddress remoteAddress,
|
||||
byte[] packetData,
|
||||
long[] nextBackgroundTaskDeadline);
|
||||
|
||||
private native ResultCode processBackgroundTasks(
|
||||
long nodeId,
|
||||
long now,
|
||||
long[] nextBackgroundTaskDeadline);
|
||||
|
||||
private native ResultCode join(long nodeId, long nwid);
|
||||
|
||||
private native ResultCode leave(long nodeId, long nwid);
|
||||
|
||||
private native ResultCode multicastSubscribe(
|
||||
long nodeId,
|
||||
long nwid,
|
||||
long multicastGroup,
|
||||
long multicastAdi);
|
||||
|
||||
private native ResultCode multicastUnsubscribe(
|
||||
long nodeId,
|
||||
long nwid,
|
||||
long multicastGroup,
|
||||
long multicastAdi);
|
||||
|
||||
private native long address(long nodeId);
|
||||
|
||||
private native NodeStatus status(long nodeId);
|
||||
|
||||
private native VirtualNetworkConfig networkConfig(long nodeId, long nwid);
|
||||
|
||||
private native Version version();
|
||||
|
||||
private native Peer[] peers(long nodeId);
|
||||
|
||||
private native VirtualNetworkConfig[] networks(long nodeId);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.lang.RuntimeException;
|
||||
|
||||
public class NodeException extends RuntimeException {
|
||||
public NodeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public final class NodeStatus {
|
||||
private long address;
|
||||
private String publicIdentity;
|
||||
private String secretIdentity;
|
||||
private boolean online;
|
||||
|
||||
private NodeStatus() {}
|
||||
|
||||
/**
|
||||
* 40-bit ZeroTier address of this node
|
||||
*/
|
||||
public final long getAddres() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public identity in string-serialized form (safe to send to others)
|
||||
*
|
||||
* <p>This identity will remain valid as long as the node exists.</p>
|
||||
*/
|
||||
public final String getPublicIdentity() {
|
||||
return publicIdentity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full identity including secret key in string-serialized form
|
||||
*
|
||||
* <p>This identity will remain valid as long as the node exists.</p>
|
||||
*/
|
||||
public final String getSecretIdentity() {
|
||||
return secretIdentity;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if some kind of connectivity appears available
|
||||
*/
|
||||
public final boolean isOnline() {
|
||||
return online;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
|
||||
public interface PacketSender {
|
||||
/**
|
||||
* Function to send a ZeroTier packet out over the wire
|
||||
*
|
||||
* <p>The function must return zero on success and may return any error code
|
||||
* on failure. Note that success does not (of course) guarantee packet
|
||||
* delivery. It only means that the packet appears to have been sent.</p>
|
||||
*
|
||||
* @param localAddr {@link InetSocketAddress} to send from. Set to null if not specified.
|
||||
* @param remoteAddr {@link InetSocketAddress} to send to
|
||||
* @param packetData data to send
|
||||
* @return 0 on success, any error code on failure.
|
||||
*/
|
||||
public int onSendPacketRequested(
|
||||
InetSocketAddress localAddr,
|
||||
InetSocketAddress remoteAddr,
|
||||
byte[] packetData,
|
||||
int ttl);
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Peer status result
|
||||
*/
|
||||
public final class Peer {
|
||||
private long address;
|
||||
private int versionMajor;
|
||||
private int versionMinor;
|
||||
private int versionRev;
|
||||
private int latency;
|
||||
private PeerRole role;
|
||||
private PeerPhysicalPath[] paths;
|
||||
|
||||
private Peer() {}
|
||||
|
||||
/**
|
||||
* ZeroTier address (40 bits)
|
||||
*/
|
||||
public final long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote major version or -1 if not known
|
||||
*/
|
||||
public final int versionMajor() {
|
||||
return versionMajor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote minor version or -1 if not known
|
||||
*/
|
||||
public final int versionMinor() {
|
||||
return versionMinor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote revision or -1 if not known
|
||||
*/
|
||||
public final int versionRev() {
|
||||
return versionRev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Last measured latency in milliseconds or zero if unknown
|
||||
*/
|
||||
public final int latency() {
|
||||
return latency;
|
||||
}
|
||||
|
||||
/**
|
||||
* What trust hierarchy role does this device have?
|
||||
*/
|
||||
public final PeerRole role() {
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Known network paths to peer
|
||||
*/
|
||||
public final PeerPhysicalPath[] paths() {
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
/**
|
||||
* Physical network path to a peer
|
||||
*/
|
||||
public final class PeerPhysicalPath {
|
||||
private InetSocketAddress address;
|
||||
private long lastSend;
|
||||
private long lastReceive;
|
||||
private boolean fixed;
|
||||
private boolean preferred;
|
||||
|
||||
private PeerPhysicalPath() {}
|
||||
|
||||
/**
|
||||
* Address of endpoint
|
||||
*/
|
||||
public final InetSocketAddress address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time of last send in milliseconds or 0 for never
|
||||
*/
|
||||
public final long lastSend() {
|
||||
return lastSend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Time of last receive in milliseconds or 0 for never
|
||||
*/
|
||||
public final long lastReceive() {
|
||||
return lastReceive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is path fixed? (i.e. not learned, static)
|
||||
*/
|
||||
public final boolean isFixed() {
|
||||
return fixed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is path preferred?
|
||||
*/
|
||||
public final boolean isPreferred() {
|
||||
return preferred;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public enum PeerRole {
|
||||
/**
|
||||
* An ordinary node
|
||||
*/
|
||||
PEER_ROLE_LEAF,
|
||||
|
||||
/**
|
||||
* moon root
|
||||
*/
|
||||
PEER_ROLE_MOON,
|
||||
|
||||
/**
|
||||
* planetary root
|
||||
*/
|
||||
PEER_ROLE_PLANET
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
/**
|
||||
* Function return code: OK (0) or error results
|
||||
*
|
||||
* <p>Use {@link ResultCode#isFatal) to check for a fatal error. If a fatal error
|
||||
* occurs, the node should be considered to not be working correctly. These
|
||||
* indicate serious problems like an inaccessible data store or a compile
|
||||
* problem.</p>
|
||||
*/
|
||||
public enum ResultCode {
|
||||
/**
|
||||
* Operation completed normally
|
||||
*/
|
||||
RESULT_OK(0),
|
||||
|
||||
// Fatal errors (> 0, < 1000)
|
||||
/**
|
||||
* Ran out of memory
|
||||
*/
|
||||
RESULT_FATAL_ERROR_OUT_OF_MEMORY(1),
|
||||
|
||||
/**
|
||||
* Data store is not writable or has failed
|
||||
*/
|
||||
RESULT_FATAL_ERROR_DATA_STORE_FAILED(2),
|
||||
|
||||
/**
|
||||
* Internal error (e.g. unexpected exception indicating bug or build problem)
|
||||
*/
|
||||
RESULT_FATAL_ERROR_INTERNAL(3),
|
||||
|
||||
// non-fatal errors
|
||||
|
||||
/**
|
||||
* Network ID not valid
|
||||
*/
|
||||
RESULT_ERROR_NETWORK_NOT_FOUND(1000);
|
||||
|
||||
private final int id;
|
||||
ResultCode(int id) { this.id = id; }
|
||||
public int getValue() { return id; }
|
||||
|
||||
public boolean isFatal(int id) {
|
||||
return (id > 0 && id < 1000);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public final class Version {
|
||||
private Version() {}
|
||||
|
||||
public int major = 0;
|
||||
public int minor = 0;
|
||||
public int revision = 0;
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.lang.Comparable;
|
||||
import java.lang.Override;
|
||||
import java.lang.String;
|
||||
import java.util.ArrayList;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public final class VirtualNetworkConfig implements Comparable<VirtualNetworkConfig> {
|
||||
public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096;
|
||||
public static final int ZT_MAX_ZT_ASSIGNED_ADDRESSES = 16;
|
||||
|
||||
private long nwid;
|
||||
private long mac;
|
||||
private String name;
|
||||
private VirtualNetworkStatus status;
|
||||
private VirtualNetworkType type;
|
||||
private int mtu;
|
||||
private boolean dhcp;
|
||||
private boolean bridge;
|
||||
private boolean broadcastEnabled;
|
||||
private int portError;
|
||||
private boolean enabled;
|
||||
private long netconfRevision;
|
||||
private InetSocketAddress[] assignedAddresses;
|
||||
private VirtualNetworkRoute[] routes;
|
||||
|
||||
private VirtualNetworkConfig() {
|
||||
|
||||
}
|
||||
|
||||
public boolean equals(VirtualNetworkConfig cfg) {
|
||||
boolean aaEqual = true;
|
||||
if(assignedAddresses.length == cfg.assignedAddresses.length) {
|
||||
for(int i = 0; i < assignedAddresses.length; ++i) {
|
||||
if(!assignedAddresses[i].equals(cfg.assignedAddresses[i])) {
|
||||
aaEqual = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
aaEqual = false;
|
||||
}
|
||||
|
||||
boolean routesEqual = true;
|
||||
if(routes.length == cfg.routes.length) {
|
||||
for (int i = 0; i < routes.length; ++i) {
|
||||
if (!routes[i].equals(cfg.routes[i])) {
|
||||
routesEqual = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
routesEqual = false;
|
||||
}
|
||||
|
||||
return nwid == cfg.nwid &&
|
||||
mac == cfg.mac &&
|
||||
name.equals(cfg.name) &&
|
||||
status.equals(cfg.status) &&
|
||||
type.equals(cfg.type) &&
|
||||
mtu == cfg.mtu &&
|
||||
dhcp == cfg.dhcp &&
|
||||
bridge == cfg.bridge &&
|
||||
broadcastEnabled == cfg.broadcastEnabled &&
|
||||
portError == cfg.portError &&
|
||||
enabled == cfg.enabled &&
|
||||
aaEqual && routesEqual;
|
||||
}
|
||||
|
||||
public int compareTo(VirtualNetworkConfig cfg) {
|
||||
if(cfg.nwid == this.nwid) {
|
||||
return 0;
|
||||
} else {
|
||||
return this.nwid > cfg.nwid ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 64-bit ZeroTier network ID
|
||||
*/
|
||||
public final long networkId() {
|
||||
return nwid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ethernet MAC (40 bits) that should be assigned to port
|
||||
*/
|
||||
public final long macAddress() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network name (from network configuration master)
|
||||
*/
|
||||
public final String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network configuration request status
|
||||
*/
|
||||
public final VirtualNetworkStatus networkStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network type
|
||||
*/
|
||||
public final VirtualNetworkType networkType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum interface MTU
|
||||
*/
|
||||
public final int mtu() {
|
||||
return mtu;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the network this port belongs to indicates DHCP availability
|
||||
*
|
||||
* <p>This is a suggestion. The underlying implementation is free to ignore it
|
||||
* for security or other reasons. This is simply a netconf parameter that
|
||||
* means 'DHCP is available on this network.'</p>
|
||||
*/
|
||||
public final boolean isDhcpAvailable() {
|
||||
return dhcp;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this port is allowed to bridge to other networks
|
||||
*
|
||||
* <p>This is informational. If this is false, bridged packets will simply
|
||||
* be dropped and bridging won't work.</p>
|
||||
*/
|
||||
public final boolean isBridgeEnabled() {
|
||||
return bridge;
|
||||
}
|
||||
|
||||
/**
|
||||
* If true, this network supports and allows broadcast (ff:ff:ff:ff:ff:ff) traffic
|
||||
*/
|
||||
public final boolean broadcastEnabled() {
|
||||
return broadcastEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the network is in PORT_ERROR state, this is the error most recently returned by the port config callback
|
||||
*/
|
||||
public final int portError() {
|
||||
return portError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network config revision as reported by netconf master
|
||||
*
|
||||
* <p>If this is zero, it means we're still waiting for our netconf.</p>
|
||||
*/
|
||||
public final long netconfRevision() {
|
||||
return netconfRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* ZeroTier-assigned addresses (in {@link java.net.InetSocketAddress} objects)
|
||||
*
|
||||
* For IP, the port number of the sockaddr_XX structure contains the number
|
||||
* of bits in the address netmask. Only the IP address and port are used.
|
||||
* Other fields like interface number can be ignored.
|
||||
*
|
||||
* This is only used for ZeroTier-managed address assignments sent by the
|
||||
* virtual network's configuration master.
|
||||
*/
|
||||
public final InetSocketAddress[] assignedAddresses() {
|
||||
return assignedAddresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* ZeroTier-assigned routes (in {@link com.zerotier.sdk.VirtualNetworkRoute} objects)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public final VirtualNetworkRoute[] routes() { return routes; }
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
|
||||
public interface VirtualNetworkConfigListener {
|
||||
/**
|
||||
* Callback called to update virtual network port configuration
|
||||
*
|
||||
* <p>This can be called at any time to update the configuration of a virtual
|
||||
* network port. The parameter after the network ID specifies whether this
|
||||
* port is being brought up, updated, brought down, or permanently deleted.
|
||||
*
|
||||
* This in turn should be used by the underlying implementation to create
|
||||
* and configure tap devices at the OS (or virtual network stack) layer.</P>
|
||||
*
|
||||
* This should not call {@link Node#multicastSubscribe} or other network-modifying
|
||||
* methods, as this could cause a deadlock in multithreaded or interrupt
|
||||
* driven environments.
|
||||
*
|
||||
* This must return 0 on success. It can return any OS-dependent error code
|
||||
* on failure, and this results in the network being placed into the
|
||||
* PORT_ERROR state.
|
||||
*
|
||||
* @param nwid network id
|
||||
* @param op {@link VirtualNetworkConfigOperation} enum describing the configuration operation
|
||||
* @param config {@link VirtualNetworkConfig} object with the new configuration
|
||||
* @return 0 on success
|
||||
*/
|
||||
public int onNetworkConfigurationUpdated(
|
||||
long nwid,
|
||||
VirtualNetworkConfigOperation op,
|
||||
VirtualNetworkConfig config);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public enum VirtualNetworkConfigOperation {
|
||||
/**
|
||||
* Network is coming up (either for the first time or after service restart)
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_UP,
|
||||
|
||||
/**
|
||||
* Network configuration has been updated
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE,
|
||||
|
||||
/**
|
||||
* Network is going down (not permanently)
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN,
|
||||
|
||||
/**
|
||||
* Network is going down permanently (leave/delete)
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public interface VirtualNetworkFrameListener {
|
||||
/**
|
||||
* Function to send a frame out to a virtual network port
|
||||
*
|
||||
* @param nwid ZeroTier One network ID
|
||||
* @param srcMac source MAC address
|
||||
* @param destMac destination MAC address
|
||||
* @param ethertype
|
||||
* @param vlanId
|
||||
* @param frameData data to send
|
||||
*/
|
||||
public void onVirtualNetworkFrame(
|
||||
long nwid,
|
||||
long srcMac,
|
||||
long destMac,
|
||||
long etherType,
|
||||
long vlanId,
|
||||
byte[] frameData);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
public final class VirtualNetworkRoute implements Comparable<VirtualNetworkRoute>
|
||||
{
|
||||
private VirtualNetworkRoute() {
|
||||
target = null;
|
||||
via = null;
|
||||
flags = 0;
|
||||
metric = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Target network / netmask bits (in port field) or NULL or 0.0.0.0/0 for default
|
||||
*/
|
||||
public InetSocketAddress target;
|
||||
|
||||
/**
|
||||
* Gateway IP address (port ignored) or NULL (family == 0) for LAN-local (no gateway)
|
||||
*/
|
||||
public InetSocketAddress via;
|
||||
|
||||
/**
|
||||
* Route flags
|
||||
*/
|
||||
public int flags;
|
||||
|
||||
/**
|
||||
* Route metric (not currently used)
|
||||
*/
|
||||
public int metric;
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(VirtualNetworkRoute other) {
|
||||
return target.toString().compareTo(other.target.toString());
|
||||
}
|
||||
|
||||
public boolean equals(VirtualNetworkRoute other) {
|
||||
boolean targetEquals;
|
||||
if (target == null && other.target == null) {
|
||||
targetEquals = true;
|
||||
}
|
||||
else if (target == null && other.target != null) {
|
||||
targetEquals = false;
|
||||
}
|
||||
else if (target != null && other.target == null) {
|
||||
targetEquals = false;
|
||||
}
|
||||
else {
|
||||
targetEquals = target.equals(other.target);
|
||||
}
|
||||
|
||||
|
||||
boolean viaEquals;
|
||||
if (via == null && other.via == null) {
|
||||
viaEquals = true;
|
||||
}
|
||||
else if (via == null && other.via != null) {
|
||||
viaEquals = false;
|
||||
}
|
||||
else if (via != null && other.via == null) {
|
||||
viaEquals = false;
|
||||
}
|
||||
else {
|
||||
viaEquals = via.equals(other.via);
|
||||
}
|
||||
|
||||
return viaEquals &&
|
||||
viaEquals &&
|
||||
flags == other.flags &&
|
||||
metric == other.metric;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public enum VirtualNetworkStatus {
|
||||
/**
|
||||
* Waiting for network configuration (also means revision == 0)
|
||||
*/
|
||||
NETWORK_STATUS_REQUESTING_CONFIGURATION,
|
||||
|
||||
/**
|
||||
* Configuration received and we are authorized
|
||||
*/
|
||||
NETWORK_STATUS_OK,
|
||||
|
||||
/**
|
||||
* Netconf master told us 'nope'
|
||||
*/
|
||||
NETWORK_STATUS_ACCESS_DENIED,
|
||||
|
||||
/**
|
||||
* Netconf master exists, but this virtual network does not
|
||||
*/
|
||||
NETWORK_STATUS_NOT_FOUND,
|
||||
|
||||
/**
|
||||
* Initialization of network failed or other internal error
|
||||
*/
|
||||
NETWORK_STATUS_PORT_ERROR,
|
||||
|
||||
/**
|
||||
* ZeroTier One version too old
|
||||
*/
|
||||
NETWORK_STATUS_CLIENT_TOO_OLD
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2015 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.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --
|
||||
*
|
||||
* ZeroTier may be used and distributed under the terms of the GPLv3, which
|
||||
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*
|
||||
* If you would like to embed ZeroTier into a commercial application or
|
||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
package com.zerotier.sdk;
|
||||
|
||||
public enum VirtualNetworkType {
|
||||
/**
|
||||
* Private networks are authorized via certificates of membership
|
||||
*/
|
||||
NETWORK_TYPE_PRIVATE,
|
||||
|
||||
/**
|
||||
* Public networks have no access control -- they'll always be AUTHORIZED
|
||||
*/
|
||||
NETWORK_TYPE_PUBLIC
|
||||
}
|
||||
@@ -1,553 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ControlPlane.hpp"
|
||||
#include "OneService.hpp"
|
||||
|
||||
#include "../version.h"
|
||||
#include "../include/ZeroTierOne.h"
|
||||
|
||||
#ifdef ZT_USE_SYSTEM_HTTP_PARSER
|
||||
#include <http_parser.h>
|
||||
#else
|
||||
#include "../ext/http-parser/http_parser.h"
|
||||
#endif
|
||||
|
||||
#include "../ext/json/json.hpp"
|
||||
|
||||
#include "../controller/EmbeddedNetworkController.hpp"
|
||||
|
||||
#include "../node/InetAddress.hpp"
|
||||
#include "../node/Node.hpp"
|
||||
#include "../node/Utils.hpp"
|
||||
#include "../node/World.hpp"
|
||||
|
||||
#include "../osdep/OSUtils.hpp"
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
namespace {
|
||||
|
||||
static void _networkToJson(nlohmann::json &nj,const ZT_VirtualNetworkConfig *nc,const std::string &portDeviceName,const OneService::NetworkSettings &localSettings)
|
||||
{
|
||||
char tmp[256];
|
||||
|
||||
const char *nstatus = "",*ntype = "";
|
||||
switch(nc->status) {
|
||||
case ZT_NETWORK_STATUS_REQUESTING_CONFIGURATION: nstatus = "REQUESTING_CONFIGURATION"; break;
|
||||
case ZT_NETWORK_STATUS_OK: nstatus = "OK"; break;
|
||||
case ZT_NETWORK_STATUS_ACCESS_DENIED: nstatus = "ACCESS_DENIED"; break;
|
||||
case ZT_NETWORK_STATUS_NOT_FOUND: nstatus = "NOT_FOUND"; break;
|
||||
case ZT_NETWORK_STATUS_PORT_ERROR: nstatus = "PORT_ERROR"; break;
|
||||
case ZT_NETWORK_STATUS_CLIENT_TOO_OLD: nstatus = "CLIENT_TOO_OLD"; break;
|
||||
}
|
||||
switch(nc->type) {
|
||||
case ZT_NETWORK_TYPE_PRIVATE: ntype = "PRIVATE"; break;
|
||||
case ZT_NETWORK_TYPE_PUBLIC: ntype = "PUBLIC"; break;
|
||||
}
|
||||
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%.16llx",nc->nwid);
|
||||
nj["id"] = tmp;
|
||||
nj["nwid"] = tmp;
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",(unsigned int)((nc->mac >> 40) & 0xff),(unsigned int)((nc->mac >> 32) & 0xff),(unsigned int)((nc->mac >> 24) & 0xff),(unsigned int)((nc->mac >> 16) & 0xff),(unsigned int)((nc->mac >> 8) & 0xff),(unsigned int)(nc->mac & 0xff));
|
||||
nj["mac"] = tmp;
|
||||
nj["name"] = nc->name;
|
||||
nj["status"] = nstatus;
|
||||
nj["type"] = ntype;
|
||||
nj["mtu"] = nc->mtu;
|
||||
nj["dhcp"] = (bool)(nc->dhcp != 0);
|
||||
nj["bridge"] = (bool)(nc->bridge != 0);
|
||||
nj["broadcastEnabled"] = (bool)(nc->broadcastEnabled != 0);
|
||||
nj["portError"] = nc->portError;
|
||||
nj["netconfRevision"] = nc->netconfRevision;
|
||||
nj["portDeviceName"] = portDeviceName;
|
||||
nj["allowManaged"] = localSettings.allowManaged;
|
||||
nj["allowGlobal"] = localSettings.allowGlobal;
|
||||
nj["allowDefault"] = localSettings.allowDefault;
|
||||
|
||||
nlohmann::json aa = nlohmann::json::array();
|
||||
for(unsigned int i=0;i<nc->assignedAddressCount;++i) {
|
||||
aa.push_back(reinterpret_cast<const InetAddress *>(&(nc->assignedAddresses[i]))->toString());
|
||||
}
|
||||
nj["assignedAddresses"] = aa;
|
||||
|
||||
nlohmann::json ra = nlohmann::json::array();
|
||||
for(unsigned int i=0;i<nc->routeCount;++i) {
|
||||
nlohmann::json rj;
|
||||
rj["target"] = reinterpret_cast<const InetAddress *>(&(nc->routes[i].target))->toString();
|
||||
if (nc->routes[i].via.ss_family == nc->routes[i].target.ss_family)
|
||||
rj["via"] = reinterpret_cast<const InetAddress *>(&(nc->routes[i].via))->toIpString();
|
||||
else rj["via"] = nlohmann::json();
|
||||
rj["flags"] = (int)nc->routes[i].flags;
|
||||
rj["metric"] = (int)nc->routes[i].metric;
|
||||
ra.push_back(rj);
|
||||
}
|
||||
nj["routes"] = ra;
|
||||
}
|
||||
|
||||
static void _peerToJson(nlohmann::json &pj,const ZT_Peer *peer)
|
||||
{
|
||||
char tmp[256];
|
||||
|
||||
const char *prole = "";
|
||||
switch(peer->role) {
|
||||
case ZT_PEER_ROLE_LEAF: prole = "LEAF"; break;
|
||||
case ZT_PEER_ROLE_MOON: prole = "MOON"; break;
|
||||
case ZT_PEER_ROLE_PLANET: prole = "PLANET"; break;
|
||||
}
|
||||
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%.10llx",peer->address);
|
||||
pj["address"] = tmp;
|
||||
pj["versionMajor"] = peer->versionMajor;
|
||||
pj["versionMinor"] = peer->versionMinor;
|
||||
pj["versionRev"] = peer->versionRev;
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%d.%d.%d",peer->versionMajor,peer->versionMinor,peer->versionRev);
|
||||
pj["version"] = tmp;
|
||||
pj["latency"] = peer->latency;
|
||||
pj["role"] = prole;
|
||||
|
||||
nlohmann::json pa = nlohmann::json::array();
|
||||
for(unsigned int i=0;i<peer->pathCount;++i) {
|
||||
nlohmann::json j;
|
||||
j["address"] = reinterpret_cast<const InetAddress *>(&(peer->paths[i].address))->toString();
|
||||
j["lastSend"] = peer->paths[i].lastSend;
|
||||
j["lastReceive"] = peer->paths[i].lastReceive;
|
||||
j["trustedPathId"] = peer->paths[i].trustedPathId;
|
||||
j["linkQuality"] = (double)peer->paths[i].linkQuality / (double)ZT_PATH_LINK_QUALITY_MAX;
|
||||
j["active"] = (bool)(peer->paths[i].expired == 0);
|
||||
j["expired"] = (bool)(peer->paths[i].expired != 0);
|
||||
j["preferred"] = (bool)(peer->paths[i].preferred != 0);
|
||||
pa.push_back(j);
|
||||
}
|
||||
pj["paths"] = pa;
|
||||
}
|
||||
|
||||
static void _moonToJson(nlohmann::json &mj,const World &world)
|
||||
{
|
||||
char tmp[64];
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%.16llx",world.id());
|
||||
mj["id"] = tmp;
|
||||
mj["timestamp"] = world.timestamp();
|
||||
mj["signature"] = Utils::hex(world.signature().data,(unsigned int)world.signature().size());
|
||||
mj["updatesMustBeSignedBy"] = Utils::hex(world.updatesMustBeSignedBy().data,(unsigned int)world.updatesMustBeSignedBy().size());
|
||||
nlohmann::json ra = nlohmann::json::array();
|
||||
for(std::vector<World::Root>::const_iterator r(world.roots().begin());r!=world.roots().end();++r) {
|
||||
nlohmann::json rj;
|
||||
rj["identity"] = r->identity.toString(false);
|
||||
nlohmann::json eps = nlohmann::json::array();
|
||||
for(std::vector<InetAddress>::const_iterator a(r->stableEndpoints.begin());a!=r->stableEndpoints.end();++a)
|
||||
eps.push_back(a->toString());
|
||||
rj["stableEndpoints"] = eps;
|
||||
ra.push_back(rj);
|
||||
}
|
||||
mj["roots"] = ra;
|
||||
mj["waiting"] = false;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
ControlPlane::ControlPlane(OneService *svc,Node *n) :
|
||||
_svc(svc),
|
||||
_node(n),
|
||||
_controller((EmbeddedNetworkController *)0)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int ControlPlane::handleRequest(
|
||||
const InetAddress &fromAddress,
|
||||
unsigned int httpMethod,
|
||||
const std::string &path,
|
||||
const std::map<std::string,std::string> &headers,
|
||||
const std::string &body,
|
||||
std::string &responseBody,
|
||||
std::string &responseContentType)
|
||||
{
|
||||
char tmp[256];
|
||||
unsigned int scode = 404;
|
||||
nlohmann::json res;
|
||||
std::vector<std::string> ps(OSUtils::split(path.c_str(),"/","",""));
|
||||
std::map<std::string,std::string> urlArgs;
|
||||
|
||||
Mutex::Lock _l(_lock);
|
||||
|
||||
/* Note: this is kind of restricted in what it'll take. It does not support
|
||||
* URL encoding, and /'s in URL args will screw it up. But the only URL args
|
||||
* it really uses in ?jsonp=funcionName, and otherwise it just takes simple
|
||||
* paths to simply-named resources. */
|
||||
if (ps.size() > 0) {
|
||||
std::size_t qpos = ps[ps.size() - 1].find('?');
|
||||
if (qpos != std::string::npos) {
|
||||
std::string args(ps[ps.size() - 1].substr(qpos + 1));
|
||||
ps[ps.size() - 1] = ps[ps.size() - 1].substr(0,qpos);
|
||||
std::vector<std::string> asplit(OSUtils::split(args.c_str(),"&","",""));
|
||||
for(std::vector<std::string>::iterator a(asplit.begin());a!=asplit.end();++a) {
|
||||
std::size_t eqpos = a->find('=');
|
||||
if (eqpos == std::string::npos)
|
||||
urlArgs[*a] = "";
|
||||
else urlArgs[a->substr(0,eqpos)] = a->substr(eqpos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isAuth = false;
|
||||
{
|
||||
std::map<std::string,std::string>::const_iterator ah(headers.find("x-zt1-auth"));
|
||||
if ((ah != headers.end())&&(_authTokens.count(ah->second) > 0)) {
|
||||
isAuth = true;
|
||||
} else {
|
||||
ah = urlArgs.find("auth");
|
||||
if ((ah != urlArgs.end())&&(_authTokens.count(ah->second) > 0))
|
||||
isAuth = true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __SYNOLOGY__
|
||||
#include <stdlib.h>
|
||||
// Authenticate via Synology's built-in cgi script
|
||||
if (!isAuth) {
|
||||
/*
|
||||
fprintf(stderr, "path = %s\n", path.c_str());
|
||||
fprintf(stderr, "headers.size=%d\n", headers.size());
|
||||
std::map<std::string, std::string>::const_iterator it(headers.begin());
|
||||
while(it != headers.end()) {
|
||||
fprintf(stderr,"header[%s] = %s\n", (it->first).c_str(), (it->second).c_str());
|
||||
it++;
|
||||
}
|
||||
*/
|
||||
// parse out url args
|
||||
int synotoken_pos = path.find("SynoToken");
|
||||
int argpos = path.find("?");
|
||||
if(synotoken_pos != std::string::npos && argpos != std::string::npos) {
|
||||
std::string cookie = path.substr(argpos+1, synotoken_pos-(argpos+1));
|
||||
std::string synotoken = path.substr(synotoken_pos);
|
||||
std::string cookie_val = cookie.substr(cookie.find("=")+1);
|
||||
std::string synotoken_val = synotoken.substr(synotoken.find("=")+1);
|
||||
// Set necessary env for auth script
|
||||
std::map<std::string,std::string>::const_iterator ah2(headers.find("x-forwarded-for"));
|
||||
setenv("HTTP_COOKIE", cookie_val.c_str(), true);
|
||||
setenv("HTTP_X_SYNO_TOKEN", synotoken_val.c_str(), true);
|
||||
setenv("REMOTE_ADDR", ah2->second.c_str(),true);
|
||||
//fprintf(stderr, "HTTP_COOKIE: %s\n",std::getenv ("HTTP_COOKIE"));
|
||||
//fprintf(stderr, "HTTP_X_SYNO_TOKEN: %s\n",std::getenv ("HTTP_X_SYNO_TOKEN"));
|
||||
//fprintf(stderr, "REMOTE_ADDR: %s\n",std::getenv ("REMOTE_ADDR"));
|
||||
// check synology web auth
|
||||
char user[256], buf[1024];
|
||||
FILE *fp = NULL;
|
||||
bzero(user, 256);
|
||||
fp = popen("/usr/syno/synoman/webman/modules/authenticate.cgi", "r");
|
||||
if(!fp)
|
||||
isAuth = false;
|
||||
else {
|
||||
bzero(buf, sizeof(buf));
|
||||
fread(buf, 1024, 1, fp);
|
||||
if(strlen(buf) > 0) {
|
||||
snprintf(user, 256, "%s", buf);
|
||||
isAuth = true;
|
||||
}
|
||||
}
|
||||
pclose(fp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (httpMethod == HTTP_GET) {
|
||||
if (isAuth) {
|
||||
if (ps[0] == "status") {
|
||||
ZT_NodeStatus status;
|
||||
_node->status(&status);
|
||||
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%.10llx",status.address);
|
||||
res["address"] = tmp;
|
||||
res["publicIdentity"] = status.publicIdentity;
|
||||
res["online"] = (bool)(status.online != 0);
|
||||
res["tcpFallbackActive"] = _svc->tcpFallbackActive();
|
||||
res["versionMajor"] = ZEROTIER_ONE_VERSION_MAJOR;
|
||||
res["versionMinor"] = ZEROTIER_ONE_VERSION_MINOR;
|
||||
res["versionRev"] = ZEROTIER_ONE_VERSION_REVISION;
|
||||
res["versionBuild"] = ZEROTIER_ONE_VERSION_BUILD;
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%d.%d.%d",ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION);
|
||||
res["version"] = tmp;
|
||||
res["clock"] = OSUtils::now();
|
||||
|
||||
World planet(_node->planet());
|
||||
res["planetWorldId"] = planet.id();
|
||||
res["planetWorldTimestamp"] = planet.timestamp();
|
||||
|
||||
#ifdef ZT_ENABLE_CLUSTER
|
||||
nlohmann::json cj;
|
||||
ZT_ClusterStatus cs;
|
||||
_node->clusterStatus(&cs);
|
||||
if (cs.clusterSize >= 1) {
|
||||
nlohmann::json cja = nlohmann::json::array();
|
||||
for(unsigned int i=0;i<cs.clusterSize;++i) {
|
||||
nlohmann::json cjm;
|
||||
cjm["id"] = (int)cs.members[i].id;
|
||||
cjm["msSinceLastHeartbeat"] = cs.members[i].msSinceLastHeartbeat;
|
||||
cjm["alive"] = (bool)(cs.members[i].alive != 0);
|
||||
cjm["x"] = cs.members[i].x;
|
||||
cjm["y"] = cs.members[i].y;
|
||||
cjm["z"] = cs.members[i].z;
|
||||
cjm["load"] = cs.members[i].load;
|
||||
cjm["peers"] = cs.members[i].peers;
|
||||
cja.push_back(cjm);
|
||||
}
|
||||
cj["members"] = cja;
|
||||
cj["myId"] = (int)cs.myId;
|
||||
cj["clusterSize"] = cs.clusterSize;
|
||||
}
|
||||
res["cluster"] = cj;
|
||||
#else
|
||||
res["cluster"] = nlohmann::json();
|
||||
#endif
|
||||
|
||||
scode = 200;
|
||||
} else if (ps[0] == "moon") {
|
||||
std::vector<World> moons(_node->moons());
|
||||
if (ps.size() == 1) {
|
||||
// Return [array] of all moons
|
||||
|
||||
res = nlohmann::json::array();
|
||||
for(std::vector<World>::const_iterator m(moons.begin());m!=moons.end();++m) {
|
||||
nlohmann::json mj;
|
||||
_moonToJson(mj,*m);
|
||||
res.push_back(mj);
|
||||
}
|
||||
|
||||
scode = 200;
|
||||
} else {
|
||||
// Return a single moon by ID
|
||||
|
||||
const uint64_t id = Utils::hexStrToU64(ps[1].c_str());
|
||||
for(std::vector<World>::const_iterator m(moons.begin());m!=moons.end();++m) {
|
||||
if (m->id() == id) {
|
||||
_moonToJson(res,*m);
|
||||
scode = 200;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (ps[0] == "network") {
|
||||
ZT_VirtualNetworkList *nws = _node->networks();
|
||||
if (nws) {
|
||||
if (ps.size() == 1) {
|
||||
// Return [array] of all networks
|
||||
|
||||
res = nlohmann::json::array();
|
||||
for(unsigned long i=0;i<nws->networkCount;++i) {
|
||||
OneService::NetworkSettings localSettings;
|
||||
_svc->getNetworkSettings(nws->networks[i].nwid,localSettings);
|
||||
nlohmann::json nj;
|
||||
_networkToJson(nj,&(nws->networks[i]),_svc->portDeviceName(nws->networks[i].nwid),localSettings);
|
||||
res.push_back(nj);
|
||||
}
|
||||
|
||||
scode = 200;
|
||||
} else if (ps.size() == 2) {
|
||||
// Return a single network by ID or 404 if not found
|
||||
|
||||
const uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str());
|
||||
for(unsigned long i=0;i<nws->networkCount;++i) {
|
||||
if (nws->networks[i].nwid == wantnw) {
|
||||
OneService::NetworkSettings localSettings;
|
||||
_svc->getNetworkSettings(nws->networks[i].nwid,localSettings);
|
||||
_networkToJson(res,&(nws->networks[i]),_svc->portDeviceName(nws->networks[i].nwid),localSettings);
|
||||
scode = 200;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else scode = 404;
|
||||
_node->freeQueryResult((void *)nws);
|
||||
} else scode = 500;
|
||||
} else if (ps[0] == "peer") {
|
||||
ZT_PeerList *pl = _node->peers();
|
||||
if (pl) {
|
||||
if (ps.size() == 1) {
|
||||
// Return [array] of all peers
|
||||
|
||||
res = nlohmann::json::array();
|
||||
for(unsigned long i=0;i<pl->peerCount;++i) {
|
||||
nlohmann::json pj;
|
||||
_peerToJson(pj,&(pl->peers[i]));
|
||||
res.push_back(pj);
|
||||
}
|
||||
|
||||
scode = 200;
|
||||
} else if (ps.size() == 2) {
|
||||
// Return a single peer by ID or 404 if not found
|
||||
|
||||
uint64_t wantp = Utils::hexStrToU64(ps[1].c_str());
|
||||
for(unsigned long i=0;i<pl->peerCount;++i) {
|
||||
if (pl->peers[i].address == wantp) {
|
||||
_peerToJson(res,&(pl->peers[i]));
|
||||
scode = 200;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else scode = 404;
|
||||
_node->freeQueryResult((void *)pl);
|
||||
} else scode = 500;
|
||||
} else {
|
||||
if (_controller) {
|
||||
scode = _controller->handleControlPlaneHttpGET(std::vector<std::string>(ps.begin()+1,ps.end()),urlArgs,headers,body,responseBody,responseContentType);
|
||||
} else scode = 404;
|
||||
}
|
||||
|
||||
} else scode = 401; // isAuth == false
|
||||
} else if ((httpMethod == HTTP_POST)||(httpMethod == HTTP_PUT)) {
|
||||
if (isAuth) {
|
||||
|
||||
if (ps[0] == "moon") {
|
||||
if (ps.size() == 2) {
|
||||
|
||||
uint64_t seed = 0;
|
||||
try {
|
||||
nlohmann::json j(OSUtils::jsonParse(body));
|
||||
if (j.is_object()) {
|
||||
seed = Utils::hexStrToU64(OSUtils::jsonString(j["seed"],"0").c_str());
|
||||
}
|
||||
} catch ( ... ) {
|
||||
// discard invalid JSON
|
||||
}
|
||||
|
||||
std::vector<World> moons(_node->moons());
|
||||
const uint64_t id = Utils::hexStrToU64(ps[1].c_str());
|
||||
for(std::vector<World>::const_iterator m(moons.begin());m!=moons.end();++m) {
|
||||
if (m->id() == id) {
|
||||
_moonToJson(res,*m);
|
||||
scode = 200;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((scode != 200)&&(seed != 0)) {
|
||||
char tmp[64];
|
||||
Utils::snprintf(tmp,sizeof(tmp),"%.16llx",id);
|
||||
res["id"] = tmp;
|
||||
res["roots"] = nlohmann::json::array();
|
||||
res["timestamp"] = 0;
|
||||
res["signature"] = nlohmann::json();
|
||||
res["updatesMustBeSignedBy"] = nlohmann::json();
|
||||
res["waiting"] = true;
|
||||
_node->orbit(id,seed);
|
||||
}
|
||||
|
||||
} else scode = 404;
|
||||
} else if (ps[0] == "network") {
|
||||
if (ps.size() == 2) {
|
||||
|
||||
uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str());
|
||||
_node->join(wantnw,(void *)0); // does nothing if we are a member
|
||||
ZT_VirtualNetworkList *nws = _node->networks();
|
||||
if (nws) {
|
||||
for(unsigned long i=0;i<nws->networkCount;++i) {
|
||||
if (nws->networks[i].nwid == wantnw) {
|
||||
OneService::NetworkSettings localSettings;
|
||||
_svc->getNetworkSettings(nws->networks[i].nwid,localSettings);
|
||||
|
||||
try {
|
||||
nlohmann::json j(OSUtils::jsonParse(body));
|
||||
if (j.is_object()) {
|
||||
nlohmann::json &allowManaged = j["allowManaged"];
|
||||
if (allowManaged.is_boolean()) localSettings.allowManaged = (bool)allowManaged;
|
||||
nlohmann::json &allowGlobal = j["allowGlobal"];
|
||||
if (allowGlobal.is_boolean()) localSettings.allowGlobal = (bool)allowGlobal;
|
||||
nlohmann::json &allowDefault = j["allowDefault"];
|
||||
if (allowDefault.is_boolean()) localSettings.allowDefault = (bool)allowDefault;
|
||||
}
|
||||
} catch ( ... ) {
|
||||
// discard invalid JSON
|
||||
}
|
||||
|
||||
_svc->setNetworkSettings(nws->networks[i].nwid,localSettings);
|
||||
_networkToJson(res,&(nws->networks[i]),_svc->portDeviceName(nws->networks[i].nwid),localSettings);
|
||||
|
||||
scode = 200;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_node->freeQueryResult((void *)nws);
|
||||
} else scode = 500;
|
||||
|
||||
} else scode = 404;
|
||||
} else {
|
||||
if (_controller)
|
||||
scode = _controller->handleControlPlaneHttpPOST(std::vector<std::string>(ps.begin()+1,ps.end()),urlArgs,headers,body,responseBody,responseContentType);
|
||||
else scode = 404;
|
||||
}
|
||||
|
||||
} else scode = 401; // isAuth == false
|
||||
} else if (httpMethod == HTTP_DELETE) {
|
||||
if (isAuth) {
|
||||
|
||||
if (ps[0] == "moon") {
|
||||
if (ps.size() == 2) {
|
||||
_node->deorbit(Utils::hexStrToU64(ps[1].c_str()));
|
||||
res["result"] = true;
|
||||
scode = 200;
|
||||
} // else 404
|
||||
} else if (ps[0] == "network") {
|
||||
ZT_VirtualNetworkList *nws = _node->networks();
|
||||
if (nws) {
|
||||
if (ps.size() == 2) {
|
||||
uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str());
|
||||
for(unsigned long i=0;i<nws->networkCount;++i) {
|
||||
if (nws->networks[i].nwid == wantnw) {
|
||||
_node->leave(wantnw,(void **)0);
|
||||
res["result"] = true;
|
||||
scode = 200;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // else 404
|
||||
_node->freeQueryResult((void *)nws);
|
||||
} else scode = 500;
|
||||
} else {
|
||||
if (_controller)
|
||||
scode = _controller->handleControlPlaneHttpDELETE(std::vector<std::string>(ps.begin()+1,ps.end()),urlArgs,headers,body,responseBody,responseContentType);
|
||||
else scode = 404;
|
||||
}
|
||||
|
||||
} else scode = 401; // isAuth = false
|
||||
} else {
|
||||
scode = 400;
|
||||
}
|
||||
|
||||
if (responseBody.length() == 0) {
|
||||
if ((res.is_object())||(res.is_array()))
|
||||
responseBody = OSUtils::jsonDump(res);
|
||||
else responseBody = "{}";
|
||||
responseContentType = "application/json";
|
||||
}
|
||||
|
||||
// Wrap result in jsonp function call if the user included a jsonp= url argument.
|
||||
// Also double-check isAuth since forbidding this without auth feels safer.
|
||||
std::map<std::string,std::string>::const_iterator jsonp(urlArgs.find("jsonp"));
|
||||
if ((isAuth)&&(jsonp != urlArgs.end())&&(responseContentType == "application/json")) {
|
||||
if (responseBody.length() > 0)
|
||||
responseBody = jsonp->second + "(" + responseBody + ");";
|
||||
else responseBody = jsonp->second + "(null);";
|
||||
responseContentType = "application/javascript";
|
||||
}
|
||||
|
||||
return scode;
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ZT_ONE_CONTROLPLANE_HPP
|
||||
#define ZT_ONE_CONTROLPLANE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "../include/ZeroTierOne.h"
|
||||
|
||||
#include "../node/Mutex.hpp"
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
class OneService;
|
||||
class Node;
|
||||
class EmbeddedNetworkController;
|
||||
struct InetAddress;
|
||||
|
||||
/**
|
||||
* HTTP control plane and static web server
|
||||
*/
|
||||
class ControlPlane
|
||||
{
|
||||
public:
|
||||
ControlPlane(OneService *svc,Node *n);
|
||||
|
||||
/**
|
||||
* Set controller, which will be available under /controller
|
||||
*
|
||||
* @param c Network controller instance
|
||||
*/
|
||||
inline void setController(EmbeddedNetworkController *c)
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
_controller = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an authentication token for API access
|
||||
*/
|
||||
inline void addAuthToken(const char *tok)
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
_authTokens.insert(std::string(tok));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle HTTP request
|
||||
*
|
||||
* @param fromAddress Originating IP address of request
|
||||
* @param httpMethod HTTP method (as defined in ext/http-parser/http_parser.h)
|
||||
* @param path Request path
|
||||
* @param headers Request headers
|
||||
* @param body Request body
|
||||
* @param responseBody Result parameter: fill with response data
|
||||
* @param responseContentType Result parameter: fill with content type
|
||||
* @return HTTP response code
|
||||
*/
|
||||
unsigned int handleRequest(
|
||||
const InetAddress &fromAddress,
|
||||
unsigned int httpMethod,
|
||||
const std::string &path,
|
||||
const std::map<std::string,std::string> &headers,
|
||||
const std::string &body,
|
||||
std::string &responseBody,
|
||||
std::string &responseContentType);
|
||||
|
||||
private:
|
||||
OneService *const _svc;
|
||||
Node *const _node;
|
||||
EmbeddedNetworkController *_controller;
|
||||
std::set<std::string> _authTokens;
|
||||
Mutex _lock;
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
||||
@@ -1,563 +0,0 @@
|
||||
/****************************** Module Header ******************************\
|
||||
* Module Name: ServiceBase.cpp
|
||||
* Project: CppWindowsService
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Provides a base class for a service that will exist as part of a service
|
||||
* application. CServiceBase must be derived from when creating a new service
|
||||
* class.
|
||||
*
|
||||
* This source is subject to the Microsoft Public License.
|
||||
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
* All other rights reserved.
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
\***************************************************************************/
|
||||
|
||||
#pragma region Includes
|
||||
#include "ServiceBase.h"
|
||||
#include <assert.h>
|
||||
#include <strsafe.h>
|
||||
#include <string>
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Static Members
|
||||
|
||||
// Initialize the singleton service instance.
|
||||
CServiceBase *CServiceBase::s_service = NULL;
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::Run(CServiceBase &)
|
||||
//
|
||||
// PURPOSE: Register the executable for a service with the Service Control
|
||||
// Manager (SCM). After you call Run(ServiceBase), the SCM issues a Start
|
||||
// command, which results in a call to the OnStart method in the service.
|
||||
// This method blocks until the service has stopped.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * service - the reference to a CServiceBase object. It will become the
|
||||
// singleton service instance of this service application.
|
||||
//
|
||||
// RETURN VALUE: If the function succeeds, the return value is TRUE. If the
|
||||
// function fails, the return value is FALSE. To get extended error
|
||||
// information, call GetLastError.
|
||||
//
|
||||
BOOL CServiceBase::Run(CServiceBase &service)
|
||||
{
|
||||
s_service = &service;
|
||||
|
||||
SERVICE_TABLE_ENTRYA serviceTable[] =
|
||||
{
|
||||
{ service.m_name, ServiceMain },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
// Connects the main thread of a service process to the service control
|
||||
// manager, which causes the thread to be the service control dispatcher
|
||||
// thread for the calling process. This call returns when the service has
|
||||
// stopped. The process should simply terminate when the call returns.
|
||||
return StartServiceCtrlDispatcher(serviceTable);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::ServiceMain(DWORD, PWSTR *)
|
||||
//
|
||||
// PURPOSE: Entry point for the service. It registers the handler function
|
||||
// for the service and starts the service.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * dwArgc - number of command line arguments
|
||||
// * lpszArgv - array of command line arguments
|
||||
//
|
||||
void WINAPI CServiceBase::ServiceMain(DWORD dwArgc, PSTR *pszArgv)
|
||||
{
|
||||
assert(s_service != NULL);
|
||||
|
||||
// Register the handler function for the service
|
||||
s_service->m_statusHandle = RegisterServiceCtrlHandler(
|
||||
s_service->m_name, ServiceCtrlHandler);
|
||||
if (s_service->m_statusHandle == NULL)
|
||||
{
|
||||
throw GetLastError();
|
||||
}
|
||||
|
||||
// Start the service.
|
||||
s_service->Start(dwArgc, pszArgv);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::ServiceCtrlHandler(DWORD)
|
||||
//
|
||||
// PURPOSE: The function is called by the SCM whenever a control code is
|
||||
// sent to the service.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * dwCtrlCode - the control code. This parameter can be one of the
|
||||
// following values:
|
||||
//
|
||||
// SERVICE_CONTROL_CONTINUE
|
||||
// SERVICE_CONTROL_INTERROGATE
|
||||
// SERVICE_CONTROL_NETBINDADD
|
||||
// SERVICE_CONTROL_NETBINDDISABLE
|
||||
// SERVICE_CONTROL_NETBINDREMOVE
|
||||
// SERVICE_CONTROL_PARAMCHANGE
|
||||
// SERVICE_CONTROL_PAUSE
|
||||
// SERVICE_CONTROL_SHUTDOWN
|
||||
// SERVICE_CONTROL_STOP
|
||||
//
|
||||
// This parameter can also be a user-defined control code ranges from 128
|
||||
// to 255.
|
||||
//
|
||||
void WINAPI CServiceBase::ServiceCtrlHandler(DWORD dwCtrl)
|
||||
{
|
||||
switch (dwCtrl)
|
||||
{
|
||||
case SERVICE_CONTROL_STOP: s_service->Stop(); break;
|
||||
case SERVICE_CONTROL_PAUSE: s_service->Pause(); break;
|
||||
case SERVICE_CONTROL_CONTINUE: s_service->Continue(); break;
|
||||
case SERVICE_CONTROL_SHUTDOWN: s_service->Shutdown(); break;
|
||||
case SERVICE_CONTROL_INTERROGATE: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Service Constructor and Destructor
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::CServiceBase(PWSTR, BOOL, BOOL, BOOL)
|
||||
//
|
||||
// PURPOSE: The constructor of CServiceBase. It initializes a new instance
|
||||
// of the CServiceBase class. The optional parameters (fCanStop,
|
||||
/// fCanShutdown and fCanPauseContinue) allow you to specify whether the
|
||||
// service can be stopped, paused and continued, or be notified when system
|
||||
// shutdown occurs.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * pszServiceName - the name of the service
|
||||
// * fCanStop - the service can be stopped
|
||||
// * fCanShutdown - the service is notified when system shutdown occurs
|
||||
// * fCanPauseContinue - the service can be paused and continued
|
||||
//
|
||||
CServiceBase::CServiceBase(PSTR pszServiceName,
|
||||
BOOL fCanStop,
|
||||
BOOL fCanShutdown,
|
||||
BOOL fCanPauseContinue)
|
||||
{
|
||||
// Service name must be a valid string and cannot be NULL.
|
||||
m_name = (pszServiceName == NULL) ? "" : pszServiceName;
|
||||
|
||||
m_statusHandle = NULL;
|
||||
|
||||
// The service runs in its own process.
|
||||
m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
|
||||
|
||||
// The service is starting.
|
||||
m_status.dwCurrentState = SERVICE_START_PENDING;
|
||||
|
||||
// The accepted commands of the service.
|
||||
DWORD dwControlsAccepted = 0;
|
||||
if (fCanStop)
|
||||
dwControlsAccepted |= SERVICE_ACCEPT_STOP;
|
||||
if (fCanShutdown)
|
||||
dwControlsAccepted |= SERVICE_ACCEPT_SHUTDOWN;
|
||||
if (fCanPauseContinue)
|
||||
dwControlsAccepted |= SERVICE_ACCEPT_PAUSE_CONTINUE;
|
||||
m_status.dwControlsAccepted = dwControlsAccepted;
|
||||
|
||||
m_status.dwWin32ExitCode = NO_ERROR;
|
||||
m_status.dwServiceSpecificExitCode = 0;
|
||||
m_status.dwCheckPoint = 0;
|
||||
m_status.dwWaitHint = 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::~CServiceBase()
|
||||
//
|
||||
// PURPOSE: The virtual destructor of CServiceBase.
|
||||
//
|
||||
CServiceBase::~CServiceBase(void)
|
||||
{
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Service Start, Stop, Pause, Continue, and Shutdown
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::Start(DWORD, PWSTR *)
|
||||
//
|
||||
// PURPOSE: The function starts the service. It calls the OnStart virtual
|
||||
// function in which you can specify the actions to take when the service
|
||||
// starts. If an error occurs during the startup, the error will be logged
|
||||
// in the Application event log, and the service will be stopped.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * dwArgc - number of command line arguments
|
||||
// * lpszArgv - array of command line arguments
|
||||
//
|
||||
void CServiceBase::Start(DWORD dwArgc, PSTR *pszArgv)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Tell SCM that the service is starting.
|
||||
SetServiceStatus(SERVICE_START_PENDING);
|
||||
|
||||
// Perform service-specific initialization.
|
||||
OnStart(dwArgc, pszArgv);
|
||||
|
||||
// Tell SCM that the service is started.
|
||||
SetServiceStatus(SERVICE_RUNNING);
|
||||
}
|
||||
catch (DWORD dwError)
|
||||
{
|
||||
// Log the error.
|
||||
WriteErrorLogEntry("Service Start", dwError);
|
||||
|
||||
// Set the service status to be stopped.
|
||||
SetServiceStatus(SERVICE_STOPPED, dwError);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Log the error.
|
||||
WriteEventLogEntry("Service failed to start.", EVENTLOG_ERROR_TYPE);
|
||||
|
||||
// Set the service status to be stopped.
|
||||
SetServiceStatus(SERVICE_STOPPED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::OnStart(DWORD, PWSTR *)
|
||||
//
|
||||
// PURPOSE: When implemented in a derived class, executes when a Start
|
||||
// command is sent to the service by the SCM or when the operating system
|
||||
// starts (for a service that starts automatically). Specifies actions to
|
||||
// take when the service starts. Be sure to periodically call
|
||||
// CServiceBase::SetServiceStatus() with SERVICE_START_PENDING if the
|
||||
// procedure is going to take long time. You may also consider spawning a
|
||||
// new thread in OnStart to perform time-consuming initialization tasks.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * dwArgc - number of command line arguments
|
||||
// * lpszArgv - array of command line arguments
|
||||
//
|
||||
void CServiceBase::OnStart(DWORD dwArgc, PSTR *pszArgv)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::Stop()
|
||||
//
|
||||
// PURPOSE: The function stops the service. It calls the OnStop virtual
|
||||
// function in which you can specify the actions to take when the service
|
||||
// stops. If an error occurs, the error will be logged in the Application
|
||||
// event log, and the service will be restored to the original state.
|
||||
//
|
||||
void CServiceBase::Stop()
|
||||
{
|
||||
DWORD dwOriginalState = m_status.dwCurrentState;
|
||||
try
|
||||
{
|
||||
// Tell SCM that the service is stopping.
|
||||
SetServiceStatus(SERVICE_STOP_PENDING);
|
||||
|
||||
// Perform service-specific stop operations.
|
||||
OnStop();
|
||||
|
||||
// Tell SCM that the service is stopped.
|
||||
SetServiceStatus(SERVICE_STOPPED);
|
||||
}
|
||||
catch (DWORD dwError)
|
||||
{
|
||||
// Log the error.
|
||||
WriteErrorLogEntry("Service Stop", dwError);
|
||||
|
||||
// Set the orginal service status.
|
||||
SetServiceStatus(dwOriginalState);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Log the error.
|
||||
WriteEventLogEntry("Service failed to stop.", EVENTLOG_ERROR_TYPE);
|
||||
|
||||
// Set the orginal service status.
|
||||
SetServiceStatus(dwOriginalState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::OnStop()
|
||||
//
|
||||
// PURPOSE: When implemented in a derived class, executes when a Stop
|
||||
// command is sent to the service by the SCM. Specifies actions to take
|
||||
// when a service stops running. Be sure to periodically call
|
||||
// CServiceBase::SetServiceStatus() with SERVICE_STOP_PENDING if the
|
||||
// procedure is going to take long time.
|
||||
//
|
||||
void CServiceBase::OnStop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::Pause()
|
||||
//
|
||||
// PURPOSE: The function pauses the service if the service supports pause
|
||||
// and continue. It calls the OnPause virtual function in which you can
|
||||
// specify the actions to take when the service pauses. If an error occurs,
|
||||
// the error will be logged in the Application event log, and the service
|
||||
// will become running.
|
||||
//
|
||||
void CServiceBase::Pause()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Tell SCM that the service is pausing.
|
||||
SetServiceStatus(SERVICE_PAUSE_PENDING);
|
||||
|
||||
// Perform service-specific pause operations.
|
||||
OnPause();
|
||||
|
||||
// Tell SCM that the service is paused.
|
||||
SetServiceStatus(SERVICE_PAUSED);
|
||||
}
|
||||
catch (DWORD dwError)
|
||||
{
|
||||
// Log the error.
|
||||
WriteErrorLogEntry("Service Pause", dwError);
|
||||
|
||||
// Tell SCM that the service is still running.
|
||||
SetServiceStatus(SERVICE_RUNNING);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Log the error.
|
||||
WriteEventLogEntry("Service failed to pause.", EVENTLOG_ERROR_TYPE);
|
||||
|
||||
// Tell SCM that the service is still running.
|
||||
SetServiceStatus(SERVICE_RUNNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::OnPause()
|
||||
//
|
||||
// PURPOSE: When implemented in a derived class, executes when a Pause
|
||||
// command is sent to the service by the SCM. Specifies actions to take
|
||||
// when a service pauses.
|
||||
//
|
||||
void CServiceBase::OnPause()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::Continue()
|
||||
//
|
||||
// PURPOSE: The function resumes normal functioning after being paused if
|
||||
// the service supports pause and continue. It calls the OnContinue virtual
|
||||
// function in which you can specify the actions to take when the service
|
||||
// continues. If an error occurs, the error will be logged in the
|
||||
// Application event log, and the service will still be paused.
|
||||
//
|
||||
void CServiceBase::Continue()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Tell SCM that the service is resuming.
|
||||
SetServiceStatus(SERVICE_CONTINUE_PENDING);
|
||||
|
||||
// Perform service-specific continue operations.
|
||||
OnContinue();
|
||||
|
||||
// Tell SCM that the service is running.
|
||||
SetServiceStatus(SERVICE_RUNNING);
|
||||
}
|
||||
catch (DWORD dwError)
|
||||
{
|
||||
// Log the error.
|
||||
WriteErrorLogEntry("Service Continue", dwError);
|
||||
|
||||
// Tell SCM that the service is still paused.
|
||||
SetServiceStatus(SERVICE_PAUSED);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Log the error.
|
||||
WriteEventLogEntry("Service failed to resume.", EVENTLOG_ERROR_TYPE);
|
||||
|
||||
// Tell SCM that the service is still paused.
|
||||
SetServiceStatus(SERVICE_PAUSED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::OnContinue()
|
||||
//
|
||||
// PURPOSE: When implemented in a derived class, OnContinue runs when a
|
||||
// Continue command is sent to the service by the SCM. Specifies actions to
|
||||
// take when a service resumes normal functioning after being paused.
|
||||
//
|
||||
void CServiceBase::OnContinue()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::Shutdown()
|
||||
//
|
||||
// PURPOSE: The function executes when the system is shutting down. It
|
||||
// calls the OnShutdown virtual function in which you can specify what
|
||||
// should occur immediately prior to the system shutting down. If an error
|
||||
// occurs, the error will be logged in the Application event log.
|
||||
//
|
||||
void CServiceBase::Shutdown()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Perform service-specific shutdown operations.
|
||||
OnShutdown();
|
||||
|
||||
// Tell SCM that the service is stopped.
|
||||
SetServiceStatus(SERVICE_STOPPED);
|
||||
}
|
||||
catch (DWORD dwError)
|
||||
{
|
||||
// Log the error.
|
||||
WriteErrorLogEntry("Service Shutdown", dwError);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Log the error.
|
||||
WriteEventLogEntry("Service failed to shut down.", EVENTLOG_ERROR_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::OnShutdown()
|
||||
//
|
||||
// PURPOSE: When implemented in a derived class, executes when the system
|
||||
// is shutting down. Specifies what should occur immediately prior to the
|
||||
// system shutting down.
|
||||
//
|
||||
void CServiceBase::OnShutdown()
|
||||
{
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
#pragma region Helper Functions
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::SetServiceStatus(DWORD, DWORD, DWORD)
|
||||
//
|
||||
// PURPOSE: The function sets the service status and reports the status to
|
||||
// the SCM.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * dwCurrentState - the state of the service
|
||||
// * dwWin32ExitCode - error code to report
|
||||
// * dwWaitHint - estimated time for pending operation, in milliseconds
|
||||
//
|
||||
void CServiceBase::SetServiceStatus(DWORD dwCurrentState,
|
||||
DWORD dwWin32ExitCode,
|
||||
DWORD dwWaitHint)
|
||||
{
|
||||
static DWORD dwCheckPoint = 1;
|
||||
|
||||
// Fill in the SERVICE_STATUS structure of the service.
|
||||
|
||||
m_status.dwCurrentState = dwCurrentState;
|
||||
m_status.dwWin32ExitCode = dwWin32ExitCode;
|
||||
m_status.dwWaitHint = dwWaitHint;
|
||||
|
||||
m_status.dwCheckPoint =
|
||||
((dwCurrentState == SERVICE_RUNNING) ||
|
||||
(dwCurrentState == SERVICE_STOPPED)) ?
|
||||
0 : dwCheckPoint++;
|
||||
|
||||
// Report the status of the service to the SCM.
|
||||
::SetServiceStatus(m_statusHandle, &m_status);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::WriteEventLogEntry(PWSTR, WORD)
|
||||
//
|
||||
// PURPOSE: Log a message to the Application event log.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * pszMessage - string message to be logged.
|
||||
// * wType - the type of event to be logged. The parameter can be one of
|
||||
// the following values.
|
||||
//
|
||||
// EVENTLOG_SUCCESS
|
||||
// EVENTLOG_AUDIT_FAILURE
|
||||
// EVENTLOG_AUDIT_SUCCESS
|
||||
// EVENTLOG_ERROR_TYPE
|
||||
// EVENTLOG_INFORMATION_TYPE
|
||||
// EVENTLOG_WARNING_TYPE
|
||||
//
|
||||
void CServiceBase::WriteEventLogEntry(PSTR pszMessage, WORD wType)
|
||||
{
|
||||
HANDLE hEventSource = NULL;
|
||||
LPCSTR lpszStrings[2] = { NULL, NULL };
|
||||
|
||||
hEventSource = RegisterEventSource(NULL, m_name);
|
||||
if (hEventSource)
|
||||
{
|
||||
lpszStrings[0] = m_name;
|
||||
lpszStrings[1] = pszMessage;
|
||||
|
||||
ReportEvent(hEventSource, // Event log handle
|
||||
wType, // Event type
|
||||
0, // Event category
|
||||
0, // Event identifier
|
||||
NULL, // No security identifier
|
||||
2, // Size of lpszStrings array
|
||||
0, // No binary data
|
||||
lpszStrings, // Array of strings
|
||||
NULL // No binary data
|
||||
);
|
||||
|
||||
DeregisterEventSource(hEventSource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: CServiceBase::WriteErrorLogEntry(PWSTR, DWORD)
|
||||
//
|
||||
// PURPOSE: Log an error message to the Application event log.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * pszFunction - the function that gives the error
|
||||
// * dwError - the error code
|
||||
//
|
||||
void CServiceBase::WriteErrorLogEntry(PSTR pszFunction, DWORD dwError)
|
||||
{
|
||||
char szMessage[260];
|
||||
StringCchPrintf(szMessage, ARRAYSIZE(szMessage),
|
||||
"%s failed w/err 0x%08lx", pszFunction, dwError);
|
||||
WriteEventLogEntry(szMessage, EVENTLOG_ERROR_TYPE);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
@@ -1,122 +0,0 @@
|
||||
/****************************** Module Header ******************************\
|
||||
* Module Name: ServiceBase.h
|
||||
* Project: CppWindowsService
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Provides a base class for a service that will exist as part of a service
|
||||
* application. CServiceBase must be derived from when creating a new service
|
||||
* class.
|
||||
*
|
||||
* This source is subject to the Microsoft Public License.
|
||||
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
* All other rights reserved.
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
\***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
class CServiceBase
|
||||
{
|
||||
public:
|
||||
|
||||
// Register the executable for a service with the Service Control Manager
|
||||
// (SCM). After you call Run(ServiceBase), the SCM issues a Start command,
|
||||
// which results in a call to the OnStart method in the service. This
|
||||
// method blocks until the service has stopped.
|
||||
static BOOL Run(CServiceBase &service);
|
||||
|
||||
// Service object constructor. The optional parameters (fCanStop,
|
||||
// fCanShutdown and fCanPauseContinue) allow you to specify whether the
|
||||
// service can be stopped, paused and continued, or be notified when
|
||||
// system shutdown occurs.
|
||||
CServiceBase(LPSTR pszServiceName,
|
||||
BOOL fCanStop = TRUE,
|
||||
BOOL fCanShutdown = TRUE,
|
||||
BOOL fCanPauseContinue = FALSE);
|
||||
|
||||
// Service object destructor.
|
||||
virtual ~CServiceBase(void);
|
||||
|
||||
// Stop the service.
|
||||
void Stop();
|
||||
|
||||
protected:
|
||||
|
||||
// When implemented in a derived class, executes when a Start command is
|
||||
// sent to the service by the SCM or when the operating system starts
|
||||
// (for a service that starts automatically). Specifies actions to take
|
||||
// when the service starts.
|
||||
virtual void OnStart(DWORD dwArgc, PSTR *pszArgv);
|
||||
|
||||
// When implemented in a derived class, executes when a Stop command is
|
||||
// sent to the service by the SCM. Specifies actions to take when a
|
||||
// service stops running.
|
||||
virtual void OnStop();
|
||||
|
||||
// When implemented in a derived class, executes when a Pause command is
|
||||
// sent to the service by the SCM. Specifies actions to take when a
|
||||
// service pauses.
|
||||
virtual void OnPause();
|
||||
|
||||
// When implemented in a derived class, OnContinue runs when a Continue
|
||||
// command is sent to the service by the SCM. Specifies actions to take
|
||||
// when a service resumes normal functioning after being paused.
|
||||
virtual void OnContinue();
|
||||
|
||||
// When implemented in a derived class, executes when the system is
|
||||
// shutting down. Specifies what should occur immediately prior to the
|
||||
// system shutting down.
|
||||
virtual void OnShutdown();
|
||||
|
||||
// Set the service status and report the status to the SCM.
|
||||
void SetServiceStatus(DWORD dwCurrentState,
|
||||
DWORD dwWin32ExitCode = NO_ERROR,
|
||||
DWORD dwWaitHint = 0);
|
||||
|
||||
// Log a message to the Application event log.
|
||||
void WriteEventLogEntry(PSTR pszMessage, WORD wType);
|
||||
|
||||
// Log an error message to the Application event log.
|
||||
void WriteErrorLogEntry(PSTR pszFunction,
|
||||
DWORD dwError = GetLastError());
|
||||
|
||||
private:
|
||||
|
||||
// Entry point for the service. It registers the handler function for the
|
||||
// service and starts the service.
|
||||
static void WINAPI ServiceMain(DWORD dwArgc, LPSTR *lpszArgv);
|
||||
|
||||
// The function is called by the SCM whenever a control code is sent to
|
||||
// the service.
|
||||
static void WINAPI ServiceCtrlHandler(DWORD dwCtrl);
|
||||
|
||||
// Start the service.
|
||||
void Start(DWORD dwArgc, PSTR *pszArgv);
|
||||
|
||||
// Pause the service.
|
||||
void Pause();
|
||||
|
||||
// Resume the service after being paused.
|
||||
void Continue();
|
||||
|
||||
// Execute when the system is shutting down.
|
||||
void Shutdown();
|
||||
|
||||
// The singleton service instance.
|
||||
static CServiceBase *s_service;
|
||||
|
||||
// The name of the service
|
||||
LPSTR m_name;
|
||||
|
||||
// The status of the service
|
||||
SERVICE_STATUS m_status;
|
||||
|
||||
// The service status handle
|
||||
SERVICE_STATUS_HANDLE m_statusHandle;
|
||||
};
|
||||
@@ -1,186 +0,0 @@
|
||||
/****************************** Module Header ******************************\
|
||||
* Module Name: ServiceInstaller.cpp
|
||||
* Project: CppWindowsService
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* The file implements functions that install and uninstall the service.
|
||||
*
|
||||
* This source is subject to the Microsoft Public License.
|
||||
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
* All other rights reserved.
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
\***************************************************************************/
|
||||
|
||||
#pragma region "Includes"
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include "ServiceInstaller.h"
|
||||
#pragma endregion
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: InstallService
|
||||
//
|
||||
// PURPOSE: Install the current application as a service to the local
|
||||
// service control manager database.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * pszServiceName - the name of the service to be installed
|
||||
// * pszDisplayName - the display name of the service
|
||||
// * dwStartType - the service start option. This parameter can be one of
|
||||
// the following values: SERVICE_AUTO_START, SERVICE_BOOT_START,
|
||||
// SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START.
|
||||
// * pszDependencies - a pointer to a double null-terminated array of null-
|
||||
// separated names of services or load ordering groups that the system
|
||||
// must start before this service.
|
||||
// * pszAccount - the name of the account under which the service runs.
|
||||
// * pszPassword - the password to the account name.
|
||||
//
|
||||
// NOTE: If the function fails to install the service, it prints the error
|
||||
// in the standard output stream for users to diagnose the problem.
|
||||
//
|
||||
std::string InstallService(PSTR pszServiceName,
|
||||
PSTR pszDisplayName,
|
||||
DWORD dwStartType,
|
||||
PSTR pszDependencies,
|
||||
PSTR pszAccount,
|
||||
PSTR pszPassword)
|
||||
{
|
||||
std::string ret;
|
||||
char szPathTmp[MAX_PATH],szPath[MAX_PATH];
|
||||
SC_HANDLE schSCManager = NULL;
|
||||
SC_HANDLE schService = NULL;
|
||||
|
||||
if (GetModuleFileName(NULL, szPathTmp, ARRAYSIZE(szPath)) == 0)
|
||||
{
|
||||
ret = "GetModuleFileName failed, unable to get path to self";
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
// Quote path in case it contains spaces
|
||||
_snprintf_s(szPath,sizeof(szPath),"\"%s\"",szPathTmp);
|
||||
|
||||
// Open the local default service control manager database
|
||||
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
|
||||
SC_MANAGER_CREATE_SERVICE);
|
||||
if (schSCManager == NULL)
|
||||
{
|
||||
ret = "OpenSCManager failed";
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
// Install the service into SCM by calling CreateService
|
||||
schService = CreateService(
|
||||
schSCManager, // SCManager database
|
||||
pszServiceName, // Name of service
|
||||
pszDisplayName, // Name to display
|
||||
SERVICE_QUERY_STATUS, // Desired access
|
||||
SERVICE_WIN32_OWN_PROCESS, // Service type
|
||||
dwStartType, // Service start type
|
||||
SERVICE_ERROR_NORMAL, // Error control type
|
||||
szPath, // Service's binary
|
||||
NULL, // No load ordering group
|
||||
NULL, // No tag identifier
|
||||
pszDependencies, // Dependencies
|
||||
pszAccount, // Service running account
|
||||
pszPassword // Password of the account
|
||||
);
|
||||
if (schService == NULL)
|
||||
{
|
||||
ret = "CreateService failed";
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
// Centralized cleanup for all allocated resources.
|
||||
if (schSCManager)
|
||||
{
|
||||
CloseServiceHandle(schSCManager);
|
||||
schSCManager = NULL;
|
||||
}
|
||||
if (schService)
|
||||
{
|
||||
CloseServiceHandle(schService);
|
||||
schService = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: UninstallService
|
||||
//
|
||||
// PURPOSE: Stop and remove the service from the local service control
|
||||
// manager database.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * pszServiceName - the name of the service to be removed.
|
||||
//
|
||||
// NOTE: If the function fails to uninstall the service, it prints the
|
||||
// error in the standard output stream for users to diagnose the problem.
|
||||
//
|
||||
std::string UninstallService(PSTR pszServiceName)
|
||||
{
|
||||
std::string ret;
|
||||
SC_HANDLE schSCManager = NULL;
|
||||
SC_HANDLE schService = NULL;
|
||||
SERVICE_STATUS ssSvcStatus = {};
|
||||
|
||||
// Open the local default service control manager database
|
||||
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
|
||||
if (schSCManager == NULL)
|
||||
{
|
||||
ret = "OpenSCManager failed";
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
// Open the service with delete, stop, and query status permissions
|
||||
schService = OpenService(schSCManager, pszServiceName, SERVICE_STOP |
|
||||
SERVICE_QUERY_STATUS | DELETE);
|
||||
if (schService == NULL)
|
||||
{
|
||||
ret = "OpenService failed (is service installed?)";
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
// Try to stop the service
|
||||
if (ControlService(schService, SERVICE_CONTROL_STOP, &ssSvcStatus))
|
||||
{
|
||||
Sleep(500);
|
||||
|
||||
while (QueryServiceStatus(schService, &ssSvcStatus))
|
||||
{
|
||||
if (ssSvcStatus.dwCurrentState == SERVICE_STOP_PENDING)
|
||||
{
|
||||
Sleep(500);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
|
||||
// Now remove the service by calling DeleteService.
|
||||
if (!DeleteService(schService))
|
||||
{
|
||||
ret = "DeleteService failed (is service running?)";
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
// Centralized cleanup for all allocated resources.
|
||||
if (schSCManager)
|
||||
{
|
||||
CloseServiceHandle(schSCManager);
|
||||
schSCManager = NULL;
|
||||
}
|
||||
if (schService)
|
||||
{
|
||||
CloseServiceHandle(schService);
|
||||
schService = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/****************************** Module Header ******************************\
|
||||
* Module Name: ServiceInstaller.h
|
||||
* Project: CppWindowsService
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* The file declares functions that install and uninstall the service.
|
||||
*
|
||||
* This source is subject to the Microsoft Public License.
|
||||
* See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
|
||||
* All other rights reserved.
|
||||
*
|
||||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
|
||||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
\***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
//
|
||||
// FUNCTION: InstallService
|
||||
//
|
||||
// PURPOSE: Install the current application as a service to the local
|
||||
// service control manager database.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * pszServiceName - the name of the service to be installed
|
||||
// * pszDisplayName - the display name of the service
|
||||
// * dwStartType - the service start option. This parameter can be one of
|
||||
// the following values: SERVICE_AUTO_START, SERVICE_BOOT_START,
|
||||
// SERVICE_DEMAND_START, SERVICE_DISABLED, SERVICE_SYSTEM_START.
|
||||
// * pszDependencies - a pointer to a double null-terminated array of null-
|
||||
// separated names of services or load ordering groups that the system
|
||||
// must start before this service.
|
||||
// * pszAccount - the name of the account under which the service runs.
|
||||
// * pszPassword - the password to the account name.
|
||||
//
|
||||
// NOTE: If the function fails to install the service, it prints the error
|
||||
// in the standard output stream for users to diagnose the problem.
|
||||
//
|
||||
// modified for ZT1 to return an error or empty string on success
|
||||
std::string InstallService(PSTR pszServiceName,
|
||||
PSTR pszDisplayName,
|
||||
DWORD dwStartType,
|
||||
PSTR pszDependencies,
|
||||
PSTR pszAccount,
|
||||
PSTR pszPassword);
|
||||
|
||||
|
||||
//
|
||||
// FUNCTION: UninstallService
|
||||
//
|
||||
// PURPOSE: Stop and remove the service from the local service control
|
||||
// manager database.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// * pszServiceName - the name of the service to be removed.
|
||||
//
|
||||
// NOTE: If the function fails to uninstall the service, it prints the
|
||||
// error in the standard output stream for users to diagnose the problem.
|
||||
//
|
||||
// Also modified to return rather than print errors
|
||||
std::string UninstallService(PSTR pszServiceName);
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,322 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\controller\EmbeddedNetworkController.cpp" />
|
||||
<ClCompile Include="..\..\controller\JSONDB.cpp" />
|
||||
<ClCompile Include="..\..\ext\http-parser\http_parser.c" />
|
||||
<ClCompile Include="..\..\ext\libnatpmp\getgateway.c" />
|
||||
<ClCompile Include="..\..\ext\libnatpmp\natpmp.c" />
|
||||
<ClCompile Include="..\..\ext\libnatpmp\wingettimeofday.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\connecthostport.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\igd_desc_parse.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\minisoap.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\minissdpc.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\miniupnpc.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\miniwget.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\minixml.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\portlistingparse.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\receivedata.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnpcommands.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnpdev.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnperrors.c" />
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnpreplyparse.c" />
|
||||
<ClCompile Include="..\..\node\C25519.cpp" />
|
||||
<ClCompile Include="..\..\node\Capability.cpp" />
|
||||
<ClCompile Include="..\..\node\CertificateOfMembership.cpp" />
|
||||
<ClCompile Include="..\..\node\CertificateOfOwnership.cpp" />
|
||||
<ClCompile Include="..\..\node\Cluster.cpp" />
|
||||
<ClCompile Include="..\..\node\Identity.cpp" />
|
||||
<ClCompile Include="..\..\node\IncomingPacket.cpp" />
|
||||
<ClCompile Include="..\..\node\InetAddress.cpp" />
|
||||
<ClCompile Include="..\..\node\Membership.cpp" />
|
||||
<ClCompile Include="..\..\node\Multicaster.cpp" />
|
||||
<ClCompile Include="..\..\node\Network.cpp" />
|
||||
<ClCompile Include="..\..\node\NetworkConfig.cpp" />
|
||||
<ClCompile Include="..\..\node\Node.cpp" />
|
||||
<ClCompile Include="..\..\node\OutboundMulticast.cpp" />
|
||||
<ClCompile Include="..\..\node\Packet.cpp" />
|
||||
<ClCompile Include="..\..\node\Path.cpp" />
|
||||
<ClCompile Include="..\..\node\Peer.cpp" />
|
||||
<ClCompile Include="..\..\node\Poly1305.cpp" />
|
||||
<ClCompile Include="..\..\node\Revocation.cpp" />
|
||||
<ClCompile Include="..\..\node\Salsa20.cpp" />
|
||||
<ClCompile Include="..\..\node\SelfAwareness.cpp" />
|
||||
<ClCompile Include="..\..\node\SHA512.cpp" />
|
||||
<ClCompile Include="..\..\node\Switch.cpp" />
|
||||
<ClCompile Include="..\..\node\Tag.cpp" />
|
||||
<ClCompile Include="..\..\node\Topology.cpp" />
|
||||
<ClCompile Include="..\..\node\Utils.cpp" />
|
||||
<ClCompile Include="..\..\one.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\osdep\Http.cpp" />
|
||||
<ClCompile Include="..\..\osdep\ManagedRoute.cpp" />
|
||||
<ClCompile Include="..\..\osdep\OSUtils.cpp" />
|
||||
<ClCompile Include="..\..\osdep\PortMapper.cpp" />
|
||||
<ClCompile Include="..\..\osdep\WindowsEthernetTap.cpp" />
|
||||
<ClCompile Include="..\..\service\ControlPlane.cpp" />
|
||||
<ClCompile Include="..\..\service\OneService.cpp" />
|
||||
<ClCompile Include="..\..\service\SoftwareUpdater.cpp" />
|
||||
<ClCompile Include="ServiceBase.cpp" />
|
||||
<ClCompile Include="ServiceInstaller.cpp" />
|
||||
<ClCompile Include="ZeroTierOneService.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\ext\http-parser\http_parser.h" />
|
||||
<ClInclude Include="..\..\ext\json\json.hpp" />
|
||||
<ClInclude Include="..\..\ext\libnatpmp\getgateway.h" />
|
||||
<ClInclude Include="..\..\ext\libnatpmp\natpmp.h" />
|
||||
<ClInclude Include="..\..\ext\libnatpmp\wingettimeofday.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\codelength.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\connecthostport.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\igd_desc_parse.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\minisoap.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\minissdpc.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniupnpctypes.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc_declspec.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniwget.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\minixml.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\portlistingparse.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\receivedata.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnpcommands.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnpdev.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnperrors.h" />
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnpreplyparse.h" />
|
||||
<ClInclude Include="..\..\include\ZeroTierOne.h" />
|
||||
<ClInclude Include="..\..\node\Address.hpp" />
|
||||
<ClInclude Include="..\..\node\Array.hpp" />
|
||||
<ClInclude Include="..\..\node\AtomicCounter.hpp" />
|
||||
<ClInclude Include="..\..\node\BandwidthAccount.hpp" />
|
||||
<ClInclude Include="..\..\node\BinarySemaphore.hpp" />
|
||||
<ClInclude Include="..\..\node\Buffer.hpp" />
|
||||
<ClInclude Include="..\..\node\C25519.hpp" />
|
||||
<ClInclude Include="..\..\node\CertificateOfMembership.hpp" />
|
||||
<ClInclude Include="..\..\node\CertificateOfOwnership.hpp" />
|
||||
<ClInclude Include="..\..\node\Cluster.hpp" />
|
||||
<ClInclude Include="..\..\node\CMWC4096.hpp" />
|
||||
<ClInclude Include="..\..\node\Constants.hpp" />
|
||||
<ClInclude Include="..\..\node\DeferredPackets.hpp" />
|
||||
<ClInclude Include="..\..\node\Dictionary.hpp" />
|
||||
<ClInclude Include="..\..\node\Hashtable.hpp" />
|
||||
<ClInclude Include="..\..\node\Identity.hpp" />
|
||||
<ClInclude Include="..\..\node\IncomingPacket.hpp" />
|
||||
<ClInclude Include="..\..\node\InetAddress.hpp" />
|
||||
<ClInclude Include="..\..\node\MAC.hpp" />
|
||||
<ClInclude Include="..\..\node\Multicaster.hpp" />
|
||||
<ClInclude Include="..\..\node\MulticastGroup.hpp" />
|
||||
<ClInclude Include="..\..\node\Mutex.hpp" />
|
||||
<ClInclude Include="..\..\node\Network.hpp" />
|
||||
<ClInclude Include="..\..\node\NetworkConfig.hpp" />
|
||||
<ClInclude Include="..\..\node\NetworkController.hpp" />
|
||||
<ClInclude Include="..\..\node\Node.hpp" />
|
||||
<ClInclude Include="..\..\node\NonCopyable.hpp" />
|
||||
<ClInclude Include="..\..\node\OutboundMulticast.hpp" />
|
||||
<ClInclude Include="..\..\node\Packet.hpp" />
|
||||
<ClInclude Include="..\..\node\Path.hpp" />
|
||||
<ClInclude Include="..\..\node\Peer.hpp" />
|
||||
<ClInclude Include="..\..\node\Poly1305.hpp" />
|
||||
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp" />
|
||||
<ClInclude Include="..\..\node\Salsa20.hpp" />
|
||||
<ClInclude Include="..\..\node\SelfAwareness.hpp" />
|
||||
<ClInclude Include="..\..\node\SHA512.hpp" />
|
||||
<ClInclude Include="..\..\node\SharedPtr.hpp" />
|
||||
<ClInclude Include="..\..\node\Switch.hpp" />
|
||||
<ClInclude Include="..\..\node\Topology.hpp" />
|
||||
<ClInclude Include="..\..\node\Utils.hpp" />
|
||||
<ClInclude Include="..\..\node\World.hpp" />
|
||||
<ClInclude Include="..\..\osdep\Binder.hpp" />
|
||||
<ClInclude Include="..\..\osdep\Http.hpp" />
|
||||
<ClInclude Include="..\..\osdep\ManagedRoute.hpp" />
|
||||
<ClInclude Include="..\..\osdep\OSUtils.hpp" />
|
||||
<ClInclude Include="..\..\osdep\Phy.hpp" />
|
||||
<ClInclude Include="..\..\osdep\PortMapper.hpp" />
|
||||
<ClInclude Include="..\..\osdep\Thread.hpp" />
|
||||
<ClInclude Include="..\..\osdep\WindowsEthernetTap.hpp" />
|
||||
<ClInclude Include="..\..\service\ControlPlane.hpp" />
|
||||
<ClInclude Include="..\..\service\OneService.hpp" />
|
||||
<ClInclude Include="..\..\service\SoftwareUpdater.hpp" />
|
||||
<ClInclude Include="..\..\version.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="ServiceBase.h" />
|
||||
<ClInclude Include="ServiceInstaller.h" />
|
||||
<ClInclude Include="ZeroTierOneService.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ZeroTierOne.rc" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B00A4957-5977-4AC1-9EF4-571DC27EADA2}</ProjectGuid>
|
||||
<RootNamespace>ZeroTierOne</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetExt>.exe</TargetExt>
|
||||
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<TargetName>zerotier-one_x86</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetExt>.exe</TargetExt>
|
||||
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<TargetName>zerotier-one_x86</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetExt>.exe</TargetExt>
|
||||
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<TargetName>zerotier-one_x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetExt>.exe</TargetExt>
|
||||
<OutDir>$(SolutionDir)\Build\$(Platform)\$(Configuration)\</OutDir>
|
||||
<TargetName>zerotier-one_x64</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_RULES_ENGINE_DEBUGGING;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MultiProcessorCompilation>false</MultiProcessorCompilation>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalOptions>"notelemetry.obj" %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>STATICLIB;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_SOFTWARE_UPDATE_DEFAULT="apply";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||
<StringPooling>true</StringPooling>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>
|
||||
</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<StringPooling>true</StringPooling>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wsock32.lib;ws2_32.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,497 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\node">
|
||||
<UniqueIdentifier>{67b1c0f8-b018-4169-9c14-7032ed12c786}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\include">
|
||||
<UniqueIdentifier>{40761a4c-e8db-4a91-9cab-7afef332f4a8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\node">
|
||||
<UniqueIdentifier>{da3b8126-840c-45db-8abe-9d7e7976f8be}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\osdep">
|
||||
<UniqueIdentifier>{6054dfae-4ed2-4d69-8cf5-d6f27646f2d7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\service">
|
||||
<UniqueIdentifier>{9944293a-4a1a-40e9-b92a-eff31fe87e2c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\osdep">
|
||||
<UniqueIdentifier>{ca21bd6b-ff4e-4f9e-bedd-c9f603d2d0d6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\service">
|
||||
<UniqueIdentifier>{e1743b3c-1d18-47f1-ab5a-f5703c19f1df}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\ext">
|
||||
<UniqueIdentifier>{71865460-d693-4c73-84f6-dbff42f49df6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\ext\http-parser">
|
||||
<UniqueIdentifier>{17ae9a01-d39f-4c6d-a800-8f2cd0804c96}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\ext">
|
||||
<UniqueIdentifier>{7784af31-5b60-4300-b07e-44cf864c54db}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\ext\http-parser">
|
||||
<UniqueIdentifier>{f8a1c208-15b8-4d85-a4cb-11d2b82f2d1e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\windows">
|
||||
<UniqueIdentifier>{43f75f84-c70d-4d44-a0ef-28a7a399abd4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\windows\ZeroTierOne">
|
||||
<UniqueIdentifier>{0da07a2f-8922-4827-ac51-29ca3f30f881}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\windows">
|
||||
<UniqueIdentifier>{b74916eb-bb6c-4449-a2a2-fa0b17f60121}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\windows\ZeroTierOne">
|
||||
<UniqueIdentifier>{bf604491-14c4-4a74-81a6-6105d07c5c7c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\ext\miniupnpc">
|
||||
<UniqueIdentifier>{5423fb64-896b-432e-a19d-88d4467f89f9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\ext\miniupnpc">
|
||||
<UniqueIdentifier>{56cc3ab8-3336-4a22-9471-c267ee46cd54}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\ext\libnatpmp">
|
||||
<UniqueIdentifier>{d7292d0d-72a0-4ed6-b717-21debb120737}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\ext\libnatpmp">
|
||||
<UniqueIdentifier>{409ec37e-ff36-4c13-b18d-52d6052e0ca2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\controller">
|
||||
<UniqueIdentifier>{3cad34c8-c436-43ae-8323-57803637c832}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\ext\json">
|
||||
<UniqueIdentifier>{ff20532b-d9a2-440d-a7b4-b49e26a9b2f8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\service\ControlPlane.cpp">
|
||||
<Filter>Source Files\service</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\service\OneService.cpp">
|
||||
<Filter>Source Files\service</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\osdep\WindowsEthernetTap.cpp">
|
||||
<Filter>Source Files\osdep</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\osdep\Http.cpp">
|
||||
<Filter>Source Files\osdep</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\osdep\OSUtils.cpp">
|
||||
<Filter>Source Files\osdep</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\C25519.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\CertificateOfMembership.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Identity.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\IncomingPacket.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\InetAddress.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Multicaster.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Network.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\NetworkConfig.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Node.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\OutboundMulticast.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Packet.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Peer.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Poly1305.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Salsa20.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\SelfAwareness.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\SHA512.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Switch.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Topology.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Utils.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\http-parser\http_parser.c">
|
||||
<Filter>Source Files\ext\http-parser</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\one.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ServiceBase.cpp">
|
||||
<Filter>Source Files\windows\ZeroTierOne</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ServiceInstaller.cpp">
|
||||
<Filter>Source Files\windows\ZeroTierOne</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ZeroTierOneService.cpp">
|
||||
<Filter>Source Files\windows\ZeroTierOne</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Path.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Cluster.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\connecthostport.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\igd_desc_parse.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\minisoap.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\minissdpc.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\miniupnpc.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\miniwget.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\minixml.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\portlistingparse.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\receivedata.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnpcommands.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnpdev.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnperrors.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\miniupnpc\upnpreplyparse.c">
|
||||
<Filter>Source Files\ext\miniupnpc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\osdep\PortMapper.cpp">
|
||||
<Filter>Source Files\osdep</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\libnatpmp\getgateway.c">
|
||||
<Filter>Source Files\ext\libnatpmp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\libnatpmp\natpmp.c">
|
||||
<Filter>Source Files\ext\libnatpmp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\ext\libnatpmp\wingettimeofday.c">
|
||||
<Filter>Source Files\ext\libnatpmp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\osdep\ManagedRoute.cpp">
|
||||
<Filter>Source Files\osdep</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Membership.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Capability.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Revocation.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\Tag.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\controller\EmbeddedNetworkController.cpp">
|
||||
<Filter>Source Files\controller</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\controller\JSONDB.cpp">
|
||||
<Filter>Source Files\controller</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\service\SoftwareUpdater.cpp">
|
||||
<Filter>Source Files\service</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\CertificateOfOwnership.cpp">
|
||||
<Filter>Source Files\node</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\version.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\ZeroTierOne.h">
|
||||
<Filter>Header Files\include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\Http.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\OSUtils.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\Phy.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\Thread.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\WindowsEthernetTap.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\service\ControlPlane.hpp">
|
||||
<Filter>Header Files\service</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\service\OneService.hpp">
|
||||
<Filter>Header Files\service</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Address.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Array.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\AtomicCounter.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\BandwidthAccount.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Buffer.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\C25519.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\CertificateOfMembership.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\CMWC4096.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Constants.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Dictionary.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Identity.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\IncomingPacket.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\InetAddress.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\MAC.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Multicaster.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\MulticastGroup.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Mutex.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Network.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\NetworkConfig.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\NetworkController.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Node.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\NonCopyable.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\OutboundMulticast.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Packet.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Path.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Peer.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Poly1305.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Salsa20.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\SelfAwareness.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\SHA512.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\SharedPtr.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Switch.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Topology.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Utils.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\http-parser\http_parser.h">
|
||||
<Filter>Header Files\ext\http-parser</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ServiceBase.h">
|
||||
<Filter>Header Files\windows\ZeroTierOne</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ServiceInstaller.h">
|
||||
<Filter>Header Files\windows\ZeroTierOne</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ZeroTierOneService.h">
|
||||
<Filter>Header Files\windows\ZeroTierOne</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\BinarySemaphore.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Cluster.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\Hashtable.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\DeferredPackets.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\World.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\codelength.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\connecthostport.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\igd_desc_parse.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\minisoap.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\minissdpc.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniupnpc_declspec.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniupnpctypes.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\miniwget.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\minixml.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\portlistingparse.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\receivedata.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnpcommands.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnpdev.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnperrors.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\miniupnpc\upnpreplyparse.h">
|
||||
<Filter>Header Files\ext\miniupnpc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\PortMapper.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\libnatpmp\getgateway.h">
|
||||
<Filter>Header Files\ext\libnatpmp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\libnatpmp\natpmp.h">
|
||||
<Filter>Header Files\ext\libnatpmp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\libnatpmp\wingettimeofday.h">
|
||||
<Filter>Header Files\ext\libnatpmp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\Binder.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\osdep\ManagedRoute.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\service\SoftwareUpdater.hpp">
|
||||
<Filter>Header Files\service</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\ext\json\json.hpp">
|
||||
<Filter>Header Files\ext\json</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\CertificateOfOwnership.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ZeroTierOne.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma region Includes
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ZeroTierOneService.h"
|
||||
|
||||
#include "../../version.h"
|
||||
#include "../../include/ZeroTierOne.h"
|
||||
|
||||
#include "../../node/Constants.hpp"
|
||||
#include "../../node/Utils.hpp"
|
||||
#include "../../osdep/OSUtils.hpp"
|
||||
#include "../../service/OneService.hpp"
|
||||
|
||||
#pragma endregion // Includes
|
||||
|
||||
#ifdef ZT_DEBUG_SERVICE
|
||||
FILE *SVCDBGfile = (FILE *)0;
|
||||
ZeroTier::Mutex SVCDBGfile_m;
|
||||
#endif
|
||||
|
||||
ZeroTierOneService::ZeroTierOneService() :
|
||||
CServiceBase(ZT_SERVICE_NAME,TRUE,TRUE,FALSE),
|
||||
_service((ZeroTier::OneService *)0)
|
||||
{
|
||||
#ifdef ZT_DEBUG_SERVICE
|
||||
SVCDBGfile_m.lock();
|
||||
if (!SVCDBGfile)
|
||||
SVCDBGfile = fopen(ZT_DEBUG_SERVICE,"a");
|
||||
SVCDBGfile_m.unlock();
|
||||
#endif
|
||||
|
||||
ZT_SVCDBG("ZeroTierOneService::ZeroTierOneService()\r\n");
|
||||
}
|
||||
|
||||
ZeroTierOneService::~ZeroTierOneService(void)
|
||||
{
|
||||
ZT_SVCDBG("ZeroTierOneService::~ZeroTierOneService()\r\n");
|
||||
|
||||
#ifdef ZT_DEBUG_SERVICE
|
||||
SVCDBGfile_m.lock();
|
||||
if (SVCDBGfile) {
|
||||
fclose(SVCDBGfile);
|
||||
SVCDBGfile = (FILE *)0;
|
||||
}
|
||||
SVCDBGfile_m.unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ZeroTierOneService::threadMain()
|
||||
throw()
|
||||
{
|
||||
ZT_SVCDBG("ZeroTierOneService::threadMain()\r\n");
|
||||
|
||||
restart_node:
|
||||
try {
|
||||
{
|
||||
ZeroTier::Mutex::Lock _l(_lock);
|
||||
delete _service;
|
||||
_service = (ZeroTier::OneService *)0; // in case newInstance() fails
|
||||
_service = ZeroTier::OneService::newInstance(
|
||||
ZeroTier::OneService::platformDefaultHomePath().c_str(),
|
||||
ZT_DEFAULT_PORT);
|
||||
}
|
||||
switch(_service->run()) {
|
||||
case ZeroTier::OneService::ONE_UNRECOVERABLE_ERROR: {
|
||||
std::string err("ZeroTier One encountered an unrecoverable error: ");
|
||||
err.append(_service->fatalErrorMessage());
|
||||
err.append(" (restarting in 5 seconds)");
|
||||
WriteEventLogEntry(const_cast <PSTR>(err.c_str()),EVENTLOG_ERROR_TYPE);
|
||||
Sleep(5000);
|
||||
} goto restart_node;
|
||||
|
||||
case ZeroTier::OneService::ONE_IDENTITY_COLLISION: {
|
||||
std::string homeDir(ZeroTier::OneService::platformDefaultHomePath());
|
||||
delete _service;
|
||||
_service = (ZeroTier::OneService *)0;
|
||||
std::string oldid;
|
||||
ZeroTier::OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),oldid);
|
||||
if (oldid.length()) {
|
||||
ZeroTier::OSUtils::writeFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret.saved_after_collision").c_str(),oldid);
|
||||
ZeroTier::OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str());
|
||||
ZeroTier::OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str());
|
||||
}
|
||||
} goto restart_node;
|
||||
|
||||
default: // normal termination
|
||||
break;
|
||||
}
|
||||
} catch ( ... ) {
|
||||
// sanity check, shouldn't happen since Node::run() should catch all its own errors
|
||||
// could also happen if we're out of memory though!
|
||||
WriteEventLogEntry("unexpected exception (out of memory?) (trying again in 5 seconds)",EVENTLOG_ERROR_TYPE);
|
||||
Sleep(5000);
|
||||
goto restart_node;
|
||||
}
|
||||
|
||||
{
|
||||
ZeroTier::Mutex::Lock _l(_lock);
|
||||
delete _service;
|
||||
_service = (ZeroTier::OneService *)0;
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroTierOneService::OnStart(DWORD dwArgc, LPSTR *lpszArgv)
|
||||
{
|
||||
ZT_SVCDBG("ZeroTierOneService::OnStart()\r\n");
|
||||
|
||||
try {
|
||||
_thread = ZeroTier::Thread::start(this);
|
||||
} catch ( ... ) {
|
||||
throw (DWORD)ERROR_EXCEPTION_IN_SERVICE;
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroTierOneService::OnStop()
|
||||
{
|
||||
ZT_SVCDBG("ZeroTierOneService::OnStop()\r\n");
|
||||
|
||||
_lock.lock();
|
||||
ZeroTier::OneService *s = _service;
|
||||
_lock.unlock();
|
||||
|
||||
if (s) {
|
||||
s->terminate();
|
||||
ZeroTier::Thread::join(_thread);
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroTierOneService::OnShutdown()
|
||||
{
|
||||
ZT_SVCDBG("ZeroTierOneService::OnShutdown()\r\n");
|
||||
|
||||
// stop thread on system shutdown (if it hasn't happened already)
|
||||
OnStop();
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* ZeroTier One - Network Virtualization Everywhere
|
||||
* Copyright (C) 2011-2016 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ServiceBase.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../../node/Mutex.hpp"
|
||||
#include "../../osdep/Thread.hpp"
|
||||
#include "../../service/OneService.hpp"
|
||||
|
||||
// Uncomment to make debugging Windows services suck slightly less hard.
|
||||
//#define ZT_DEBUG_SERVICE "C:\\ZeroTierOneServiceDebugLog.txt"
|
||||
|
||||
#ifdef ZT_DEBUG_SERVICE
|
||||
extern FILE *SVCDBGfile;
|
||||
extern ZeroTier::Mutex SVCDBGfile_m;
|
||||
#define ZT_SVCDBG(f,...) { SVCDBGfile_m.lock(); fprintf(SVCDBGfile,f,##__VA_ARGS__); fflush(SVCDBGfile); SVCDBGfile_m.unlock(); }
|
||||
#else
|
||||
#define ZT_SVCDBG(f,...) {}
|
||||
#endif
|
||||
|
||||
#define ZT_SERVICE_NAME "ZeroTierOneService"
|
||||
#define ZT_SERVICE_DISPLAY_NAME "ZeroTier One"
|
||||
#define ZT_SERVICE_START_TYPE SERVICE_AUTO_START
|
||||
#define ZT_SERVICE_DEPENDENCIES ""
|
||||
//#define ZT_SERVICE_ACCOUNT "NT AUTHORITY\\LocalService"
|
||||
#define ZT_SERVICE_ACCOUNT NULL
|
||||
#define ZT_SERVICE_PASSWORD NULL
|
||||
|
||||
class ZeroTierOneService : public CServiceBase
|
||||
{
|
||||
public:
|
||||
ZeroTierOneService();
|
||||
virtual ~ZeroTierOneService(void);
|
||||
|
||||
/**
|
||||
* Thread main method; do not call elsewhere
|
||||
*/
|
||||
void threadMain()
|
||||
throw();
|
||||
|
||||
protected:
|
||||
virtual void OnStart(DWORD dwArgc, PSTR *pszArgv);
|
||||
virtual void OnStop();
|
||||
virtual void OnShutdown();
|
||||
|
||||
private:
|
||||
ZeroTier::OneService *volatile _service;
|
||||
ZeroTier::Mutex _lock;
|
||||
ZeroTier::Thread _thread;
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by ZeroTierOne.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 101
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,7 +1,9 @@
|
||||
ZeroTier - A Planetary Ethernet Switch
|
||||
======
|
||||
|
||||
ZeroTier is an advanced SDN Ethernet switch for planet Earth. It erases the LAN/WAN distinction and makes VPNs, tunnels, proxies, and other kludges arising from the inflexible nature of physical networks obsolete. Everything is encrypted end-to-end and traffic takes the most direct (peer to peer) path available.
|
||||
ZeroTier is an enterprise Ethernet switch for planet Earth.
|
||||
|
||||
It erases the LAN/WAN distinction and makes VPNs, tunnels, proxies, and other kludges arising from the inflexible nature of physical networks obsolete. Everything is encrypted end-to-end and traffic takes the most direct (peer to peer) path available.
|
||||
|
||||
Visit [ZeroTier's site](https://www.zerotier.com/) for more information and [pre-built binary packages](https://www.zerotier.com/download.shtml). Apps for Android and iOS are available for free in the Google Play and Apple app stores.
|
||||
|
||||
92
zto/RELEASE-NOTES.md
Normal file
92
zto/RELEASE-NOTES.md
Normal file
@@ -0,0 +1,92 @@
|
||||
ZeroTier Release Notes
|
||||
======
|
||||
|
||||
*As of 1.2.0 this will serve as a detailed changelog, which we've needed for a long time.*
|
||||
|
||||
# 2017-03-13 -- Version 1.2.0
|
||||
|
||||
Version 1.2.0 is a major milestone release and introduces a large number of new capabilities to the ZeroTier core network hypervisor. It also includes some security tightening, major UI improvements for Windows and Macintosh platforms, and a number of bug fixes and platform issue workarounds.
|
||||
|
||||
## Features in 1.2.0
|
||||
|
||||
### The ZeroTier Rules Engine
|
||||
|
||||
The largest new feature in 1.2.0, and the product of many months of work, is our advanced network rules engine. With this release we achieve traffic control, security monitoring, and micro-segmentation capability on par with many enterprise SDN solutions designed for use in advanced data centers and corporate networks.
|
||||
|
||||
Rules allow you to filter packets on your network and vector traffic to security observers (e.g. a node running Snort). Security observation can be performed in-band using REDIRECT or out of band using TEE, and for tha latter it can be done for headers only, for select traffic, or probabilistically to reduce overhead on large distributed networks.
|
||||
|
||||
Tags and capabilites provide advanced methods for implementing fine grained permission structures and micro-segmentation schemes without bloating the size and complexity of your rules table.
|
||||
|
||||
See our manual for more information.
|
||||
|
||||
### Root Server Federation
|
||||
|
||||
It's now possible to create your own root servers and add them to the root server pool on your nodes. This is done by creating what's called a "moon," which is a signed enumeration of root servers and their stable points on the network. Refer to the manual for more details on how to do this and how it works.
|
||||
|
||||
Federated roots achieve a number of things:
|
||||
|
||||
* You can deploy your own infrastructure to reduce dependency on ours.
|
||||
* You can deploy them *inside your LAN* to ensure that network connectivity inside your facility still works if the Internet goes down. This is the first step toward making ZeroTier viable as an in-house SDN solution.
|
||||
* Roots can be deployed inside national boundaries for countries with data residency laws or "great firewalls." (As of 1.2.0 there is still no way to force all traffic to use these roots, but that will be easy to do in a later version.)
|
||||
* Last but not least this makes ZeroTier somewhat less centralized by eliminating any hard dependency on ZeroTier, Inc.'s infrastructure.
|
||||
|
||||
Our roots will of course remain and continue to provide zero-configuration instant-on deployment, a secure global authority for identities, and free traffic relaying for those who can't establish peer to peer connections.
|
||||
|
||||
### Local Configuration
|
||||
|
||||
An element of our design philosophy is "features are bugs." This isn't an absolute dogma but more of a guiding principle. We try as hard as we can to avoid adding features, especially "knobs" that must be tweaked by a user.
|
||||
|
||||
As of 1.2.0 we've decided that certain knobs are unavoidable, and so there is now a `local.conf` file that can be used to configure them. See the ZeroTier One documentation for these. They include:
|
||||
|
||||
* Blacklisting interfaces you want to make sure ZeroTier doesn't use for network traffic, such as VPNs, slow links, or backplanes designated for only certain kinds of traffic.
|
||||
* Turning uPnP/NAT-PMP on or off.
|
||||
* Configuring software updates on Windows and Mac platforms.
|
||||
* Defining trusted paths (the old trusted paths file is now deprecated)
|
||||
* Setting the ZeroTier main port so it doesn't have to be changed on the command line, which is very inconvenient in many cases.
|
||||
|
||||
### Improved In-Band Software Updates
|
||||
|
||||
A good software update system for Windows and Mac clients has been a missing feature in previous versions. It does exist but we've been shy about using it so far due to its fragility in some environments.
|
||||
|
||||
We've greatly improved this mechanism in 1.2.0. Not only does it now do a better job of actually invoking the update, but it also transfers updates in-band using the ZeroTier protocol. This means it can work in environments that do not allows http/https traffic or that force it through proxies. There's also now an update channel setting: `beta` or `release` (the default).
|
||||
|
||||
As before software updates are authenticated in two ways:
|
||||
|
||||
1. ZeroTier's own signing key is used to sign all updates and this signature is checked prior to installation. Our signatures are done on an air-gapped machine.
|
||||
|
||||
2. Updates for Mac and Windows are signed using Apple and Microsoft (DigiCert) keys and will not install unless these signatures are also valid.
|
||||
|
||||
Version 1.2.0's in-band mechanism effectively adds a third way: updates are fetched in-band from a designated ZeroTier node, thus authenticating the source using ZeroTier's built-in encryption and authentication mechanisms.
|
||||
|
||||
Updates are now configurable via `local.conf`. There are three options: `disable`, `download`, and `apply`. The third is the default for official builds on Windows and Mac, making updates happen silently and automatically as they do for popular browsers like Chrome and Firefox. For managed enterprise deployments IT people could ship a local.conf that disables updates and instead push updates via their management capabilities. Updates are disabled on Linux and other Unix-type platforms as these get updates through package repositories.
|
||||
|
||||
### Path Quality Monitoring (QoS and SD-WAN phase one)
|
||||
|
||||
Version 1.2.0 is now aware of the link quality of direct paths with other 1.2.0 nodes. This information isn't used yet but is visible through the JSON API. (Quality always shows as 100% with pre-1.2.0 nodes.)
|
||||
|
||||
Link quality monitoring is a precursor to intelligent multi-path and QoS support, which will in future versions bring us to feature parity with SD-WAN products like Cisco iWAN.
|
||||
|
||||
"Connect all the things!"
|
||||
|
||||
### Security Improvements
|
||||
|
||||
Version 1.2.0 adds anti-DOS (denial of service) rate limits and other hardening for improved resiliency against a number of denial of service attack scenarios.
|
||||
|
||||
It also adds a mechanism for instantaneous credential revocation. This can be used to revoke certificates of membership instantly to kick a node off a network (for private networks) and also to revoke capabilities and tags. The new controller sends revocations by default when a peer is de-authorized.
|
||||
|
||||
Revocations propagate using a "rumor mill" peer to peer algorithm. This means that a controller need only successfully send a revocation to at least one member of a network with connections to other active members. At this point the revocation will flood through the network peer to peer very quickly. This helps make revocations more robust in the face of poor connectivity with the controller or attempts to incapacitate the controller with denial of service attacks, as well as making revocations faster on huge networks.
|
||||
|
||||
### Windows and Macintosh UI Improvements (ZeroTier One)
|
||||
|
||||
The Mac has a whole new UI built natively in Objective-C. It provides a pulldown similar in appearance and operation to the Mac WiFi task bar menu. The Windows UI has also been improved and now provides a task bar icon that can be right-clicked to manage networks. Both now expose managed route and IP permissions, allowing nodes to easily opt in to full tunnel operation if you have a router configured on your network.
|
||||
|
||||
## Major Bug Fixes in 1.2.0
|
||||
|
||||
* **The Windows HyperV 100% CPU bug**
|
||||
* This long-running problem turns out to have been an issue with Windows itself, but one we were triggering by placing invalid data into the Windows registry. Microsoft is aware of the issue but we've also fixed the triggering problem on our side. ZeroTier should now co-exist quite well with HyperV and should now be able to be bridged with a HyperV virtual switch.
|
||||
* **Segmenation Faults on musl-libc based Linux Systems**
|
||||
* Alpine Linux and some embedded Linux systems that use musl libc (a minimal libc) experienced segmentation faults. These were due to a smaller default stack size. A work-around that sets the stack size for new threads has been added.
|
||||
* **Windows Firewall Blocks Local JSON API**
|
||||
* On some Windows systems the firewall likes to block 127.0.0.1:9993 for mysterious reasons. This is now fixed in the installer via the addition of another firewall exemption rule.
|
||||
* **UI Crash on Embedded Windows Due to Missing Fonts**
|
||||
* The MSI installer now ships fonts and will install them if they are not present, so this should be fixed.
|
||||
@@ -53,7 +53,7 @@ using json = nlohmann::json;
|
||||
#define ZT_NETCONF_CONTROLLER_API_VERSION 3
|
||||
|
||||
// Number of requests to remember in member history
|
||||
#define ZT_NETCONF_DB_MEMBER_HISTORY_LENGTH 24
|
||||
#define ZT_NETCONF_DB_MEMBER_HISTORY_LENGTH 2
|
||||
|
||||
// Min duration between requests for an address/nwid combo to prevent floods
|
||||
#define ZT_NETCONF_MIN_REQUEST_PERIOD 1000
|
||||
@@ -61,6 +61,9 @@ using json = nlohmann::json;
|
||||
// Nodes are considered active if they've queried in less than this long
|
||||
#define ZT_NETCONF_NODE_ACTIVE_THRESHOLD (ZT_NETWORK_AUTOCONF_DELAY * 2)
|
||||
|
||||
// Timeout for disk read cache (ms)
|
||||
#define ZT_NETCONF_DB_CACHE_TTL 60000
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
static json _renderRule(ZT_VirtualNetworkRule &rule)
|
||||
@@ -500,7 +503,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpGET(
|
||||
json network;
|
||||
{
|
||||
Mutex::Lock _l(_db_m);
|
||||
network = _db.get("network",nwids,0);
|
||||
network = _db.get("network",nwids,ZT_NETCONF_DB_CACHE_TTL);
|
||||
}
|
||||
if (!network.size())
|
||||
return 404;
|
||||
@@ -515,7 +518,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpGET(
|
||||
json member;
|
||||
{
|
||||
Mutex::Lock _l(_db_m);
|
||||
member = _db.get("network",nwids,"member",Address(address).toString(),0);
|
||||
member = _db.get("network",nwids,"member",Address(address).toString(),ZT_NETCONF_DB_CACHE_TTL);
|
||||
}
|
||||
if (!member.size())
|
||||
return 404;
|
||||
@@ -531,7 +534,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpGET(
|
||||
|
||||
responseBody = "{";
|
||||
std::string pfx(std::string("network/") + nwids + "member/");
|
||||
_db.filter(pfx,120000,[&responseBody](const std::string &n,const json &member) {
|
||||
_db.filter(pfx,ZT_NETCONF_DB_CACHE_TTL,[&responseBody](const std::string &n,const json &member) {
|
||||
if (member.size() > 0) {
|
||||
responseBody.append((responseBody.length() == 1) ? "\"" : ",\"");
|
||||
responseBody.append(OSUtils::jsonString(member["id"],""));
|
||||
@@ -639,7 +642,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
|
||||
json member;
|
||||
{
|
||||
Mutex::Lock _l(_db_m);
|
||||
member = _db.get("network",nwids,"member",Address(address).toString(),0);
|
||||
member = _db.get("network",nwids,"member",Address(address).toString(),ZT_NETCONF_DB_CACHE_TTL);
|
||||
}
|
||||
json origMember(member); // for detecting changes
|
||||
_initMember(member);
|
||||
@@ -822,7 +825,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
|
||||
uint64_t tryNwid = nwidPrefix | (nwidPostfix & 0xffffffULL);
|
||||
if ((tryNwid & 0xffffffULL) == 0ULL) tryNwid |= 1ULL;
|
||||
Utils::snprintf(nwids,sizeof(nwids),"%.16llx",(unsigned long long)tryNwid);
|
||||
if (_db.get("network",nwids,120000).size() <= 0) {
|
||||
if (_db.get("network",nwids,ZT_NETCONF_DB_CACHE_TTL).size() <= 0) {
|
||||
nwid = tryNwid;
|
||||
break;
|
||||
}
|
||||
@@ -831,7 +834,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
|
||||
return 503;
|
||||
}
|
||||
|
||||
network = _db.get("network",nwids,0);
|
||||
network = _db.get("network",nwids,ZT_NETCONF_DB_CACHE_TTL);
|
||||
}
|
||||
json origNetwork(network); // for detecting changes
|
||||
_initNetwork(network);
|
||||
@@ -1093,7 +1096,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE(
|
||||
json network;
|
||||
{
|
||||
Mutex::Lock _l(_db_m);
|
||||
network = _db.get("network",nwids,0);
|
||||
network = _db.get("network",nwids,ZT_NETCONF_DB_CACHE_TTL);
|
||||
}
|
||||
if (!network.size())
|
||||
return 404;
|
||||
@@ -1104,7 +1107,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE(
|
||||
|
||||
Mutex::Lock _l(_db_m);
|
||||
|
||||
json member = _db.get("network",nwids,"member",Address(address).toString(),0);
|
||||
json member = _db.get("network",nwids,"member",Address(address).toString(),ZT_NETCONF_DB_CACHE_TTL);
|
||||
_db.erase("network",nwids,"member",Address(address).toString());
|
||||
|
||||
if (!member.size())
|
||||
@@ -1244,8 +1247,8 @@ void EmbeddedNetworkController::_request(
|
||||
json member;
|
||||
{
|
||||
Mutex::Lock _l(_db_m);
|
||||
network = _db.get("network",nwids,0);
|
||||
member = _db.get("network",nwids,"member",identity.address().toString(),0);
|
||||
network = _db.get("network",nwids,ZT_NETCONF_DB_CACHE_TTL);
|
||||
member = _db.get("network",nwids,"member",identity.address().toString(),ZT_NETCONF_DB_CACHE_TTL);
|
||||
}
|
||||
|
||||
if (!network.size()) {
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "JSONDB.hpp"
|
||||
|
||||
// Number of background threads to start -- not actually started until needed
|
||||
#define ZT_EMBEDDEDNETWORKCONTROLLER_BACKGROUND_THREAD_COUNT 2
|
||||
#define ZT_EMBEDDEDNETWORKCONTROLLER_BACKGROUND_THREAD_COUNT 4
|
||||
|
||||
// TTL for circuit tests
|
||||
#define ZT_EMBEDDEDNETWORKCONTROLLER_CIRCUIT_TEST_EXPIRATION 120000
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user