Rest -> MPL except controller.
Some checks failed
/ build_macos (push) Has been cancelled
/ build_windows (push) Has been cancelled
/ build_ubuntu (push) Has been cancelled

This commit is contained in:
Adam Ierymenko 2025-08-06 12:16:44 -04:00
commit f6d52dd96c
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
57 changed files with 2411 additions and 2371 deletions

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
/** /**
* @file * @file
@ -29,20 +24,20 @@
#include <string.h> #include <string.h>
#define ZT_MSG_INFO true #define ZT_MSG_INFO true
#define ZT_COLOR true #define ZT_COLOR true
// Debug output colors // Debug output colors
#if defined(__APPLE__) #if defined(__APPLE__)
#include "TargetConditionals.h" #include "TargetConditionals.h"
#endif #endif
#if defined(ZT_COLOR) && ! defined(_WIN32) && ! defined(__ANDROID__) && ! defined(TARGET_OS_IPHONE) && ! defined(TARGET_IPHONE_SIMULATOR) && ! defined(__APP_FRAMEWORK__) #if defined(ZT_COLOR) && ! defined(_WIN32) && ! defined(__ANDROID__) && ! defined(TARGET_OS_IPHONE) && ! defined(TARGET_IPHONE_SIMULATOR) && ! defined(__APP_FRAMEWORK__)
#define ZT_RED "\x1B[31m" #define ZT_RED "\x1B[31m"
#define ZT_GRN "\x1B[32m" #define ZT_GRN "\x1B[32m"
#define ZT_YEL "\x1B[33m" #define ZT_YEL "\x1B[33m"
#define ZT_BLU "\x1B[34m" #define ZT_BLU "\x1B[34m"
#define ZT_MAG "\x1B[35m" #define ZT_MAG "\x1B[35m"
#define ZT_CYN "\x1B[36m" #define ZT_CYN "\x1B[36m"
#define ZT_WHT "\x1B[37m" #define ZT_WHT "\x1B[37m"
#define ZT_RESET "\x1B[0m" #define ZT_RESET "\x1B[0m"
#else #else
#define ZT_RED #define ZT_RED
@ -90,7 +85,7 @@
#else #else
#define DEBUG_INFO(fmt, args...) #define DEBUG_INFO(fmt, args...)
#endif #endif
#else // blank #else // blank
#if defined(_WIN32) #if defined(_WIN32)
#define DEBUG_INFO(...) #define DEBUG_INFO(...)
#else #else
@ -98,4 +93,4 @@
#endif #endif
#endif #endif
#endif // _H #endif // _H

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "Arp.hpp" #include "Arp.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_ARP_HPP #ifndef ZT_ARP_HPP
#define ZT_ARP_HPP #define ZT_ARP_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "BSDEthernetTap.hpp" #include "BSDEthernetTap.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_BSDETHERNETTAP_HPP #ifndef ZT_BSDETHERNETTAP_HPP
#define ZT_BSDETHERNETTAP_HPP #define ZT_BSDETHERNETTAP_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2013-2020 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_BINDER_HPP #ifndef ZT_BINDER_HPP
#define ZT_BINDER_HPP #define ZT_BINDER_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_BLOCKINGQUEUE_HPP #ifndef ZT_BLOCKINGQUEUE_HPP
#define ZT_BLOCKINGQUEUE_HPP #define ZT_BLOCKINGQUEUE_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "EthernetTap.hpp" #include "EthernetTap.hpp"
@ -20,9 +15,9 @@
#ifdef ZT_SDK #ifdef ZT_SDK
#include "../nonfree/controller/EmbeddedNetworkController.hpp"
#include "../include/VirtualTap.hpp" #include "../include/VirtualTap.hpp"
#include "../node/Node.hpp" #include "../node/Node.hpp"
#include "../nonfree/controller/EmbeddedNetworkController.hpp"
#else #else

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_ETHERNETTAP_HPP #ifndef ZT_ETHERNETTAP_HPP
#define ZT_ETHERNETTAP_HPP #define ZT_ETHERNETTAP_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "ExtOsdep.hpp" #include "ExtOsdep.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_EXTOSDEP_HPP #ifndef ZT_EXTOSDEP_HPP
#define ZT_EXTOSDEP_HPP #define ZT_EXTOSDEP_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "Http.hpp" #include "Http.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_HTTP_HPP #ifndef ZT_HTTP_HPP
#define ZT_HTTP_HPP #define ZT_HTTP_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifdef __GNUC__ #ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wrestrict" #pragma GCC diagnostic ignored "-Wrestrict"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_LINUXETHERNETTAP_HPP #ifndef ZT_LINUXETHERNETTAP_HPP
#define ZT_LINUXETHERNETTAP_HPP #define ZT_LINUXETHERNETTAP_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "../node/Constants.hpp" #include "../node/Constants.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_LINUX_NETLINK_HPP #ifndef ZT_LINUX_NETLINK_HPP
#define ZT_LINUX_NETLINK_HPP #define ZT_LINUX_NETLINK_HPP

View file

@ -1,3 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* (c) ZeroTier, Inc.
* https://www.zerotier.com/
*/
#ifndef MAC_DNS_HELPER #ifndef MAC_DNS_HELPER
#define MAC_DNS_HELPER #define MAC_DNS_HELPER

