mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-03 19:13:43 +02:00
Locator stuff, and more cleanup of things that may come back...
This commit is contained in:
parent
faecf04dd5
commit
2acd67fbc1
8 changed files with 135 additions and 608 deletions
61
AUTHORS.md
61
AUTHORS.md
|
@ -1,61 +0,0 @@
|
|||
# Authors and Third Party Code Licensing Information
|
||||
|
||||
## Primary Authors
|
||||
|
||||
* ZeroTier Core and ZeroTier One virtual networking service<br>
|
||||
Adam Ierymenko / adam.ierymenko@zerotier.com
|
||||
Joseph Henry / joseph.henry@zerotier.com (QoS and multipath)
|
||||
|
||||
* Java JNI Interface to enable Android application development, and Android app itself (code for that is elsewhere)<br>
|
||||
Grant Limberg / glimberg@gmail.com
|
||||
|
||||
* ZeroTier SDK / libzt<br>
|
||||
Joseph Henry / joseph.henry@zerotier.com
|
||||
|
||||
## Third Party Contributors
|
||||
|
||||
* A number of fixes and improvements to the new controller, other stuff.<br>
|
||||
Kees Bos / https://github.com/keesbos/
|
||||
|
||||
* Debugging and testing, OpenWRT support fixes.<br>
|
||||
Moritz Warning / moritzwarning@web.de
|
||||
|
||||
* Debian GNU/Linux packaging, manual pages, and license compliance edits.<br>
|
||||
Ben Finney <ben+zerotier@benfinney.id.au>
|
||||
|
||||
* Several others made smaller contributions, which GitHub tracks here:<br>
|
||||
https://github.com/zerotier/ZeroTierOne/graphs/contributors/
|
||||
|
||||
## Third-Party Code
|
||||
|
||||
ZeroTier includes the following third party code, either in ext/ or incorporated into the ZeroTier core. This third party code remains licensed under its original license and is not subject to ZeroTier's BSL license.
|
||||
|
||||
* LZ4 compression algorithm by Yann Collet
|
||||
|
||||
* Files: node/LZ4.cpp
|
||||
* Home page: http://code.google.com/p/lz4/
|
||||
* License: BSD 2-clause
|
||||
|
||||
* C++11 json (nlohmann/json) by Niels Lohmann
|
||||
|
||||
* Files: ext/json/*
|
||||
* Home page: https://github.com/nlohmann/json
|
||||
* License: MIT
|
||||
|
||||
* tap-windows6 by the OpenVPN project
|
||||
|
||||
* Files: windows/TapDriver6/*
|
||||
* Home page: https://github.com/OpenVPN/tap-windows6/
|
||||
* License: GNU GPL v2
|
||||
|
||||
* Salsa20 stream cipher, Curve25519 elliptic curve cipher, Ed25519 digital signature algorithm, and Poly1305 MAC algorithm, all by Daniel J. Bernstein
|
||||
|
||||
* Files: node/Salsa20.* node/C25519.* node/Poly1305.*
|
||||
* Home page: http://cr.yp.to/
|
||||
* License: public domain
|
||||
|
||||
* cpp-httplib by yhirose
|
||||
|
||||
* Files: ext/cpp-httplib/*
|
||||
* Home page: https://github.com/yhirose/cpp-httplib
|
||||
* License: MIT
|
12
COPYING
12
COPYING
|
@ -1,12 +0,0 @@
|
|||
ZeroTier One, an endpoint server for the ZeroTier virtual network layer.
|
||||
Copyright © 2013–2020 ZeroTier, Inc.
|
||||
|
||||
ZeroTier is released under the terms of the BSL version 1.1. See the
|
||||
file LICENSE.txt for details.
|
||||
|
||||
..
|
||||
Local variables:
|
||||
coding: utf-8
|
||||
mode: text
|
||||
End:
|
||||
vim: fileencoding=utf-8 filetype=text :
|
149
LICENSE.txt
149
LICENSE.txt
|
@ -1,149 +0,0 @@
|
|||
-----------------------------------------------------------------------------
|
||||
|
||||
Business Source License 1.1
|
||||
|
||||
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
||||
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Parameters
|
||||
|
||||
Licensor: ZeroTier, Inc.
|
||||
Licensed Work: ZeroTier Network Virtualization Engine
|
||||
The Licensed Work is (c)2013-2021 ZeroTier, Inc.
|
||||
Additional Use Grant: You may make use of the Licensed Work, provided you
|
||||
do not use it in any of the following ways:
|
||||
|
||||
* Sell hosted ZeroTier services as a "SaaS" Product
|
||||
|
||||
(1) Operate or sell access to ZeroTier root servers,
|
||||
network controllers, or authorization key or certificate
|
||||
generation components of the Licensed Work as a
|
||||
for-profit service, regardless of whether the use of
|
||||
these components is sold alone or is bundled with other
|
||||
services. Note that this does not apply to the use of
|
||||
ZeroTier behind the scenes to operate a service not
|
||||
related to ZeroTier network administration.
|
||||
|
||||
* Create Non-Open-Source Commercial Derivative Works
|
||||
|
||||
(2) Link or directly include the Licensed Work in a
|
||||
commercial or for-profit application or other product
|
||||
not distributed under an Open Source Initiative (OSI)
|
||||
compliant license. See: https://opensource.org/licenses
|
||||
|
||||
(3) Remove the name, logo, copyright, or other branding
|
||||
material from the Licensed Work to create a "rebranded"
|
||||
or "white labeled" version to distribute as part of
|
||||
any commercial or for-profit product or service.
|
||||
|
||||
* Certain Government Uses
|
||||
|
||||
(4) Use or deploy the Licensed Work in a government
|
||||
setting in support of any active government function
|
||||
or operation with the exception of the following:
|
||||
physical or mental health care, family and social
|
||||
services, social welfare, senior care, child care, and
|
||||
the care of persons with disabilities.
|
||||
|
||||
Change Date: 2025-01-01
|
||||
|
||||
Change License: Apache License version 2.0 as published by the Apache
|
||||
Software Foundation
|
||||
https://www.apache.org/licenses/
|
||||
|
||||
Alternative Licensing
|
||||
|
||||
If you would like to use the Licensed Work in any way that conflicts with
|
||||
the stipulations of the Additional Use Grant, contact ZeroTier, Inc. to
|
||||
obtain an alternative commercial license.
|
||||
|
||||
Visit us on the web at: https://www.zerotier.com/
|
||||
|
||||
Notice
|
||||
|
||||
The Business Source License (this document, or the "License") is not an Open
|
||||
Source license. However, the Licensed Work will eventually be made available
|
||||
under an Open Source License, as stated in this License.
|
||||
|
||||
For more information on the use of the Business Source License for ZeroTier
|
||||
products, please visit our pricing page which contains license details and
|
||||
and license FAQ: https://zerotier.com/pricing
|
||||
|
||||
For more information on the use of the Business Source License generally,
|
||||
please visit the Adopting and Developing Business Source License FAQ at
|
||||
https://mariadb.com/bsl-faq-adopting.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Business Source License 1.1
|
||||
|
||||
Terms
|
||||
|
||||
The Licensor hereby grants you the right to copy, modify, create derivative
|
||||
works, redistribute, and make non-production use of the Licensed Work. The
|
||||
Licensor may make an Additional Use Grant, above, permitting limited
|
||||
production use.
|
||||
|
||||
Effective on the Change Date, or the fourth anniversary of the first publicly
|
||||
available distribution of a specific version of the Licensed Work under this
|
||||
License, whichever comes first, the Licensor hereby grants you rights under
|
||||
the terms of the Change License, and the rights granted in the paragraph
|
||||
above terminate.
|
||||
|
||||
If your use of the Licensed Work does not comply with the requirements
|
||||
currently in effect as described in this License, you must purchase a
|
||||
commercial license from the Licensor, its affiliated entities, or authorized
|
||||
resellers, or you must refrain from using the Licensed Work.
|
||||
|
||||
All copies of the original and modified Licensed Work, and derivative works
|
||||
of the Licensed Work, are subject to this License. This License applies
|
||||
separately for each version of the Licensed Work and the Change Date may vary
|
||||
for each version of the Licensed Work released by Licensor.
|
||||
|
||||
You must conspicuously display this License on each original or modified copy
|
||||
of the Licensed Work. If you receive the Licensed Work in original or
|
||||
modified form from a third party, the terms and conditions set forth in this
|
||||
License apply to your use of that work.
|
||||
|
||||
Any use of the Licensed Work in violation of this License will automatically
|
||||
terminate your rights under this License for the current and all other
|
||||
versions of the Licensed Work.
|
||||
|
||||
This License does not grant you any right in any trademark or logo of
|
||||
Licensor or its affiliates (provided that you may use a trademark or logo of
|
||||
Licensor as expressly required by this License).
|
||||
|
||||
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
||||
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
||||
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
||||
TITLE.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
MariaDB hereby grants you permission to use this License’s text to license
|
||||
your works, and to refer to it using the trademark "Business Source License",
|
||||
as long as you comply with the Covenants of Licensor below.
|
||||
|
||||
Covenants of Licensor
|
||||
|
||||
In consideration of the right to use this License’s text and the "Business
|
||||
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
||||
other recipients of the licensed work to be provided by Licensor:
|
||||
|
||||
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
||||
or a license that is compatible with GPL Version 2.0 or a later version,
|
||||
where "compatible" means that software provided under the Change License can
|
||||
be included in a program with software provided under GPL Version 2.0 or a
|
||||
later version. Licensor may specify additional Change Licenses without
|
||||
limitation.
|
||||
|
||||
2. To either: (a) specify an additional grant of rights to use that does not
|
||||
impose any additional restriction on the right granted in this License, as
|
||||
the Additional Use Grant; or (b) insert the text "None".
|
||||
|
||||
3. To specify a Change Date.
|
||||
|
||||
4. Not to modify this License in any other way.
|
108
README.md
108
README.md
|
@ -1,108 +0,0 @@
|
|||
ZeroTier - Global Area Networking
|
||||
======
|
||||
|
||||
ZeroTier is a smart programmable Ethernet switch for planet Earth. It allows all networked devices, VMs, containers, and applications to communicate as if they all reside in the same physical data center or cloud region.
|
||||
|
||||
This is accomplished by combining a cryptographically addressed and secure peer to peer network (termed VL1) with an Ethernet emulation layer somewhat similar to VXLAN (termed VL2). Our VL2 Ethernet virtualization layer includes advanced enterprise SDN features like fine grained access control rules for network micro-segmentation and security monitoring.
|
||||
|
||||
All ZeroTier traffic is encrypted end-to-end using secret keys that only you control. Most traffic flows peer to peer, though we offer free (but slow) relaying for users who cannot establish peer to peer connetions.
|
||||
|
||||
The goals and design principles of ZeroTier are inspired by among other things the original [Google BeyondCorp](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/43231.pdf) paper and the [Jericho Forum](https://en.wikipedia.org/wiki/Jericho_Forum) with its notion of "deperimeterization."
|
||||
|
||||
Visit [ZeroTier's site](https://www.zerotier.com/) for more information and [pre-built binary packages](https://www.zerotier.com/download/). Apps for Android and iOS are available for free in the Google Play and Apple app stores.
|
||||
|
||||
ZeroTier is licensed under the [BSL version 1.1](https://mariadb.com/bsl11/). See [LICENSE.txt](LICENSE.txt) and the [ZeroTier pricing page](https://www.zerotier.com/pricing) for details. ZeroTier is free to use internally in businesses and academic institutions and for non-commercial purposes. Certain types of commercial use such as building closed-source apps and devices based on ZeroTier or offering ZeroTier network controllers and network management as a SaaS service require a commercial license.
|
||||
|
||||
A small amount of third party code is also included in ZeroTier and is not subject to our BSL license. See [AUTHORS.md] for a list of third party code, where it is included, and the licenses that apply to it. All of the third party code in ZeroTier is liberally licensed (MIT, BSD, Apache, public domain, etc.).
|
||||
|
||||
### Getting Started
|
||||
|
||||
Everything in the ZeroTier world is controlled by two types of identifier: 40-bit/10-digit *ZeroTier addresses* and 64-bit/16-digit *network IDs*. These identifiers are easily distinguished by their length. A ZeroTier address identifies a node or "device" (laptop, phone, server, VM, app, etc.) while a network ID identifies a virtual Ethernet network that can be joined by devices.
|
||||
|
||||
ZeroTier addresses can be thought of as port numbers on an enormous planet-wide enterprise Ethernet smart switch supporting VLANs. Network IDs are VLAN IDs to which these ports may be assigned. A single port can be assigned to more than one VLAN.
|
||||
|
||||
A ZeroTier address looks like `8056c2e21c` and a network ID looks like `8056c2e21c000001`. Network IDs are composed of the ZeroTier address of that network's primary controller and an arbitrary 24-bit ID that identifies the network on this controller. Network controllers are roughly analogous to SDN controllers in SDN protocols like [OpenFlow](https://en.wikipedia.org/wiki/OpenFlow), though as with the analogy between VXLAN and VL2 this should not be read to imply that the protocols or design are the same. You can use our convenient and inexpensive SaaS hosted controllers at [my.zerotier.com](https://my.zerotier.com/) or [run your own controller](controller/) if you don't mind messing around with JSON configuration files or writing scripts to do so.
|
||||
|
||||
### Project Layout
|
||||
|
||||
The base path contains the ZeroTier One service main entry point (`one.cpp`), self test code, makefiles, etc.
|
||||
|
||||
- `artwork/`: icons, logos, etc.
|
||||
- `attic/`: old stuff and experimental code that we want to keep around for reference.
|
||||
- `controller/`: the reference network controller implementation, which is built and included by default on desktop and server build targets.
|
||||
- `debian/`: files for building Debian packages on Linux.
|
||||
- `doc/`: manual pages and other documentation.
|
||||
- `ext/`: third party libraries, binaries that we ship for convenience on some platforms (Mac and Windows), and installation support files.
|
||||
- `include/`: include files for the ZeroTier core.
|
||||
- `java/`: a JNI wrapper used with our Android mobile app. (The whole Android app is not open source but may be made so in the future.)
|
||||
- `macui/`: a Macintosh menu-bar app for controlling ZeroTier One, written in Objective C.
|
||||
- `node/`: the ZeroTier virtual Ethernet switch core, which is designed to be entirely separate from the rest of the code and able to be built as a stand-alone OS-independent library. Note to developers: do not use C++11 features in here, since we want this to build on old embedded platforms that lack C++11 support. C++11 can be used elsewhere.
|
||||
- `osdep/`: code to support and integrate with OSes, including platform-specific stuff only built for certain targets.
|
||||
- `rule-compiler/`: JavaScript rules language compiler for defining network-level rules.
|
||||
- `service/`: the ZeroTier One service, which wraps the ZeroTier core and provides VPN-like connectivity to virtual networks for desktops, laptops, servers, VMs, and containers.
|
||||
- `windows/`: Visual Studio solution files, Windows service code, and the Windows task bar app UI.
|
||||
|
||||
### Build and Platform Notes
|
||||
|
||||
To build on Mac and Linux just type `make`. On FreeBSD and OpenBSD `gmake` (GNU make) is required and can be installed from packages or ports. For Windows there is a Visual Studio solution in `windows/'.
|
||||
|
||||
- **Mac**
|
||||
- Xcode command line tools for OSX 10.8 or newer are required.
|
||||
- **Linux**
|
||||
- The minimum compiler versions required are GCC/G++ 4.9.3 or CLANG/CLANG++ 3.4.2. (Install `clang` on CentOS 7 as G++ is too old.)
|
||||
- Linux makefiles automatically detect and prefer clang/clang++ if present as it produces smaller and slightly faster binaries in most cases. You can override by supplying CC and CXX variables on the make command line.
|
||||
- **Windows**
|
||||
- Windows 7 or newer is supported. This *may* work on Vista but isn't officially supported there. It will not work on Windows XP.
|
||||
- We build with Visual Studio 2017. Older versions may not work. Clang or MinGW will also probably work but may require some makefile hacking.
|
||||
- **FreeBSD**
|
||||
- GNU make is required. Type `gmake` to build.
|
||||
- **OpenBSD**
|
||||
- There is a limit of four network memberships on OpenBSD as there are only four tap devices (`/dev/tap0` through `/dev/tap3`).
|
||||
- GNU make is required. Type `gmake` to build.
|
||||
|
||||
Typing `make selftest` will build a *zerotier-selftest* binary which unit tests various internals and reports on a few aspects of the build environment. It's a good idea to try this on novel platforms or architectures.
|
||||
|
||||
### Running
|
||||
|
||||
Running *zerotier-one* with -h will show help.
|
||||
|
||||
On Linux and BSD you can start the service with:
|
||||
|
||||
sudo ./zerotier-one -d
|
||||
|
||||
A home folder for your system will automatically be created.
|
||||
|
||||
The service is controlled via the JSON API, which by default is available at 127.0.0.1 port 9993. We include a *zerotier-cli* command line utility to make API calls for standard things like joining and leaving networks. The *authtoken.secret* file in the home folder contains the secret token for accessing this API. See README.md in [service/](service/) for API documentation.
|
||||
|
||||
Here's where home folders live (by default) on each OS:
|
||||
|
||||
* **Linux**: `/var/lib/zerotier-one`
|
||||
* **FreeBSD** / **OpenBSD**: `/var/db/zerotier-one`
|
||||
* **Mac**: `/Library/Application Support/ZeroTier/One`
|
||||
* **Windows**: `\ProgramData\ZeroTier\One` (That's for Windows 7. The base 'shared app data' folder might be different on different Windows versions.)
|
||||
|
||||
Running ZeroTier One on a Mac is the same, but OSX requires a kernel extension. We ship a signed binary build of the ZeroTier tap device driver, which can be installed on Mac with:
|
||||
|
||||
sudo make install-mac-tap
|
||||
|
||||
This will create the home folder for Mac, place *tap.kext* there, and set its modes correctly to enable ZeroTier One to manage it with *kextload* and *kextunload*.
|
||||
|
||||
### Basic Troubleshooting
|
||||
|
||||
For most users, it just works.
|
||||
|
||||
If you are running a local system firewall, we recommend adding a rule permitting UDP port 9993 inbound and outbound. If you installed binaries for Windows this should be done automatically. Other platforms might require manual editing of local firewall rules depending on your configuration.
|
||||
|
||||
The Mac firewall can be found under "Security" in System Preferences. Linux has a variety of firewall configuration systems and tools. If you're using Ubuntu's *ufw*, you can do this:
|
||||
|
||||
sudo ufw allow 9993/udp
|
||||
|
||||
On CentOS check `/etc/sysconfig/iptables` for IPTables rules. For other distributions consult your distribution's documentation. You'll also have to check the UIs or documentation for commercial third party firewall applications like Little Snitch (Mac), McAfee Firewall Enterprise (Windows), etc. if you are running any of those. Some corporate environments might have centrally managed firewall software, so you might also have to contact IT.
|
||||
|
||||
ZeroTier One peers will automatically locate each other and communicate directly over a local wired LAN *if UDP port 9993 inbound is open*. If that port is filtered, they won't be able to see each others' LAN announcement packets. If you're experiencing poor performance between devices on the same physical network, check their firewall settings. Without LAN auto-location peers must attempt "loopback" NAT traversal, which sometimes fails and in any case requires that every packet traverse your external router twice.
|
||||
|
||||
Users behind certain types of firewalls and "symmetric" NAT devices may not able able to connect to external peers directly at all. ZeroTier has limited support for port prediction and will *attempt* to traverse symmetric NATs, but this doesn't always work. If P2P connectivity fails you'll be bouncing UDP packets off our relay servers resulting in slower performance. Some NAT router(s) have a configurable NAT mode, and setting this to "full cone" will eliminate this problem. If you do this you may also see a magical improvement for things like VoIP phones, Skype, BitTorrent, WebRTC, certain games, etc., since all of these use NAT traversal techniques similar to ours.
|
||||
|
||||
If a firewall between you and the Internet blocks ZeroTier's UDP traffic, you will fall back to last-resort TCP tunneling to rootservers over port 443 (https impersonation). This will work almost anywhere but is *very slow* compared to UDP or direct peer to peer connectivity.
|
||||
|
||||
Additional help [can be found in our knowledge base](https://zerotier.atlassian.net/wiki/spaces/SD/overview).
|
270
RELEASE-NOTES.md
270
RELEASE-NOTES.md
|
@ -1,270 +0,0 @@
|
|||
ZeroTier Release Notes
|
||||
======
|
||||
|
||||
# Version 1.9.0 (2.0 beta)
|
||||
|
||||
Version 2.0 is a very significant release with many changes. It remains backward compatibility to version 1.4.0 (and possibly earlier versions but this is not guaranteed) but makes numerous local and behavioral changes that should be reviewed before upgrading production systems.
|
||||
|
||||
After this release we're going to be working to get to a more frequent, less extreme, more "agile" release cadence.
|
||||
|
||||
Protocol changes:
|
||||
|
||||
* Trusted paths have been completely removed. The new AES mode is so fast on CPUs with AES acceleration that much of the rationale for this is gone, and this feature was never used much to begin with due to inconvenience and obvious security concerns. Environments using trusted paths will need to upgrade all nodes at once.
|
||||
* The symmetric encryption algorithm and mode is now AES-GMAC-SIV, a variation of AES-GCM using the same primitives but offering superior security bounds and behavior under non-ideal conditions. It's also a lot faster than Salsa20/12 and Poly1305 on CPUs with AES acceleration (almost all desktops, laptops, and newer routers and phones). Salsa20/12 with Poly1305 is still supported for communication with older versions and small devices that lack AES acceleration.
|
||||
* A new identity type (1) has been introduced that contains both Curve25519 and NIST P-384 public key types, but classic type 0 remains the default for new identities for now. ECDH key agreement between V1 identities uses both keys and hashes the resulting secrets to yield security equal to the best of the two, but V1 identities can also agree with V0 identities using only their Curve25519 component.
|
||||
* Roots can now be joined and left like networks in a much more convenient way, and the old "moon" and "planet" terminology is deprecated.
|
||||
* A new peer to peer multicast algorithm has been introduced that offers much better scalability and better performance, especially when the physical network itself is hub-and-spoke with many low latency peers connected by higher latency WAN links.
|
||||
* Forward secrecy is finally supported via periodic re-keying using ephemeral asymmetric keys. Both Curve25519 and NIST P-384 keys are used with secrets being hashed to provide security equal to the stronger of the two curves.
|
||||
* As part of forward secrecy implementation peers now always exchange HELLO messages even if they don't have a direct path.
|
||||
* Compression is only enabled for control packets as almost all data packets are largely un-compressable.
|
||||
* New NAT traversal tricks have been added, such as (ab)use of port 500.
|
||||
|
||||
Code changes:
|
||||
|
||||
* Migrated from GNU make to cmake for easier cross platform builds and simplified build files.
|
||||
* The core network hypervisor has been significantly refactored, almost amounting to a partial rewrite.
|
||||
* Critical packet handling paths have been streamlined with unnecessary memcpy() steps removed.
|
||||
* Host service code has been completely rewritten in Go. Packet handling code remains in C++, but Go offers superior developer productivity when it comes to implementing more complex local service and local API features. Go imposes a little bit more memory overhead but not much and has been tuned to minimize memory use.
|
||||
|
||||
User interface:
|
||||
|
||||
* Command line interface has been redesigned and rewritten. Old commands names are supported but their output will be different.
|
||||
|
||||
Other things:
|
||||
|
||||
* The V2 design, protocol, and cryptographic primitives (AES-GMAC-SIV) have been security audited by [Trail of Bits](https://www.trailofbits.com), and the code is being audited as well prior to full 2.0 release.
|
||||
|
||||
---
|
||||
|
||||
# Older version release notes
|
||||
|
||||
# 2019-08-30 -- Version 1.4.6
|
||||
|
||||
* Update default root list to latest
|
||||
* ARM32 platform build and flag fixes
|
||||
* Add a clarification line to LICENSE.txt
|
||||
* Fix license message in CLI
|
||||
* Windows service now looks for service command line arguments
|
||||
* Fixed a bug that could cause excessive queued multicasts
|
||||
|
||||
# 2019-08-23 -- Version 1.4.4
|
||||
|
||||
* Change license from GPL3 to BSL 1.1, see LICENSE.txt
|
||||
* Fix an issue with the "ipauth" rule and auto-generated unforgeable IPv6 addresses
|
||||
* Fix socket/bind errors setting IPs and routes on Linux
|
||||
|
||||
# 2019-08-12 -- Version 1.4.2
|
||||
|
||||
* Fix high CPU use bug on some platforms
|
||||
* Fix issues with PostgreSQL controller DB (only affects Central)
|
||||
* Restore backward compatibility with MacOS versions prior to 10.13
|
||||
|
||||
# 2019-07-29 -- Version 1.4.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
* Mac version no longer requires a kernel extension, instead making use of the [feth interfaces](https://apple.stackexchange.com/questions/337715/fake-ethernet-interfaces-feth-if-fake-anyone-ever-seen-this).
|
||||
* Added support for concurrent multipath (multiple paths at once) with traffic weighting by link quality and faster recovery from lost links.
|
||||
* Added under-the-hood support for QoS (not yet exposed) that will eventually be configurable via our rules engine.
|
||||
|
||||
### Minor Changes and Bug Fixes
|
||||
|
||||
* Experimental controller DB driver for [LF](https://github.com/zerotier/lf) to store network controller data (LFDB.cpp / LFDB.hpp).
|
||||
* Modified credential push and direct path push timings and algorithms to somewhat reduce "chattiness" of the protocol when idle. More radical background overhead reductions will have to wait for the 2.x line.
|
||||
* Removed our beta/half-baked integration of Central with the Windows UI. We're going to do a whole new UI of some kind in the future at least for Windows and Mac.
|
||||
* Fixed stack overflow issues on Linux versions using musl libc.
|
||||
* Fixed some alignment problems reported on ARM and ARM64, but some reports we could not reproduce so please report any issues with exact chip, OS/distro, and ZeroTier version in use.
|
||||
* Fixed numerous other small issues and bugs such as ARM alignment issues causing crashes on some devices.
|
||||
* Windows now sets the adapter name such that it is consistent in both the Windows UI and command line utilities.
|
||||
|
||||
# 2018-07-27 -- Version 1.2.12
|
||||
|
||||
* Fixed a bug that caused exits to take a long time on Mac due to huge numbers of redundant attempts to delete managed routes.
|
||||
* Fixed a socket limit problem on Windows that caused the ZeroTier service to run out of sockets, causing the UI and CLI to be unable to access the API.
|
||||
* Fixed a threading bug in the ZeroTier Core, albeit one that never manifested on the regular ZeroTier One service/client.
|
||||
* Fixed a bug that could cause the service to crash if an authorized local client accessed an invalid URL via the control API. (Not exploitable since you needed admin access anyway.)
|
||||
|
||||
# 2018-05-08 -- Version 1.2.10
|
||||
|
||||
* Fix bug loading `moons.d/` files for federated root operation.
|
||||
* Fix compile problem with ZT_DEBUG on some versions of `clang`
|
||||
* Fix slow network startup bug related to loading of `networks.d/` cache files
|
||||
|
||||
# 2018-04-27 -- Version 1.2.8
|
||||
|
||||
* Linux version once again builds with PIE (position independent executable) flags
|
||||
* Fixed bug in zerotier-idtool file sign and verify
|
||||
* Fixed minor OSX app typo
|
||||
* Merged alpha NetBSD support (mostly untested, so YMMV)
|
||||
* Merged several minor typo and one-liner bug fixes
|
||||
|
||||
# 2018-04-17 -- Version 1.2.6
|
||||
|
||||
* Features and Core Improvements
|
||||
* Path selection has been overhauled to improve path stability, simplify code, and prepare for multi-path and trunking in the next major release.
|
||||
* This version introduces remote tracing for remote diagnostics. Network controllers can set a node (usually the controller itself) to receive remote tracing events from all members of the network or from select members. Events are only sent if they pertain to a given network for security reasons.
|
||||
* Multicast replication can now be done by designated multicast replicators on a network (flagged as such at the controller) rather than by the sender. Most users won't want this, but it's useful for specialized use cases on hub-and-spoke networks and for low-power devices.
|
||||
* Cryptographic performance improvements on several platforms.
|
||||
* Multithreaded performance improvements throughout the code base, including the use of an inline lightweight spinlock for low-contention resources.
|
||||
* Bugs fixed
|
||||
* Disappearing routes on Mac (GitHub issue #600)
|
||||
* Route flapping and path instability in some dual-stack V4/V6 networks
|
||||
* Blacklist (in local.conf) doesn't work reliably (GitHub issue #656)
|
||||
* Connection instabilities due to unsigned integer overflows in timing comparisons (use int64_t instead of uint64_t)
|
||||
* Binaries don't run on some older or lower-end 32-bit ARM chips (build problem)
|
||||
* ARM NEON crypto code crashes (build problem)
|
||||
* Fixed some lock ordering issues revealed by "valgrind" tool
|
||||
* The "zerotier-idtool" command could not be accessed from "zerotier-one" via command line switch
|
||||
* Leaking sockets on some platforms when uPnP/NAT-PMP is enabled
|
||||
* Fixed two very rare multithreading issues that were only observed on certain systems
|
||||
* Platform-Specific Changes
|
||||
* MacOS
|
||||
* Installer now loads the kernel extension right away so that High Sierra users will see the prompt to authorize it. This is done in the "Security & Privacy" preference pane and must be done directly on the console (not via remote desktop). On High Sierra and newer kexts must be authorized at the console via security settings system preferences pane.
|
||||
* Windows
|
||||
* The Windows installer should now install the driver without requiring a special prompt in most cases. This should make it easier for our packages to be accepted into and updated in the Chocolatey repository and should make it easier to perform remote installs across groups of machines using IT management and provisioning tools.
|
||||
* The Windows official packages are now signed with an EV certificate (with hardware key).
|
||||
* The Windows UI can now log into ZeroTier Central and join networks via the Central API.
|
||||
* The `zerotier-idtool` command should now work on Windows without ugly hacks.
|
||||
* Upgraded the installer version.
|
||||
* Made a few changes to hopefully fix sporadic "will not uninstall" problems, though we cannot duplicate these issues ourselves.
|
||||
* Linux
|
||||
* Device names are now generated deterministically based on network IDs for all newly joined networks.
|
||||
* Android
|
||||
* Multicast now works on Android in most cases! Android apps can send and receive multicast and subscribe to multicast group IPs. Note that in some cases the app must bind to the specific correct interface for this to work.
|
||||
* IPv6 can be disabled in UI for cases where it causes problems.
|
||||
|
||||
# 2017-04-20 -- Version 1.2.4
|
||||
|
||||
* Managed routes are now only bifurcated for the default route. This is a change in behavior, though few people will probably notice. Bifurcating all managed routes was causing more trouble than it was worth for most users.
|
||||
* Up to 2X crypto speedup on x86-64 (except Windows, which will take some porting) and 32-bit ARM platforms due to integration of fast assembly language implementations of Salsa20/12 from the [supercop](http://bench.cr.yp.to/supercop.html) code base. These were written by Daniel J. Bernstein and are in the public domain. My Macbook Pro (Core i5 2.8ghz) now does almost 1.5GiB/sec Salsa20/12 per core and a Raspberry Pi got a 2X boost. 64-bit ARM support and Windows support will take some work but should not be too hard.
|
||||
* Refactored code that manages credentials to greatly reduce memory use in most cases. This may also result in a small performance improvement.
|
||||
* Reworked and simplified path selection and priority logic to fix path instability and dead path persistence edge cases. There have been some sporadic reports of persistent path instabilities and dead paths hanging around that take minutes to resolve. These have proven difficult to reproduce in house, but hopefully this will fix them. In any case it seems to speed up path establishment in our tests and it makes the code simpler and more readable.
|
||||
* Eliminated some unused cruft from the code around path management and in the peer class.
|
||||
* Fixed an issue causing build problems on some MIPS architecture systems.
|
||||
* Fixed Windows forgetting routes on sleep/wake or in some other circumstances. (GitHub issue #465)
|
||||
|
||||
# 2017-03-17 -- Version 1.2.2
|
||||
|
||||
* A bug causing unreliable multicast propagation (GitHub issue #461).
|
||||
* A crash in ARM binaries due to a build chain and flags problem.
|
||||
* A bug in the network controller preventing members from being listed (GitHub issue #460).
|
||||
|
||||
# 2017-03-14 -- Version 1.2.0
|
||||
|
||||
Version 1.2.0 is a major milestone release representing almost nine months of work. It includes our rules engine for distributed network packet filtering and security monitoring, federated roots, and many other architectural and UI improvements and bug fixes.
|
||||
|
||||
## New 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. Security observation can be performed in-band using REDIRECT or out of band using TEE.
|
||||
|
||||
Tags and capabilities provide advanced methods for implementing fine grained permission structures and micro-segmentation schemes without bloating the size and complexity of your rules table.
|
||||
|
||||
See the [rules engine announcement blog post](https://www.zerotier.com/blog/?p=927) for an in-depth discussion of theory and implementation. The [manual](https://www.zerotier.com/manual.shtml) contains detailed information on rule, tag, and capability use, and the `rule-compiler/` subfolder of the ZeroTier source tree contains a JavaScript function to compile rules in our human-readable rule definition language into rules suitable for import into a network controller. (ZeroTier Central uses this same script to compile rules on [my.zerotier.com](https://my.zerotier.com/).)
|
||||
|
||||
### 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](https://www.zerotier.com/manual.shtml) for instructions.
|
||||
|
||||
Federated roots achieve a number of things:
|
||||
|
||||
* You can deploy your own infrastructure to reduce dependency on ours.
|
||||
* You can deploy roots *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).
|
||||
|
||||
Software updates are authenticated three ways:
|
||||
|
||||
1. ZeroTier's own signing key is used to sign all updates and this signature is checked prior to installation. ZeroTier, Inc.'s signatures are performed on an air-gapped machine.
|
||||
|
||||
2. Updates for Mac and Windows are signed using Apple and Microsoft (DigiCert EV) keys and will not install unless these signatures are also valid.
|
||||
|
||||
3. The new in-band update mechanism also authenticates the source of the update via ZeroTier's built-in security features. This provides transport security, while 1 and 2 provide security of the update at rest.
|
||||
|
||||
Updates are now configurable via `local.conf`. There are three options: `disable`, `download`, and `apply`. The third (apply) 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. Updates are disabled by default on Linux and other Unix-type systems as these are typically updated through package managers.
|
||||
|
||||
### Path Link Quality Awareness
|
||||
|
||||
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.) Quality is measured passively with no additional overhead using a counter based packet loss detection algorithm.
|
||||
|
||||
This information is visible from the command line via `listpeers`:
|
||||
|
||||
200 listpeers XXXXXXXXXX 199.XXX.XXX.XXX/9993;10574;15250;1.00 48 1.2.0 LEAF
|
||||
200 listpeers XXXXXXXXXX 195.XXX.XXX.XXX/45584;467;7608;0.44 290 1.2.0 LEAF
|
||||
|
||||
The first peer's path is at 100% (1.00), while the second peer's path is suffering quite a bit of packet loss (0.44).
|
||||
|
||||
Link quality awareness 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.
|
||||
|
||||
### 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.
|
||||
|
||||
### Ad-Hoc Networks
|
||||
|
||||
A special kind of public network called an ad-hoc network may be accessed by joining a network ID with the format:
|
||||
|
||||
ffSSSSEEEE000000
|
||||
| | | |
|
||||
| | | Reserved for future use, must be 0
|
||||
| | End of port range (hex)
|
||||
| Start of port range (hex)
|
||||
Reserved ZeroTier address prefix indicating a controller-less network
|
||||
|
||||
Ad-hoc networks are public (no access control) networks that have no network controller. Instead their configuration and other credentials are generated locally. Ad-hoc networks permit only IPv6 UDP and TCP unicast traffic (no multicast or broadcast) using 6plane format NDP-emulated IPv6 addresses. In addition an ad-hoc network ID encodes an IP port range. UDP packets and TCP SYN (connection open) packets are only allowed to destination ports within the encoded range.
|
||||
|
||||
For example `ff00160016000000` is an ad-hoc network allowing only SSH, while `ff0000ffff000000` is an ad-hoc network allowing any UDP or TCP port.
|
||||
|
||||
Keep in mind that these networks are public and anyone in the entire world can join them. Care must be taken to avoid exposing vulnerable services or sharing unwanted files or other resources.
|
||||
|
||||
### Network Controller (Partial) Rewrite
|
||||
|
||||
The network controller has been largely rewritten to use a simple in-filesystem JSON data store in place of SQLite, and it is now included by default in all Windows, Mac, Linux, and BSD builds. This means any desktop or server node running ZeroTier One can now be a controller with no recompilation needed.
|
||||
|
||||
If you have data in an old SQLite3 controller we've included a NodeJS script in `controller/migrate-sqlite` to migrate data to the new format. If you don't migrate, members will start getting `NOT_FOUND` when they attempt to query for updates.
|
||||
|
||||
## Major Bug Fixes in 1.2.0
|
||||
|
||||
* **The Windows HyperV 100% CPU bug is FINALLY DEAD**: 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.
|
||||
* **Segmentation 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.
|
||||
|
||||
## Other Improvements in 1.2.0
|
||||
|
||||
* **Improved dead path detection**: ZeroTier is now more aggressive about expiring paths that do not seem to be active. If a path seems marginal it is re-confirmed before re-use.
|
||||
* **Minor performance improvements**: We've reduced unnecessary memcpy's and made a few other performance improvements in the core.
|
||||
* **Linux static binaries**: For our official packages (the ones in the download.zerotier.com apt and yum repositories) we now build Linux binaries with static linking. Hopefully this will stop all the bug reports relating to library inconsistencies, as well as allowing our deb packages to run on a wider variety of Debian-based distributions. (There are far too many of these to support officially!) The overhead for this is very small, especially since we built our static versions against musl-libc. Distribution maintainers are of course free to build dynamically linked versions for inclusion into distributions; this only affects our official binaries.
|
|
@ -107,3 +107,6 @@ pub const WHOIS_RETRY_INTERVAL: i64 = 1000;
|
|||
|
||||
/// Maximum number of WHOIS retries
|
||||
pub const WHOIS_RETRY_MAX: u16 = 3;
|
||||
|
||||
/// Maximum number of endpoints allowed in a Locator.
|
||||
pub const LOCATOR_MAX_ENDPOINTS: usize = 32;
|
||||
|
|
|
@ -42,7 +42,7 @@ pub enum Endpoint {
|
|||
IpUdp(InetAddress),
|
||||
IpTcp(InetAddress),
|
||||
Http(String),
|
||||
WebRTC(String),
|
||||
WebRTC(Vec<u8>),
|
||||
}
|
||||
|
||||
impl Default for Endpoint {
|
||||
|
@ -122,7 +122,7 @@ impl Endpoint {
|
|||
}
|
||||
Endpoint::WebRTC(offer) => {
|
||||
buf.append_u8(16 + (Type::WebRTC as u8))?;
|
||||
let b = offer.as_bytes();
|
||||
let b = offer.as_slice();
|
||||
buf.append_u16(b.len() as u16)?;
|
||||
buf.append_bytes(b)
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ impl Endpoint {
|
|||
}
|
||||
TYPE_WEBRTC => {
|
||||
let l = buf.read_u16(cursor)?;
|
||||
Ok(Endpoint::WebRTC(String::from_utf8_lossy(buf.read_bytes(l as usize, cursor)?).to_string()))
|
||||
Ok(Endpoint::WebRTC(buf.read_bytes(l as usize, cursor)?.to_vec()))
|
||||
}
|
||||
_ => std::io::Result::Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "unrecognized endpoint type in stream"))
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ impl PartialOrd for Endpoint {
|
|||
|
||||
impl Ord for Endpoint {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
// This ordering is done explicitly instead of using derive() so it will be certain
|
||||
// This ordering is done explicitly instead of using derive(Ord) so it will be certain
|
||||
// to be consistent with the integer order in the Type enum. Make sure it stays this
|
||||
// way if new types are added in future revisions.
|
||||
match self {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
use crate::vl1::{Endpoint, Address, Identity};
|
||||
use std::cmp::Ordering;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
use crate::vl1::{Address, Endpoint, Identity};
|
||||
use crate::vl1::buffer::Buffer;
|
||||
use crate::vl1::constants::{LOCATOR_MAX_ENDPOINTS, PACKET_SIZE_MAX};
|
||||
|
||||
/// A signed object generated by nodes to inform the network where they may be found.
|
||||
///
|
||||
/// By default this will just enumerate the roots used by this node, but nodes with
|
||||
|
@ -8,6 +12,7 @@ use std::hash::{Hash, Hasher};
|
|||
/// no involvement from a root at all.
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Locator {
|
||||
pub(crate) subject: Address,
|
||||
pub(crate) signer: Address,
|
||||
pub(crate) timestamp: i64,
|
||||
pub(crate) endpoints: Vec<Endpoint>,
|
||||
|
@ -15,16 +20,135 @@ pub struct Locator {
|
|||
}
|
||||
|
||||
impl Locator {
|
||||
pub fn create(id: &Identity, ts: i64, endpoints: &[Endpoint]) -> Option<Locator> {
|
||||
/// Create and sign a new locator.
|
||||
///
|
||||
/// If a node is creating its own locator the subject will be the address from the
|
||||
/// signer identity. Proxy signing is when these do not match and is only done by
|
||||
/// roots to create locators for old versions of ZeroTier that do not create their
|
||||
/// own. Proxy locators are always superseded by self-signed locators.
|
||||
///
|
||||
/// This returns None if an error occurs, which can only be something indicating a
|
||||
/// bug like too many endpoints or the identity lacking its secret keys.
|
||||
pub fn create(signer_identity: &Identity, subject: Address, ts: i64, endpoints: &[Endpoint]) -> Option<Locator> {
|
||||
if endpoints.len() > LOCATOR_MAX_ENDPOINTS {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut loc = Locator {
|
||||
signer: id.address(),
|
||||
subject,
|
||||
signer: signer_identity.address(),
|
||||
timestamp: ts,
|
||||
endpoints: endpoints.to_vec(),
|
||||
signature: Vec::new()
|
||||
};
|
||||
loc.endpoints.sort_unstable();
|
||||
loc.endpoints.dedup();
|
||||
Some(loc)
|
||||
|
||||
let mut buf: Buffer<{ PACKET_SIZE_MAX }> = Buffer::new();
|
||||
if loc.marshal_internal(&mut buf, true).is_err() {
|
||||
return None;
|
||||
}
|
||||
signer_identity.sign(buf.as_bytes()).map(|sig| {
|
||||
loc.signature = sig;
|
||||
loc
|
||||
})
|
||||
}
|
||||
|
||||
/// Check if this locator should replace one that is already known.
|
||||
pub fn should_replace(&self, other: &Self) -> bool {
|
||||
if self.subject == self.signer && other.subject != other.signer {
|
||||
true
|
||||
} else if self.subject != self.signer && other.subject == other.signer {
|
||||
false
|
||||
} else {
|
||||
self.timestamp > other.timestamp
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn subject(&self) -> Address {
|
||||
self.subject
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn signer(&self) -> Address {
|
||||
self.signer
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn is_proxy_signed(&self) -> bool {
|
||||
self.subject != self.signer
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn timestamp(&self) -> i64 {
|
||||
self.timestamp
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn endpoints(&self) -> &[Endpoint] {
|
||||
self.endpoints.as_slice()
|
||||
}
|
||||
|
||||
pub fn verify_signature(&self, signer_identity: &Identity) -> bool {
|
||||
let mut buf: Buffer<{ PACKET_SIZE_MAX }> = Buffer::new();
|
||||
if self.marshal_internal(&mut buf, true).is_ok() {
|
||||
if signer_identity.address() == self.signer {
|
||||
signer_identity.verify(buf.as_bytes(), self.signature.as_slice())
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn marshal_internal<const BL: usize>(&self, buf: &mut Buffer<BL>, exclude_signature: bool) -> std::io::Result<()> {
|
||||
buf.append_u64(self.subject.to_u64())?;
|
||||
buf.append_u64(self.signer.to_u64())?;
|
||||
buf.append_u64(self.timestamp as u64)?;
|
||||
debug_assert!(self.endpoints.len() < 65536);
|
||||
buf.append_u16(self.endpoints.len() as u16)?;
|
||||
for e in self.endpoints.iter() {
|
||||
e.marshal(buf)?;
|
||||
}
|
||||
buf.append_u16(0)?;
|
||||
if !exclude_signature {
|
||||
debug_assert!(self.signature.len() < 65536);
|
||||
buf.append_u16(self.signature.len() as u16)?;
|
||||
buf.append_bytes(self.signature.as_slice())?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn marshal<const BL: usize>(&self, buf: &mut Buffer<BL>) -> std::io::Result<()> {
|
||||
marshal_internal(buf, false)
|
||||
}
|
||||
|
||||
pub fn unmarshal<const BL: usize>(buf: &Buffer<BL>, cursor: &mut usize) -> std::io::Result<Self> {
|
||||
let subject = Address::from(buf.read_u64(cursor)?);
|
||||
let signer = Address::from(buf.read_u64(cursor)?);
|
||||
let timestamp = buf.read_u64(cursor)? as i64;
|
||||
let endpoint_count = buf.read_u16(cursor)? as usize;
|
||||
if endpoint_count > LOCATOR_MAX_ENDPOINTS {
|
||||
return Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "too many endpoints"));
|
||||
}
|
||||
let mut endpoints: Vec<Endpoint> = Vec::new();
|
||||
endpoints.reserve(endpoint_count);
|
||||
for _ in 0..endpoint_count {
|
||||
endpoints.push(Endpoint::unmarshal(buf, cursor)?);
|
||||
}
|
||||
*cursor += buf.read_u16(cursor)? as usize;
|
||||
let signature_len = buf.read_u16(cursor)? as usize;
|
||||
let signature = buf.read_bytes(signature_len, cursor)?;
|
||||
Ok(Locator {
|
||||
subject,
|
||||
signer,
|
||||
timestamp,
|
||||
endpoints,
|
||||
signature: signature.to_vec(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue