zhangmeng
2024-04-22 16935f4aebffdd1b6580b844391a0aa0f4f3012b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ifdef::env-github[]
:important-caption: :heavy_exclamation_mark:
endif::[]
 
= Building for ZeroTier Support
 
If you want to include support for the experimental ZeroTier
transport (`zt://` URLs), you should follow these directions.
 
Staysail has created a package that builds a clean CMake project
that you can import.
Download this from https://github.com/staysail/libzerotiercore[GitHub].
 
 
IMPORTANT: ZeroTierOne is licensed under different terms than NNG.
You are responsible for reading those license terms, and ensuring that
your use conforms to them.
 
IMPORTANT: The ZeroTier transport, and these build instructions,
are experimental.
We expect both to change over time as ZeroTier and the NNG `zt://` transport
both mature.
As always, _caveat emptor_.
 
== Building libzerotiercore
 
Using "CMake", you can build libzerotiercore
using any normal CMake generator.
You should install it as well.
Normally it will install into `/usr/local` on
Linux and UNIX systems.
 
== Configuring NNG with ZT
 
You will need to enable ZeroTier within NNG using the CMake option `NNG_TRANSPORT_ZEROTIER=ON`.
If you have installed the libzerotiercore in
one of the default locations, then that should be all
that is needed.
 
If you have specified a different location, you will
need to inform CMake of this by setting the CMake
variable `-Dzerotier_DIR=<where you installed it>`
 
== Example
 
The following example would work on either Linux or macOS, and assumes
that we have checked out github source trees into `$HOME/work`.
 
[source, sh]
----
$ export NNGDIR=$HOME/work/nng
$ export ZTDIR=$HOME/work/libzerotiercore
$ git clone https://github.com/staysail/libzerotiercore $ZTDIR
$ cd $ZTDIR
$ mkdir build
$ cd build
$ cmake ..
 
   ... (lots of lines of output from cmake...)
 
$ make
 
   ... (lots of lines of output from make...)
 
$ make install
$ cd $NNGDIR
$ mkdir build
$ cd build
$ cmake -DNNG_TRANSPORT_ZEROTIER=ON ..
 
   ... (lots of lines of output from cmake...)
 
$ make
 
   ... (lots of lines of output from make...)
 
$ ./tests/zt
 
ok      ./tests/zt                                            22.837s
----