View file

@ -1,3 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* (c) ZeroTier, Inc.
* https://www.zerotier.com/
*/
#include "MacDNSHelper.hpp" #include "MacDNSHelper.hpp"
#include <stdio.h> #include <stdio.h>

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "../node/Constants.hpp" #include "../node/Constants.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_OSXETHERNETTAP_HPP #ifndef ZT_OSXETHERNETTAP_HPP
#define ZT_OSXETHERNETTAP_HPP #define ZT_OSXETHERNETTAP_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
/* /*
* This creates a pair of feth devices with the lower numbered device * This creates a pair of feth devices with the lower numbered device

View file

@ -1,27 +1,22 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_MACETHERNETTAPAGENT_H #ifndef ZT_MACETHERNETTAPAGENT_H
#define ZT_MACETHERNETTAPAGENT_H #define ZT_MACETHERNETTAPAGENT_H
#define ZT_MACETHERNETTAPAGENT_EXIT_CODE_SUCCESS 0 #define ZT_MACETHERNETTAPAGENT_EXIT_CODE_SUCCESS 0
#define ZT_MACETHERNETTAPAGENT_EXIT_CODE_INVALID_REQUEST -1 #define ZT_MACETHERNETTAPAGENT_EXIT_CODE_INVALID_REQUEST -1
#define ZT_MACETHERNETTAPAGENT_EXIT_CODE_UNABLE_TO_CREATE -2 #define ZT_MACETHERNETTAPAGENT_EXIT_CODE_UNABLE_TO_CREATE -2
#define ZT_MACETHERNETTAPAGENT_EXIT_CODE_READ_ERROR -3 #define ZT_MACETHERNETTAPAGENT_EXIT_CODE_READ_ERROR -3
#define ZT_MACETHERNETTAPAGENT_STDIN_CMD_PACKET 0 #define ZT_MACETHERNETTAPAGENT_STDIN_CMD_PACKET 0
#define ZT_MACETHERNETTAPAGENT_STDIN_CMD_IFCONFIG 1 #define ZT_MACETHERNETTAPAGENT_STDIN_CMD_IFCONFIG 1
#define ZT_MACETHERNETTAPAGENT_STDIN_CMD_EXIT 2 #define ZT_MACETHERNETTAPAGENT_STDIN_CMD_EXIT 2
#define ZT_MACETHERNETTAPAGENT_DEFAULT_SYSTEM_PATH "/Library/Application Support/ZeroTier/One/MacEthernetTapAgent" #define ZT_MACETHERNETTAPAGENT_DEFAULT_SYSTEM_PATH "/Library/Application Support/ZeroTier/One/MacEthernetTapAgent"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "MacDNSHelper.hpp" #include "MacDNSHelper.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_MacKextEthernetTap_HPP #ifndef ZT_MacKextEthernetTap_HPP
#define ZT_MacKextEthernetTap_HPP #define ZT_MacKextEthernetTap_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "../node/Constants.hpp" #include "../node/Constants.hpp"
#include "../osdep/OSUtils.hpp" #include "../osdep/OSUtils.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_MANAGEDROUTE_HPP #ifndef ZT_MANAGEDROUTE_HPP
#define ZT_MANAGEDROUTE_HPP #define ZT_MANAGEDROUTE_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "NeighborDiscovery.hpp" #include "NeighborDiscovery.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_NEIGHBORDISCOVERY_HPP #ifndef ZT_NEIGHBORDISCOVERY_HPP
#define ZT_NEIGHBORDISCOVERY_HPP #define ZT_NEIGHBORDISCOVERY_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "NetBSDEthernetTap.hpp" #include "NetBSDEthernetTap.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_NetBSDEthernetTap_HPP #ifndef ZT_NetBSDEthernetTap_HPP
#define ZT_NetBSDEthernetTap_HPP #define ZT_NetBSDEthernetTap_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2013-2020 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "../node/Constants.hpp" #include "../node/Constants.hpp"
#include "../node/Utils.hpp" #include "../node/Utils.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2013-2020 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_OSUTILS_HPP #ifndef ZT_OSUTILS_HPP
#define ZT_OSUTILS_HPP #define ZT_OSUTILS_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2013-2020 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_PHY_HPP #ifndef ZT_PHY_HPP
#define ZT_PHY_HPP #define ZT_PHY_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifdef ZT_USE_MINIUPNPC #ifdef ZT_USE_MINIUPNPC

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifdef ZT_USE_MINIUPNPC #ifdef ZT_USE_MINIUPNPC

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_THREAD_HPP #ifndef ZT_THREAD_HPP
#define ZT_THREAD_HPP #define ZT_THREAD_HPP

View file

@ -1,3 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* (c) ZeroTier, Inc.
* https://www.zerotier.com/
*/
#include "WinDNSHelper.hpp" #include "WinDNSHelper.hpp"
#include <WbemIdl.h> #include <WbemIdl.h>

View file

@ -1,3 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* (c) ZeroTier, Inc.
* https://www.zerotier.com/
*/
#ifndef WIN_DNS_HELPER_H_ #ifndef WIN_DNS_HELPER_H_
#define WIN_DNS_HELPER_H_ #define WIN_DNS_HELPER_H_

View file

@ -1,3 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* (c) ZeroTier, Inc.
* https://www.zerotier.com/
*/
#include "WinFWHelper.hpp" #include "WinFWHelper.hpp"
namespace ZeroTier { namespace ZeroTier {

View file

@ -1,3 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* (c) ZeroTier, Inc.
* https://www.zerotier.com/
*/
#ifndef WIN_FW_HELPER_H_ #ifndef WIN_FW_HELPER_H_
#define WIN_FW_HELPER_H_ #define WIN_FW_HELPER_H_

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "WindowsEthernetTap.hpp" #include "WindowsEthernetTap.hpp"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_WINDOWSETHERNETTAP_HPP #ifndef ZT_WINDOWSETHERNETTAP_HPP
#define ZT_WINDOWSETHERNETTAP_HPP #define ZT_WINDOWSETHERNETTAP_HPP

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,9 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2021 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
#![allow(clippy::uninlined_format_args, clippy::missing_safety_doc)] #![allow(clippy::uninlined_format_args, clippy::missing_safety_doc)]

View file

@ -1,13 +1,9 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2023 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
pub mod ext; pub mod ext;

View file

@ -1,13 +1,9 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2022 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
use thiserror::Error; use thiserror::Error;

View file

@ -1,13 +1,9 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2021 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};

View file

@ -1,13 +1,9 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2021 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
#![allow( #![allow(

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2013-2020 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include <algorithm> #include <algorithm>
#include <condition_variable> #include <condition_variable>

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_ONESERVICE_HPP #ifndef ZT_ONESERVICE_HPP
#define ZT_ONESERVICE_HPP #define ZT_ONESERVICE_HPP

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#include "../node/Constants.hpp" #include "../node/Constants.hpp"
#include "../version.h" #include "../version.h"

View file

@ -1,15 +1,10 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#ifndef ZT_SOFTWAREUPDATER_HPP #ifndef ZT_SOFTWAREUPDATER_HPP
#define ZT_SOFTWAREUPDATER_HPP #define ZT_SOFTWAREUPDATER_HPP

View file

@ -1,19 +1,9 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* ZeroTier One - Network Virtualization Everywhere * License, v. 2.0. If a copy of the MPL was not distributed with this
* Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* This program is free software: you can redistribute it and/or modify * (c) ZeroTier, Inc.
* it under the terms of the GNU General Public License as published by * https://www.zerotier.com/
* 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/>.
*/ */
// HACK! Will eventually use epoll() or something in Phy<> instead of select(). // HACK! Will eventually use epoll() or something in Phy<> instead of select().

View file

@ -1,50 +1,42 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#pragma region Includes #pragma region Includes
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ZeroTierOneService.h" #include "ZeroTierOneService.h"
#include "../../version.h"
#include "../../include/ZeroTierOne.h" #include "../../include/ZeroTierOne.h"
#include "../../node/Constants.hpp" #include "../../node/Constants.hpp"
#include "../../node/Utils.hpp" #include "../../node/Utils.hpp"
#include "../../osdep/OSUtils.hpp" #include "../../osdep/OSUtils.hpp"
#include "../../service/OneService.hpp" #include "../../service/OneService.hpp"
#include "../../version.h"
#pragma endregion // Includes #include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <winsock2.h>
#pragma endregion // Includes
#ifdef ZT_DEBUG_SERVICE #ifdef ZT_DEBUG_SERVICE
FILE *SVCDBGfile = (FILE *)0; FILE* SVCDBGfile = (FILE*)0;
ZeroTier::Mutex SVCDBGfile_m; ZeroTier::Mutex SVCDBGfile_m;
#endif #endif
ZeroTierOneService::ZeroTierOneService() : ZeroTierOneService::ZeroTierOneService() : CServiceBase(ZT_SERVICE_NAME, TRUE, TRUE, FALSE), _service((ZeroTier::OneService*)0)
CServiceBase(ZT_SERVICE_NAME,TRUE,TRUE,FALSE),
_service((ZeroTier::OneService *)0)
{ {
#ifdef ZT_DEBUG_SERVICE #ifdef ZT_DEBUG_SERVICE
SVCDBGfile_m.lock(); SVCDBGfile_m.lock();
if (!SVCDBGfile) if (! SVCDBGfile)
SVCDBGfile = fopen(ZT_DEBUG_SERVICE,"a"); SVCDBGfile = fopen(ZT_DEBUG_SERVICE, "a");
SVCDBGfile_m.unlock(); SVCDBGfile_m.unlock();
#endif #endif
@ -59,14 +51,13 @@ ZeroTierOneService::~ZeroTierOneService(void)
SVCDBGfile_m.lock(); SVCDBGfile_m.lock();
if (SVCDBGfile) { if (SVCDBGfile) {
fclose(SVCDBGfile); fclose(SVCDBGfile);
SVCDBGfile = (FILE *)0; SVCDBGfile = (FILE*)0;
} }
SVCDBGfile_m.unlock(); SVCDBGfile_m.unlock();
#endif #endif
} }
void ZeroTierOneService::threadMain() void ZeroTierOneService::threadMain() throw()
throw()
{ {
ZT_SVCDBG("ZeroTierOneService::threadMain()\r\n"); ZT_SVCDBG("ZeroTierOneService::threadMain()\r\n");
@ -75,38 +66,41 @@ restart_node:
{ {
ZeroTier::Mutex::Lock _l(_lock); ZeroTier::Mutex::Lock _l(_lock);
delete _service; delete _service;
_service = (ZeroTier::OneService *)0; // in case newInstance() fails _service = (ZeroTier::OneService*)0; // in case newInstance() fails
_service = ZeroTier::OneService::newInstance(_path.c_str(), ZT_DEFAULT_PORT); _service = ZeroTier::OneService::newInstance(_path.c_str(), ZT_DEFAULT_PORT);
} }
switch(_service->run()) { switch (_service->run()) {
case ZeroTier::OneService::ONE_UNRECOVERABLE_ERROR: { case ZeroTier::OneService::ONE_UNRECOVERABLE_ERROR: {
std::string err("ZeroTier One encountered an unrecoverable error: "); std::string err("ZeroTier One encountered an unrecoverable error: ");
err.append(_service->fatalErrorMessage()); err.append(_service->fatalErrorMessage());
err.append(" (restarting in 5 seconds)"); err.append(" (restarting in 5 seconds)");
WriteEventLogEntry(const_cast <PSTR>(err.c_str()),EVENTLOG_ERROR_TYPE); WriteEventLogEntry(const_cast<PSTR>(err.c_str()), EVENTLOG_ERROR_TYPE);
Sleep(5000); Sleep(5000);
} goto restart_node; }
goto restart_node;
case ZeroTier::OneService::ONE_IDENTITY_COLLISION: { case ZeroTier::OneService::ONE_IDENTITY_COLLISION: {
std::string homeDir(ZeroTier::OneService::platformDefaultHomePath()); std::string homeDir(ZeroTier::OneService::platformDefaultHomePath());
delete _service; delete _service;
_service = (ZeroTier::OneService *)0; _service = (ZeroTier::OneService*)0;
std::string oldid; std::string oldid;
ZeroTier::OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),oldid); ZeroTier::OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(), oldid);
if (oldid.length()) { if (oldid.length()) {
ZeroTier::OSUtils::writeFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret.saved_after_collision").c_str(),oldid); 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.secret").c_str());
ZeroTier::OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str()); ZeroTier::OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str());
} }
} goto restart_node; }
goto restart_node;
default: // normal termination default: // normal termination
break; break;
} }
} catch ( ... ) { }
catch (...) {
// sanity check, shouldn't happen since Node::run() should catch all its own errors // sanity check, shouldn't happen since Node::run() should catch all its own errors
// could also happen if we're out of memory though! // could also happen if we're out of memory though!
WriteEventLogEntry("unexpected exception (out of memory?) (trying again in 5 seconds)",EVENTLOG_ERROR_TYPE); WriteEventLogEntry("unexpected exception (out of memory?) (trying again in 5 seconds)", EVENTLOG_ERROR_TYPE);
Sleep(5000); Sleep(5000);
goto restart_node; goto restart_node;
} }
@ -114,23 +108,25 @@ restart_node:
{ {
ZeroTier::Mutex::Lock _l(_lock); ZeroTier::Mutex::Lock _l(_lock);
delete _service; delete _service;
_service = (ZeroTier::OneService *)0; _service = (ZeroTier::OneService*)0;
} }
} }
void ZeroTierOneService::OnStart(DWORD dwArgc, PSTR *lpszArgv) void ZeroTierOneService::OnStart(DWORD dwArgc, PSTR* lpszArgv)
{ {
ZT_SVCDBG("ZeroTierOneService::OnStart()\r\n"); ZT_SVCDBG("ZeroTierOneService::OnStart()\r\n");
if ((dwArgc > 1)&&(lpszArgv[1])&&(strlen(lpszArgv[1]) > 0)) { if ((dwArgc > 1) && (lpszArgv[1]) && (strlen(lpszArgv[1]) > 0)) {
this->_path = lpszArgv[1]; this->_path = lpszArgv[1];
} else { }
else {
this->_path = ZeroTier::OneService::platformDefaultHomePath(); this->_path = ZeroTier::OneService::platformDefaultHomePath();
} }
try { try {
_thread = ZeroTier::Thread::start(this); _thread = ZeroTier::Thread::start(this);
} catch ( ... ) { }
catch (...) {
throw (DWORD)ERROR_EXCEPTION_IN_SERVICE; throw (DWORD)ERROR_EXCEPTION_IN_SERVICE;
} }
} }
@ -140,7 +136,7 @@ void ZeroTierOneService::OnStop()
ZT_SVCDBG("ZeroTierOneService::OnStop()\r\n"); ZT_SVCDBG("ZeroTierOneService::OnStop()\r\n");
_lock.lock(); _lock.lock();
ZeroTier::OneService *s = _service; ZeroTier::OneService* s = _service;
_lock.unlock(); _lock.unlock();
if (s) { if (s) {

View file

@ -1,69 +1,68 @@
/* /* This Source Code Form is subject to the terms of the Mozilla Public
* Copyright (c)2019 ZeroTier, Inc. * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
* *
* Use of this software is governed by the Business Source License included * (c) ZeroTier, Inc.
* in the LICENSE.TXT file in the project's root directory. * https://www.zerotier.com/
*
* Change Date: 2026-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/ */
/****/
#pragma once #pragma once
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#include <stdio.h>
#include "ServiceBase.h"
#include <string>
#include "../../node/Mutex.hpp" #include "../../node/Mutex.hpp"
#include "../../osdep/Thread.hpp" #include "../../osdep/Thread.hpp"
#include "../../service/OneService.hpp" #include "../../service/OneService.hpp"
#include "ServiceBase.h"
#include <stdio.h>
#include <string>
// Uncomment to make debugging Windows services suck slightly less hard. // Uncomment to make debugging Windows services suck slightly less hard.
//#define ZT_DEBUG_SERVICE "C:\\ZeroTierOneServiceDebugLog.txt" // #define ZT_DEBUG_SERVICE "C:\\ZeroTierOneServiceDebugLog.txt"
#ifdef ZT_DEBUG_SERVICE #ifdef ZT_DEBUG_SERVICE
extern FILE *SVCDBGfile; extern FILE* SVCDBGfile;
extern ZeroTier::Mutex SVCDBGfile_m; extern ZeroTier::Mutex SVCDBGfile_m;
#define ZT_SVCDBG(f,...) { SVCDBGfile_m.lock(); fprintf(SVCDBGfile,f,##__VA_ARGS__); fflush(SVCDBGfile); SVCDBGfile_m.unlock(); } #define ZT_SVCDBG(f, ...) \
{ \
SVCDBGfile_m.lock(); \
fprintf(SVCDBGfile, f, ##__VA_ARGS__); \
fflush(SVCDBGfile); \
SVCDBGfile_m.unlock(); \
}
#else #else
#define ZT_SVCDBG(f,...) {} #define ZT_SVCDBG(f, ...) \
{ \
}
#endif #endif
#define ZT_SERVICE_NAME "ZeroTierOneService" #define ZT_SERVICE_NAME "ZeroTierOneService"
#define ZT_SERVICE_DISPLAY_NAME "ZeroTier One" #define ZT_SERVICE_DISPLAY_NAME "ZeroTier One"
#define ZT_SERVICE_START_TYPE SERVICE_AUTO_START #define ZT_SERVICE_START_TYPE SERVICE_AUTO_START
#define ZT_SERVICE_DEPENDENCIES "" #define ZT_SERVICE_DEPENDENCIES ""
//#define ZT_SERVICE_ACCOUNT "NT AUTHORITY\\LocalService" // #define ZT_SERVICE_ACCOUNT "NT AUTHORITY\\LocalService"
#define ZT_SERVICE_ACCOUNT NULL #define ZT_SERVICE_ACCOUNT NULL
#define ZT_SERVICE_PASSWORD NULL #define ZT_SERVICE_PASSWORD NULL
class ZeroTierOneService : public CServiceBase class ZeroTierOneService : public CServiceBase {
{ public:
public: ZeroTierOneService();
ZeroTierOneService(); virtual ~ZeroTierOneService(void);
virtual ~ZeroTierOneService(void);
/** /**
* Thread main method; do not call elsewhere * Thread main method; do not call elsewhere
*/ */
void threadMain() void threadMain() throw();
throw();
protected: protected:
virtual void OnStart(DWORD dwArgc, PSTR *pszArgv); virtual void OnStart(DWORD dwArgc, PSTR* pszArgv);
virtual void OnStop(); virtual void OnStop();
virtual void OnShutdown(); virtual void OnShutdown();
private: private:
std::string _path; std::string _path;
ZeroTier::OneService *volatile _service; ZeroTier::OneService* volatile _service;
ZeroTier::Mutex _lock; ZeroTier::Mutex _lock;
ZeroTier::Thread _thread; ZeroTier::Thread _thread;
}; };