Compare commits

...

3322 Commits
1.0.4 ... root

Author SHA1 Message Date
b849e23536 Moved zerotier-root code to its own repo 2025-01-07 11:06:42 -08:00
0ab4e2f750 Roots now understand encrypted HELLO. 2024-09-26 19:47:57 -04:00
2316a45a45 clang-format root 2024-09-26 13:41:59 -04:00
0a6c22a9b8 . 2024-08-14 08:10:44 -04:00
8adf064a04 Yet another fix. 2021-09-21 12:36:00 -04:00
7fe00f4247 Another dumb RENDEZVOUS bug. 2021-09-21 12:13:47 -04:00
5eae02068d Fix bass ackwards addresses making RENDEZVOUS packets not make it, improve P2P. 2021-09-21 11:58:39 -04:00
5d429cedbb Send error. 2021-09-20 16:56:16 -04:00
3c85322067 Meh... fixed now. 2021-09-20 15:54:12 -04:00
9fb902bdf6 Pointer deref fix. 2021-09-20 15:43:27 -04:00
262cb7a4b5 Generate new peer if old was bad. 2021-09-20 15:12:56 -04:00
104fade420 Thinko. 2021-09-20 15:04:25 -04:00
bcf8c30ce0 Simplify validation logic too. 2021-09-20 14:56:49 -04:00
c2413fca4d Clean out a bunch of old code related to the possibility of multiple peers sharing virtual addresses. Does not seem to be currently exploitable but we are never going back to that idea, so this simplifies things. May also speed up the root. 2021-09-20 14:42:49 -04:00
5028aca372 Fix some identity verification stuff, performance improvements, build of root now requires libjemalloc. 2021-06-18 16:14:59 -04:00
311f9c5c2a A few minor changes: (1) bind sockets to peers so the same socket is always used to send as most recently received, (2) pick the most recently active IP (v4 or v6) if both exist, and (3) introduce expiry of V4 or V6 IPs in addition to the peer overall. 2021-05-26 19:37:48 -04:00
32ca1a09da Set version threshold correctly for v2 2020-08-27 10:00:11 -07:00
bba1324145 One more sanity check. 2020-01-21 11:04:18 -08:00
ff655292fb Allocate packet on heap, add extra sanity checks on packet size. 2020-01-21 10:58:41 -08:00
2558bd1b9b include iomanip 2020-01-16 09:11:12 -08:00
95d0944b9f add /metrics endpoint for exposing root metrics to Prometheus 2020-01-16 09:08:52 -08:00
68ac884d47 . 2019-10-02 14:30:46 -07:00
e2f3996843 Fix callbacks 2019-10-02 13:39:48 -07:00
57ade250af . 2019-10-02 12:19:37 -07:00
c3e0f262d1 Regularize JSON stuff 2019-10-02 09:34:44 -07:00
b9911d0db7 More plumbing 2019-10-02 07:09:54 -07:00
d1b780c7be addroot 2019-10-01 13:09:53 -07:00
1711cced3e . 2019-09-30 20:31:48 -07:00
63e6693255 . 2019-09-30 20:10:53 -07:00
9b8d191bb1 Locator fix 2019-09-30 20:09:35 -07:00
6db2b8c66d . 2019-09-30 20:03:03 -07:00
47a08ccbd4 Identity management plumbing to Go 2019-09-30 18:59:57 -07:00
7fc78129f4 A bunch of CLI work 2019-09-30 16:12:08 -07:00
c4504fd3ff Vendor Go modules 2019-09-30 12:41:21 -07:00
e4799ff8c4 Bunch of small warnings and stylistic things... 2019-09-30 11:10:47 -07:00
f680924585 Build fixes 2019-09-30 09:48:44 -07:00
b0d222768a Root admin stuff 2019-09-30 09:32:00 -07:00
4303c43db7 . 2019-09-27 14:55:46 -07:00
3b3e6d2bfc Simplify root API 2019-09-26 13:35:56 -07:00
7061f13b24 . 2019-09-26 09:34:31 -07:00
5175636d36 . 2019-09-25 14:31:08 -07:00
570032484f . 2019-09-25 14:16:55 -07:00
9c37fc1a5f . 2019-09-25 13:32:46 -07:00
105023bd87 Build fix 2019-09-25 12:43:14 -07:00
8a9669f130 . 2019-09-25 12:36:49 -07:00
e5bd230fb0 . 2019-09-24 16:44:29 -07:00
e3d47e588a . 2019-09-24 12:32:35 -07:00
f4a5abeed9 Go CLI work 2019-09-24 12:19:28 -07:00
a7e38d2b00 . 2019-09-23 16:58:55 -07:00
84ba396ed3 . 2019-09-23 16:47:13 -07:00
6683280a37 . 2019-09-23 16:46:58 -07:00
1edf680464 . 2019-09-23 16:46:31 -07:00
4df090469a Clean out obsolete dependencies. 2019-09-23 16:42:23 -07:00
3c63f58532 Build fix. 2019-09-23 16:21:43 -07:00
64c8171e13 Port binding check. 2019-09-23 16:21:02 -07:00
b6175bd408 Gogogogogogogo 2019-09-23 15:18:52 -07:00
b44bd19c53 . 2019-09-22 22:33:11 -07:00
536bc59abb . 2019-09-22 22:25:55 -07:00
70d5da1e2a . 2019-09-22 19:25:40 -07:00
90d4d79828 Peers and paths 2019-09-22 17:41:15 -07:00
ccc9be2d4d All that cgo crap compiles! 2019-09-22 00:06:07 -07:00
3341c4a670 Rooting around 2019-09-21 22:54:58 -07:00
bcb9df9cdf Network config stuff in Go 2019-09-21 20:40:06 -07:00
2eef9d22e6 getting there... 2019-09-21 18:22:25 -07:00
5e35346f17 Gogog 2019-09-21 15:35:27 -07:00
bb53ee9567 Going once... going twice! 2019-09-21 15:04:00 -07:00
9934a856dd More go 2019-09-21 12:54:45 -07:00
24904c5083 Go F yourself 2019-09-21 11:56:31 -07:00
6ce4663a31 GoGoGo 2019-09-21 00:19:20 -07:00
fbf74d3baa Go! Go! https://www.youtube.com/watch?v=hyGYdqMfrQQ 2019-09-20 21:00:54 -07:00
b540181990 Go! Go! Go! - Moby 2019-09-20 20:34:31 -07:00
02a6b15e6b Moar Go 2019-09-20 19:51:57 -07:00
b34aa10bf8 Go code! 2019-09-20 18:48:48 -07:00
e0ddbc2f28 Update build process, Go glue builds now. 2019-09-20 15:00:53 -07:00
ed2024285d More Go boilerplate. 2019-09-20 14:11:15 -07:00
ae2120eb96 New service, work in progress 2019-09-20 09:09:05 -07:00
3ceb2257e5 Plumb through roots via API. 2019-09-19 09:47:12 -07:00
624efde7e4 Make sure threads dont exit on spurious return values from recvfrom unless we are really dying. 2019-09-16 20:41:23 -07:00
50009fef6f Merge branch 'dev' into edge 2019-09-16 20:26:41 -07:00
de127056c2 Add notarization to "make official". 2019-09-16 20:13:20 -07:00
dde937e197 cleanup 2019-09-16 19:58:21 -07:00
07a480b37a Build fix. 2019-09-16 18:04:32 -07:00
9f5bccec30 Add a recv timeout to root 2019-09-16 18:03:17 -07:00
ade52bf81e Fix RENDEZVOUS issue and possibly improve GeoIP resolution. 2019-09-16 17:04:13 -07:00
71c766a3b2 Build fix 2019-09-16 15:09:56 -07:00
eef66aee9a build fix 2019-09-16 14:51:02 -07:00
e245eb1eb5 Trim some unnecessary locks from root, and cleanup elsewhere. 2019-09-16 14:48:27 -07:00
e08fc81397 More threading improvements in root, more DNS TXT and multicast work (in progress) 2019-09-16 10:33:59 -07:00
9f9032ae36 Cleanup and warning removal. 2019-09-13 16:24:02 -07:00
063a16fcd6 Ensure SSE is enabled for Salsa20 on x64 2019-09-13 11:16:21 -07:00
0db4151492 cleanup 2019-09-13 11:10:56 -07:00
e44d7a553f The root technically does not need to do this, and its slow. 2019-09-13 10:29:11 -07:00
53a2de98de Packet ID fix 2019-09-13 10:23:35 -07:00
2deaaeef28 Some root cleanup and more lock contention reduction. 2019-09-13 10:20:29 -07:00
1f9e16f63e AES optimization rabbit hole 2019-09-13 09:37:09 -07:00
87fe69c27c AES optimization rabbit hole 2019-09-13 09:35:49 -07:00
2d1eeda188 Cleanup, optimization 2019-09-12 14:32:37 -07:00
5c06d40358 cleanup 2019-09-12 10:37:26 -07:00
31e193756d cleanup 2019-09-12 09:59:46 -07:00
5aa744db84 Simplification and further concurrency improvements. 2019-09-12 08:41:34 -07:00
0ad82dad80 Linux build fix 2019-09-12 08:25:26 -07:00
99c36ed2f2 Parallelization improvements 2019-09-12 08:20:38 -07:00
44878e583a Bug fixes 2019-09-11 16:10:06 -07:00
0723a85ab3 Build fixes. 2019-09-11 15:52:18 -07:00
d8dae365f6 Cleanup, optimization, multicast stuff, and it now compiles again. 2019-09-11 15:34:55 -07:00
bccb86a401 More multicast work... 2019-09-10 16:20:28 -07:00
592e743349 Yet more multicast work. 2019-09-09 15:49:17 -07:00
fb6161e9ac May as well make it a full self-signature. 2019-09-09 10:45:49 -07:00
787277d282 More multicast work, add a signature in identity for safety margin, cleanup. 2019-09-09 10:44:31 -07:00
540ee69773 A bunch of multicast work... in progress. 2019-09-07 19:15:21 -07:00
0d2c87fe4e map fix 2019-09-06 08:54:27 -07:00
2460de9713 map fix 2019-09-06 08:50:36 -07:00
0d32f42d26 map fix 2019-09-06 08:47:32 -07:00
277497684e Revert "map fix"
This reverts commit f4a83e516c.
2019-09-06 08:45:39 -07:00
f4a83e516c map fix 2019-09-06 08:41:03 -07:00
d2eb1ed9a5 map fix 2019-09-06 08:27:03 -07:00
a3ec5846df map fix 2019-09-06 08:18:11 -07:00
b6047899a8 map fix 2019-09-06 08:12:46 -07:00
3516070b6e map fix 2019-09-06 08:11:20 -07:00
56ec87e00e map fix 2019-09-06 08:03:59 -07:00
fe0b896665 map fix 2019-09-06 07:58:43 -07:00
e4721417e6 map fix 2019-09-06 07:55:36 -07:00
45f5b3b648 map fix 2019-09-06 07:40:32 -07:00
3123102211 root cleanup and add nifty geoip thing 2019-09-06 07:37:44 -07:00
c6141ffbc7 cleanup 2019-09-05 18:06:48 -07:00
c0e92d06a5 faster without const variable second-guessing of the compiler 2019-09-05 17:31:12 -07:00
274b2682d6 cleanup and docs 2019-09-05 15:09:20 -07:00
171d661b84 cleanup 2019-09-05 12:17:04 -07:00
5cea8da664 Optimization and naming cleanup 2019-09-05 12:03:11 -07:00
44dd52d08f KBKDF 2019-09-05 11:39:16 -07:00
70648d006d Merge branch 'dev' into edge 2019-09-05 11:06:27 -07:00
0767ea5d69 * 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-09-05 11:02:16 -07:00
43e6a9e9ee more fastitude 2019-09-05 09:54:30 -07:00
0599c1710b Merge branch 'dev' into edge 2019-09-04 16:41:05 -07:00
abf218a9cd cleanup 2019-09-04 16:38:55 -07:00
55f4f9aaeb cleanup 2019-09-04 16:15:10 -07:00
82b7e1dbcb HMAC fix 2019-09-04 15:22:15 -07:00
e8f8b0f8e5 cleanup 2019-09-04 14:40:36 -07:00
7566d4fbab Merge dev 2019-09-04 14:38:35 -07:00
3a0d385119 Implement changes to AES-GMAC-CTR: four keys with one for each role/purpose instead of just two, and simpler CTR-IV calculation. 2019-09-04 14:37:38 -07:00
8454a14eac new Windows GUID for build #2 2019-09-04 14:25:57 -07:00
ecee310087 Update built-in root list. 2019-09-04 14:17:41 -07:00
bcdab95e4c Windows installer version bump, build fix. 2019-09-04 14:13:45 -07:00
a16377cea5 Add mitigations against borked ARM32 exception unrollers, possibly fix GitHub issue #1003 2019-09-04 12:48:28 -07:00
ef69f1bb27 ARM wrestling 2019-09-04 12:37:54 -07:00
27c8eb0d6d GitHub issue #1019 2019-09-04 12:21:51 -07:00
a465afa83d Merge branch 'dev' into edge 2019-09-04 08:19:39 -07:00
3c0f54257b Debian typo fix 2019-09-04 08:19:33 -07:00
185e90c40f AES-GMAC-CTR tweaks, self test tweaks, debian typo fix. 2019-09-04 08:19:12 -07:00
e29c2d0260 Fix field headers 2019-09-03 15:59:34 -07:00
acf6425ae9 Formatting fix 2019-09-03 15:55:23 -07:00
5e8d49de0f Stats, tweak P2P success rate stat. 2019-09-03 15:48:10 -07:00
1f9456a462 Estimate P2P Success Rate 2019-09-03 15:19:17 -07:00
a7d8285c3a Don't require siblings field 2019-09-03 14:57:54 -07:00
5f1dc4b851 cleanup 2019-09-03 14:57:02 -07:00
b1c22949c5 Cleanup, add support for distributing a new planet file 2019-09-03 14:44:13 -07:00
29be175743 Make relay max hops configurable on roots 2019-09-03 13:17:12 -07:00
b6c5ba264b One more fix for discarding hops exceeded packets. 2019-09-03 13:01:01 -07:00
8e7e3c2b11 Fix max hops. 2019-09-03 12:58:23 -07:00
0e7df129d8 Fix variable shadowing bug. 2019-09-03 12:51:32 -07:00
50709cbd21 Fix siblings in peers list, fix meter. 2019-09-03 12:44:09 -07:00
fd6e8d8c5c Add instrumentation to root, add capability to forward to siblings if no path is known to a peer. 2019-09-03 12:21:57 -07:00
2e7496130c Fix silly thinko in root that harms p2p establishment. 2019-08-30 21:17:34 -07:00
9666ab5797 Merge branch 'dev' into edge 2019-08-30 17:57:11 -07:00
e6ead35884 docs 2019-08-30 17:48:22 -07:00
a6dff8ff2f Add an extra catch as workaround for possible cause of ARM crash. 2019-08-30 17:47:13 -07:00
4281b6b448 Ignore MULTICAST_GATHER replies with the wrong count. 2019-08-30 17:45:10 -07:00
4c08ac7873 Fix MULTICAST_GATHER reply problem in root 2019-08-30 17:34:05 -07:00
5435ec7545 Merge dev 2019-08-30 15:40:00 -07:00
6897f602bf 1.4.6 version bump 2019-08-30 15:30:37 -07:00
8764d50179 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge 2019-08-30 15:16:21 -07:00
075321fd0d debian build version bump 2019-08-30 15:16:05 -07:00
62cdb8dc94 cleanup 2019-08-30 12:47:19 -07:00
5e8e935189 world! 2019-08-30 11:57:18 -07:00
ebb5f1256f ARM wrestling 2019-08-30 10:03:07 -07:00
7c6d0d3c0f ARM wrestling 2019-08-30 09:50:37 -07:00
9918a1092f JSON fix 2019-08-30 09:39:46 -07:00
7d89511fda JSON fix 2019-08-30 09:38:18 -07:00
795b6d13d1 Simple status output on root of HTTP tree 2019-08-30 09:29:06 -07:00
8328b6f657 Lib fix 2019-08-30 09:10:11 -07:00
9994e591bd More root work and CMake-ify root 2019-08-30 09:08:39 -07:00
b27a38e55e Implement WHOIS 2019-08-29 14:27:41 -07:00
f6d747a5a0 Fix some more multicast stuff (minor) 2019-08-29 12:02:37 -07:00
b7da7574d1 Helps to decompress the packet 2019-08-29 11:40:31 -07:00
dbad9585cd Fix parsing of MULTICAST_GATHER 2019-08-29 11:23:23 -07:00
2d7a97bb94 Fix V4/V6 forwarding issue in root 2019-08-29 10:58:47 -07:00
da19da0360 RENDEZVOUS works now 2019-08-29 08:00:54 -07:00
ee7361ee2e crash fix 2019-08-29 07:25:16 -07:00
6e3e09bed4 Add RENDEZVOUS to high throughput root 2019-08-29 07:17:18 -07:00
86762d2b40 high throughput root is working! 2019-08-28 15:52:18 -07:00
ef12c5af99 . 2019-08-28 15:22:28 -07:00
933404b1dd . 2019-08-28 15:20:34 -07:00
ccec49e444 . 2019-08-28 15:17:16 -07:00
e5f1bf81f7 . 2019-08-28 15:15:21 -07:00
0e627f4f68 . 2019-08-28 15:07:38 -07:00
d33f7d2bf5 . 2019-08-28 14:49:16 -07:00
e07a019615 . 2019-08-28 14:47:05 -07:00
34ca3012e6 . 2019-08-28 14:43:37 -07:00
62634ca2da . 2019-08-28 14:39:31 -07:00
846c96e8d5 . 2019-08-28 14:36:29 -07:00
63775723c1 . 2019-08-28 14:28:07 -07:00
2f7d3e655a . 2019-08-28 14:26:13 -07:00
b19634d7e4 . 2019-08-28 14:21:02 -07:00
a92967a7c1 . 2019-08-28 14:16:14 -07:00
8915b88de5 . 2019-08-28 14:06:45 -07:00
7bca81464b . 2019-08-28 14:04:42 -07:00
b974ece24f . 2019-08-28 13:59:23 -07:00
b1c8e6ad59 . 2019-08-28 13:51:13 -07:00
64f7185e3a . 2019-08-28 13:44:15 -07:00
807cc9afc3 . 2019-08-28 13:40:49 -07:00
0adf306dd4 . 2019-08-28 13:38:52 -07:00
db0f602e86 . 2019-08-28 13:10:36 -07:00
17ec47f5c0 . 2019-08-28 13:09:14 -07:00
cf831d9cd3 . 2019-08-28 13:04:58 -07:00
5e3c633f74 root work 2019-08-28 11:59:13 -07:00
4e4b27b6ab build fix 2019-08-28 11:54:09 -07:00
c0c9590904 High throughput root stuff 2019-08-28 11:49:45 -07:00
24c9577e39 cleanup 2019-08-28 11:28:51 -07:00
59ee0cfe88 Safety upgrades to code 2019-08-28 10:34:32 -07:00
1977b9b764 Use -flto on Mac for release 2019-08-28 07:45:49 -07:00
6f9d1fc14c Merge branch 'dev' into edge 2019-08-28 07:43:36 -07:00
1b6b38e395 Add default addIps() implementation to EthernetTap base class to fix build on systems that do not need addIps(). 2019-08-28 07:43:18 -07:00
8ac59ae2be cleanup 2019-08-28 07:40:13 -07:00
46db37e06c Yield in ticket lock 2019-08-28 07:34:24 -07:00
9d1207b339 Merge branch 'dev' into edge 2019-08-28 07:31:33 -07:00
6e730cfad1 Cleanup, multicast fingerprint, benchmark asymmetric crypto 2019-08-28 07:31:17 -07:00
1cf953c046 working docker image for end users.
GitHub Issue #1013
2019-08-27 16:57:07 -07:00
e5bf4565da readme in central controller docker folder 2019-08-27 15:43:11 -07:00
ddc904a502 remove docker line from readme 2019-08-27 15:27:41 -07:00
5cda292d15 comment out docker docker target from makefile because broken 2019-08-27 15:16:05 -07:00
e51cf0d4d2 moved elsewhere for controller builds 2019-08-27 15:14:55 -07:00
d8de837c60 LinuxEthernetTap addIps virtual function fix for SYNOLOGY builds 2019-08-27 14:43:30 -07:00
199b3345a0 cleanup 2019-08-27 14:42:49 -07:00
b7f504b8a4 cleanup 2019-08-27 14:40:01 -07:00
1b459b0560 cleanup 2019-08-27 14:31:04 -07:00
40803a4dc1 cleanup 2019-08-27 14:25:11 -07:00
6f22570648 Optimization and cleanup 2019-08-26 20:18:28 -07:00
8203547cfc Warning removal. 2019-08-26 20:01:54 -07:00
dad160209e Add -mmacosx-version-min=10.9 2019-08-26 19:54:24 -07:00
8faaaec710 Add check for PCLMUL instruction too. Virtually all CPUs with AES-NI have it but good to be sure. 2019-08-26 19:48:56 -07:00
012fba617d Set SSE/AES-NI flags only on x86/x64 targets. 2019-08-26 19:40:22 -07:00
9ca495229b Revert "optimization stuff"
This reverts commit e63f624d3a.
2019-08-26 19:03:09 -07:00
e63f624d3a optimization stuff 2019-08-26 19:02:28 -07:00
e1dd413266 cleanup 2019-08-26 18:44:56 -07:00
b9ef09dd58 Optimization stuff 2019-08-26 18:15:32 -07:00
990333e7ec cleanup, re-enable AES-NI check 2019-08-26 16:35:28 -07:00
ec9582f3f2 More test vectors, software mode GCM. 2019-08-26 16:24:42 -07:00
ea65386e15 Merge branch 'dev' into edge 2019-08-26 12:22:20 -07:00
ca89695270 Fix make central-controller-docker 2019-08-26 12:19:50 -07:00
a0fd4ad23f Cleanup, Linux build fix. 2019-08-26 12:17:23 -07:00
b6d7a95028 Merge branch 'dev' into edge 2019-08-26 11:09:19 -07:00
91b16310ea * 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-26 10:33:26 -07:00
609873e6d1 Windows version bump 2019-08-23 22:10:15 -07:00
4c616621c2 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-08-23 21:38:15 -07:00
05470bf202 Fix RPM targets 2019-08-23 21:38:04 -07:00
633cf9ec04 Warning removal 2019-08-23 21:28:26 -07:00
f3c3a90393 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-08-23 21:24:34 -07:00
25a48f2f44 Fix RedHat sub-version. 2019-08-23 21:24:05 -07:00
1d8f3cee62 cleanup 2019-08-23 21:12:24 -07:00
5ba6e21967 cleanup 2019-08-23 20:34:09 -07:00
52f7f6e6cf Fully implement the packet encryption/decryption algorithms. 2019-08-23 20:20:32 -07:00
9fd5ec673b Get rid of complicated AES-GCM + scramble construct in favor of a simpler construct thanks to "Squeamish Ossifrage" on crypto.stackexchange.com 2019-08-23 18:41:21 -07:00
e905b3c963 cleanup 2019-08-23 17:22:23 -07:00
d214a5437f Bump Mac pkg version 2019-08-23 15:24:52 -07:00
f12370c348 more opt 2019-08-23 12:40:08 -07:00
b727e2a67a More opt stuff 2019-08-23 12:34:45 -07:00
8e87319925 Optimization stuff 2019-08-23 12:18:02 -07:00
1ab29b1ab0 Merge branch 'dev' into edge 2019-08-23 12:11:07 -07:00
de0a5aa840 GitHub issue #994 2019-08-23 12:09:31 -07:00
52d55e34e6 Licenses, and use full strength AES-128 in scramble. 2019-08-23 12:03:13 -07:00
c79360f58b Merge dev 2019-08-23 11:37:40 -07:00
6f9e3e3b78 Back out unnecessary hack 2019-08-23 11:14:17 -07:00
5c5e7fc7ff Merge branch 'dev' of https://github.com/zerotier/ZeroTierOne into dev 2019-08-23 11:13:13 -07:00
43e98930e9 distro cleanup 2019-08-23 11:12:25 -07:00
51ebefc3ab Ifdef these to stop non-Windows IDEs from complaining. 2019-08-23 10:34:37 -07:00
86add4a6d3 Tolerate any libstdc++6 package "version" for Mint and other distros with weird versions on libstdc++6. 2019-08-23 10:31:12 -07:00
221a3f9a08 Merge branch 'dev' of http://10.187.0.8/zerotier/ZeroTierOne into dev 2019-08-23 10:20:04 -07:00
2f74bd5150 Add "make docker" for GitHub issue #1013 2019-08-23 10:19:59 -07:00
e8ae333443 Version bumps, license fixed, and GitHub issue #990 take two 2019-08-23 10:15:13 -07:00
8057c826bc cleanup 2019-08-23 09:34:26 -07:00
6f6138c500 Merge relicensing change from dev 2019-08-23 09:27:13 -07:00
52a166a71f Relicense: GPLv3 -> ZeroTier BSL 1.1 2019-08-23 09:23:39 -07:00
903a18db1d work in progress 2019-08-23 08:41:22 -07:00
0731f3f1a9 wiring more stuff up, and simplification of timing loops 2019-08-23 07:04:20 -07:00
37047a39f9 More cleanup, and fix SHA384 built-in C code. 2019-08-22 14:52:47 -07:00
91d0cbe892 cleanup 2019-08-22 13:08:10 -07:00
b66431bc29 Work in progress... 2019-08-22 13:06:08 -07:00
0e18b14087 Merge branch 'dev' into edge 2019-08-21 14:58:26 -07:00
31bd413166 stub out new verbs 2019-08-21 14:57:57 -07:00
95a6fce2b4 Yet more cleanup, it builds again now. 2019-08-21 14:36:56 -07:00
0b5472f9fb Tons and tons of cleanup and cruft removal 2019-08-21 14:24:45 -07:00
5280d28505 cleanup 2019-08-21 10:44:52 -07:00
67a9898a99 Bunch more work on DNS, cleanup, removal of obsolete cruft. 2019-08-21 09:27:45 -07:00
509da3ac34 Merge pull request #1012 from wendelb/wendelb-patch-1
Controller-Docs little cleanup
2019-08-21 08:14:38 -07:00
fe8815f80f cleanup 2019-08-20 15:36:18 -07:00
3a21fdc304 Crypto work, packet work 2019-08-20 15:34:30 -07:00
83d723eb79 type 1 (P-384) identities 2019-08-20 13:32:23 -07:00
6e771607c0 cleanup 2019-08-19 20:35:16 -07:00
e73b220104 cleanup 2019-08-19 20:30:34 -07:00
5c1fc43610 cleanup 2019-08-19 20:29:24 -07:00
cfbd7e3bf5 Add stubs to easily build and include all of libnatpmp and miniupnpc in osdep/ 2019-08-19 20:28:44 -07:00
c8ca1cfa3c Kill old inline software update, we will use https and secondary auth for new versions. 2019-08-19 19:24:23 -07:00
5cfbb0a423 Clean up dead stuff from OneService and fix build errors. 2019-08-19 19:21:33 -07:00
900ec143a8 . 2019-08-19 16:45:29 -07:00
7bda3d0f74 put sse4.1 back 2019-08-19 15:49:13 -07:00
7650786fb5 cleanup, Locator fix and self-test 2019-08-19 15:43:15 -07:00
ca60d08621 cleanup, scrambler functions 2019-08-19 12:49:33 -07:00
b34218c8c2 auto-set -j option in makefile, and split out cmake setup rule 2019-08-19 10:06:39 -07:00
b14a59629c cleanup 2019-08-19 06:58:42 -07:00
fe18579061 Removed duplicate line creationTime 2019-08-17 22:50:13 +02:00
0914bf8cf0 Some ARM NEON code (not finished) 2019-08-16 19:22:03 -07:00
7bdca83de3 Add decrypt 2019-08-16 18:40:22 -07:00
846f03504e Add DNS TXT resolver (need one for Windows) 2019-08-16 16:49:30 -07:00
01e8fd0b07 The newer C ed25519 is the same speed as the old ASM, so drop it to simplify. 2019-08-16 14:42:38 -07:00
7f301c44b7 more cleanup 2019-08-16 14:26:45 -07:00
51a25fdec9 Remove ASM Salsa20 since it will not be the default in 2.x any more... reduce build complexity. 2019-08-16 14:26:25 -07:00
2b681c37ac Consolidate common compiler flags 2019-08-16 11:42:43 -07:00
cb4ebfdbd2 Dragging adam into CMake kicking and screaming :) 2019-08-16 10:45:14 -07:00
206c85222c Fix Constants.hpp inclusion of version.h 2019-08-16 09:52:13 -07:00
18071e038e Fix MacEthernetTapAgent & Cmake integration 2019-08-16 09:44:31 -07:00
39f7ce15ad mac compiler flags 2019-08-15 17:40:21 -07:00
e39b42bbd3 fixing some CMake stuff on Linux 2019-08-15 17:29:33 -07:00
607d8f72e8 cruftectomy 2019-08-15 15:43:35 -07:00
c483f75fb4 cleanup 2019-08-15 15:32:16 -07:00
81f0175251 cleanup 2019-08-15 14:14:49 -07:00
f753519729 A bit more optimization 2019-08-15 14:07:52 -07:00
f39693f97e cleanup 2019-08-15 13:52:23 -07:00
f83ae0e39e Add self-test for AES and AES-GCM using public test vectors. 2019-08-15 13:47:43 -07:00
521d371b5d A bunch more refactoring to rip out obsolete stuff related to old root system and general cleanup. 2019-08-15 10:49:50 -07:00
b23d551d00 cleanup 2019-08-14 16:05:09 -07:00
1b20cc6075 More optimization and cleanup 2019-08-14 15:59:45 -07:00
2043e12ac2 . 2019-08-14 15:50:25 -07:00
9461bc948f . 2019-08-14 15:28:10 -07:00
9740ab8bd6 more cleanup 2019-08-14 15:17:06 -07:00
6947a6b1d4 more cleanup 2019-08-14 15:12:49 -07:00
4da8036222 More refactor 2019-08-14 15:00:18 -07:00
e6b4006c70 Refactoring to eliminate duplicated code 2019-08-14 14:55:37 -07:00
8f5f7f1baa More work in progress 2019-08-14 12:48:45 -07:00
573d3eea87 Merge branch 'dev' into edge 2019-08-14 10:53:03 -07:00
2ec53df7ab Put a limit on the multicast TX queue to prevent memory use ridiculousness. 2019-08-14 10:52:21 -07:00
eb84eec0f4 Merge branch 'dev' into edge 2019-08-14 10:48:07 -07:00
1c7b553331 GitHub issue #1000 2019-08-14 10:47:58 -07:00
d7a31088ba Cleanup, warning removal, cppcheck informed cleanup. 2019-08-14 10:35:57 -07:00
a028e04ab9 Merge branch 'dev' into edge 2019-08-13 15:51:19 -07:00
a0fb519696 Make sure libstdc++ is in RH spec file 2019-08-13 12:58:14 -07:00
83e6864b78 Version bump in Linux packages for new binaries. 2019-08-13 09:34:56 -07:00
a0520536df . 2019-08-13 08:49:25 -07:00
af137fd5d3 Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge 2019-08-12 15:37:55 -07:00
f7bc9f01c9 More AES stuff 2019-08-12 15:37:50 -07:00
e4ce1ffd85 Windows detection of AES-NI 2019-08-12 15:28:42 -07:00
2384b49156 set cmake windows build target to Windows 7 2019-08-12 15:28:30 -07:00
f5e71f64ed Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge 2019-08-12 13:27:07 -07:00
927ef22cf8 Merge branch 'dev' into edge 2019-08-12 13:27:00 -07:00
b6eaec1278 run selftest 2019-08-12 13:26:34 -07:00
c7d1eb71da build & run selftest as part of jenkins 2019-08-12 13:25:14 -07:00
98af3c0dc1 * 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-08-12 13:25:12 -07:00
7d41d267a3 silencing warnings for code paths that will never be hit 2019-08-12 13:18:21 -07:00
0ead65ad2d change this 2019-08-12 13:11:43 -07:00
8c5481a3d5 Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge 2019-08-12 12:58:20 -07:00
741258051e this should work better 2019-08-12 12:58:10 -07:00
0f4fc8635b Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge 2019-08-12 12:51:38 -07:00
d02d3f72fe AES-GCM code 2019-08-12 12:51:32 -07:00
710b69fc75 kill build dir before jenkins build 2019-08-12 12:44:47 -07:00
4fae382ffd Auto-generate version.h 2019-08-12 12:43:51 -07:00
68b94a3188 CMake for edge branch 2019-08-12 12:35:07 -07:00
8e04f83232 Merge branch 'edge' into cmake 2019-08-12 12:24:25 -07:00
cc9fd9f8ce Merge branch 'dev' into cmake 2019-08-12 12:23:36 -07:00
1e8fcf1344 Add AES to build 2019-08-09 13:42:40 -05:00
809c8305b1 AES code 2019-08-09 10:54:08 -05:00
652c7e8f37 Locator work 2019-08-08 23:23:16 -05:00
beebca98fe Merge branch 'dev' into edge 2019-08-08 19:42:16 -05:00
5341c216a7 Comment ugly query 2019-08-08 19:20:01 -05:00
96a0c3d764 ugly query is ugly 2019-08-08 19:16:11 -05:00
783b49e383 more worky less not worky 2019-08-08 18:58:22 -05:00
ce67abc32f Merge branch 'dev' into edge 2019-08-08 18:49:03 -05:00
d4dc983a01 fix bad column name 2019-08-08 18:31:41 -05:00
72ccd1020a Another exception fix 2019-08-08 18:11:06 -05:00
6a9a577c59 rulesSource needs to be required in network or pgsql has issues 2019-08-08 17:56:27 -05:00
730305ecc7 One more sync fix. 2019-08-08 17:31:32 -05:00
f8f2432ece Shutdown fix 2019-08-08 17:22:20 -05:00
55087521f6 Add periodic sync check when syncing LF<>another DB 2019-08-08 17:20:50 -05:00
760ae07d72 Sync bug fix 2019-08-08 16:30:52 -05:00
52cc482521 Merge branch 'dev' into edge 2019-08-08 15:59:58 -05:00
28d0070ce2 Fix race in multiple DB mirroring configurations. 2019-08-08 15:29:13 -05:00
ad2a7c2590 More windows build fixes 2019-08-08 15:15:12 -05:00
5eacad444d workinprogress 2019-08-08 15:03:52 -05:00
8b97755fc5 Windows fixes. 2019-08-08 14:08:35 -05:00
e8155cbbeb Merge dev 2019-08-08 13:05:28 -05:00
7bb0d9be1b warning removal 2019-08-08 11:04:11 -05:00
6c44fcc290 more warning cleanup 2019-08-08 10:28:57 -05:00
c8e7031198 warning cleanup 2019-08-08 10:01:57 -05:00
fb3b2820b5 centos 7 docs 2019-08-08 09:50:05 -05:00
663376e385 cleanup 2019-08-08 08:42:27 -05:00
3c590994db Finish up ECC384 identity generation. 2019-08-07 23:50:47 -05:00
14c8564893 Merge branch 'dev' into edge 2019-08-07 22:35:27 -05:00
91a37f8868 Add base64 code (unpadded standard alphabet) 2019-08-07 22:35:17 -05:00
c83a4aef55 cleanup 2019-08-07 21:47:06 -05:00
af7a70bf02 cleanup 2019-08-07 21:11:48 -05:00
1a2ff884b3 Merge branch 'dev' into edge 2019-08-07 19:08:35 -05:00
4d70640a15 Remove debug line 2019-08-07 19:06:02 -05:00
b11627a8bc add SDK VirtualTap to new factory method 2019-08-07 18:45:04 -05:00
7436f85ad0 Require MacOS 10.10 2019-08-07 18:22:03 -05:00
237c379866 Choose which tap to use (feth or kext) on Mac based on Darwin version. 2019-08-07 18:20:17 -05:00
aca31c7055 Put kext back in Mac distro and use on versions older than High Sierra (which lack the feth device) 2019-08-07 18:14:12 -05:00
0298719be0 Use SHA384 with ECC384 to match FIPS / Suite B recommendation. 2019-08-07 17:06:03 -05:00
d0746da5e2 Add SHA384 support, more cleanup 2019-08-07 16:41:58 -05:00
5b1cf33b1b Merge branch 'dev' into edge 2019-08-07 11:31:32 -05:00
6073e7972f Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-08-07 11:24:04 -05:00
f7e8d8f1dd Fix LFDB path issue when using with Postgress in DBMirrorSet config 2019-08-07 11:23:48 -05:00
54a1bbd016 . 2019-08-07 11:20:12 -05:00
87016ae815 network update to upsert 2019-08-06 15:30:50 -07:00
455cd5551b . 2019-08-06 17:06:39 -05:00
3ed8e46782 Use devtoolset-8 on RHEL/CentOS 7 2019-08-06 16:46:41 -05:00
b3e1783658 . 2019-08-06 16:46:13 -05:00
906c83af83 Merge branch 'dev' into edge 2019-08-06 15:47:54 -05:00
3db0197865 Add try/catch in LFDB and add introspection into multicast subscriptions in client network status API 2019-08-06 15:22:57 -05:00
f9900cc6fb Merge dev to edge 2019-08-06 14:13:07 -05:00
6174c0c103 Fix deadlock bug. 2019-08-06 13:20:37 -05:00
8898cb342b . 2019-08-06 13:12:45 -05:00
9cc76d1115 Remove debug line 2019-08-06 11:01:08 -05:00
5289d3327c Build fixes 2019-08-06 11:00:35 -05:00
00fb9c475e More work on DB mirroring. 2019-08-06 10:42:54 -05:00
3c776675b3 Cruftectomy, work in progress on mirrorring 2019-08-06 08:51:23 -05:00
37d508ab96 Refactoring in prep for mirroring 2019-08-06 07:51:50 -05:00
f4f8fef82e LFDB fix 2019-08-05 15:30:03 -05:00
cd2e3c79f2 Windows AIP version bump 2019-08-04 20:27:09 -07:00
7722350178 Version bump to 1.4.2 for all but Windows AIP 2019-08-04 20:13:12 -07:00
a77b4ecddb Add optional function in DB change listener for member online events. 2019-08-04 19:55:52 -07:00
818b7e4a2e GitHub issue #993 (???) 2019-08-04 15:35:43 -07:00
00d63f6046 GitHub issue #993 (???) 2019-08-04 15:15:02 -07:00
639fc60257 GitHub issue #990 2019-08-04 15:08:33 -07:00
21467596bc Merge branch 'remove_network_status_table' into dev 2019-08-04 12:38:12 -07:00
75ebe5172f Fix for sharing of capabilities in 1.4 (problem introduced when push frequency was reduced) 2019-08-02 20:43:02 -07:00
4a9030b4a0 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-08-02 13:59:10 -07:00
fdc708a624 GitHub issue #979 2019-08-02 13:59:03 -07:00
8e20187d8c set OS X deployment target to 10.9 2019-08-01 15:58:32 -07:00
28dac7ff0e build MacEthernetTapAgent 2019-08-01 15:41:50 -07:00
e385b3d377 Merge branch 'dev' into cmake 2019-08-01 15:16:31 -07:00
7e5c68c553 update jenkins to use cmake for builds 2019-08-01 15:13:06 -07:00
39ad7bc741 update cmake to add LFDB and force C++11 2019-08-01 14:36:35 -07:00
c2f9aab068 Merge branch 'master' into cmake 2019-08-01 13:49:30 -07:00
67beea1e3d Batch file to clean Windows build dir 2019-08-01 13:21:36 -07:00
34364ab8ee Bump version 2019-07-31 16:41:35 -07:00
bb99ef1351 Get rid of online status stuff in FileDB, not necessary at all. 2019-07-31 16:41:12 -07:00
b3891e5506 Version 1.4.0.1: bug fix for Mac multicast and IPv4 issues, no change for other platforms 2019-07-31 13:27:08 -07:00
632d6e04ad Mac multicast bug fix -- GitHub issue #986 2019-07-31 13:25:58 -07:00
db813db7e8 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.stackexc
 * Added support for concurrent multipath (multiple paths at once) with traffic weighting by link quality and faster rec
 * 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 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
 * Removed our beta/half-baked integration of Central with the Windows UI. We're going to do a whole new UI of some kind
 * 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
 * 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.
2019-07-29 16:11:06 -07:00
837c6270f2 More docs 2019-07-29 15:14:37 -07:00
8c3c07cb5d docs 2019-07-29 13:50:02 -07:00
5cc0dd7f55 Windows installer version bump 2019-07-29 12:36:10 -07:00
79c4d98b61 docs 2019-07-29 12:10:39 -07:00
678e11530e 1.4 bump 2019-07-29 12:07:44 -07:00
a8f2b39f15 Windows project fixes 2019-07-29 11:05:46 -07:00
add2ac0369 Merge pull request #963 from atopuzov/armv6l
Fix compiling on Raspberry PI Zero W on Arch Linux
2019-07-29 10:23:09 -07:00
1e475edd1c Merge pull request #973 from unquietwiki/patch-1
Update Dockerfile
2019-07-29 10:22:36 -07:00
745483708a Merge pull request #974 from squeakbat/master
Don't relink zerotier-one every time.
2019-07-29 10:21:35 -07:00
d9432f2f1e cleanup 2019-07-29 10:19:20 -07:00
eb7081d2a3 Fix for detecting changes in LF from other instances of the same controller. 2019-07-26 19:28:09 -07:00
d9befe3fb3 Debug code removal 2019-07-26 18:51:50 -07:00
0618452615 LF masking key should be a secret 2019-07-26 17:44:05 -07:00
f6b080b8a2 Abstract out change listener from controller itself to permit DBs to shadow changes from other DBs. 2019-07-26 17:39:00 -07:00
c8c33db1d1 . 2019-07-26 16:03:21 -07:00
196bac726c Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-07-23 16:06:40 -07:00
ac2688de58 More LFDB work 2019-07-23 16:06:35 -07:00
d2af12b6a0 Forgot to add ZT_DISABLE_COMPRESSION to linux makefile 2019-07-23 13:33:25 -07:00
6958ba9557 Added ZT_DISABLE_COMPRESSION build flag for SDK and low-end NAS builds 2019-07-23 12:39:07 -07:00
5f11daadf2 Build fix 2019-07-23 09:30:40 -07:00
99df3fe433 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-07-23 09:29:12 -07:00
d4d350a285 Work in progress 2019-07-23 09:29:08 -07:00
8a0b75c83a Added LFDB.o to objects.mk 2019-07-22 15:24:16 -07:00
9cf74657e0 Commented out rtnetlink error debug trace 2019-07-22 14:12:21 -07:00
5edd04638d LFDB work in progress 2019-07-22 13:43:06 -07:00
eb2f851e65 Don't relink zerotier-one every time.
Because zerotier-one depends on "one", which is a phony target,
making it relinks zerotier-one every time, which is probably
not the desired behavior.

In any case, zerotier-one, zerotier-cli, and zerotier-idtool are
real target, so they should have real dependencies and actions.
The "one" target now depends on these three files.

Behavior is mostly unchanged otherwise.
2019-07-21 21:37:01 -07:00
a0f47b12b4 Removed Synology-specific home path, changes made elsewhere in SPK 2019-07-19 16:34:31 -07:00
1b2d9e202e Remove 44/8 as pseudoprivate since it is now partly global. 2019-07-19 13:33:14 -07:00
daa8839005 Update Dockerfile
Update Dockerfile to use Debian 10 + pull the main.sh directly from Github; works for Portainer use.
2019-07-18 17:48:41 -07:00
7e105343e2 WIP 2019-07-17 16:53:33 -05:00
fe2215df00 TON of refactoring, moon/planet is DEAD, ECC P-384 is integrated (but not enabled), and multicast work and cleanup. Whew. 2019-07-17 10:52:08 -05:00
80124bb753 Update release notes 2019-07-16 15:34:26 -07:00
640bbaabbf Safer value 2019-07-16 17:28:42 -05:00
da2965cb4e P-384 test vectors 2019-07-16 17:25:25 -05:00
861a319014 Merge branch 'dev' of github.com:zerotier/ZeroTierOne into dev 2019-07-16 15:20:05 -07:00
d43e810ecb Finally figured out how to update the network interface names on Windows so that they'll be visible in ipconfig, Get-NetAdapter etc. 2019-07-16 15:16:49 -07:00
94ba242c33 Nist P-384 guts and glory 2019-07-16 16:09:14 -05:00
7afcc17024 no usleep() on Windows 2019-07-16 13:09:10 -07:00
2ab2f68725 Add a central database schema version check to central controller startup 2019-07-16 12:15:38 -07:00
debd5a5c5e Add capability for P2P multicast propagation, and some cleanup. 2019-07-16 13:33:11 -05:00
98bbb84a63 Merge branch 'dev' into edge 2019-07-15 19:40:52 -05:00
90872c906f Fix FileDB stuff and latency measurement. 2019-07-15 16:30:34 -05:00
bdc2ec1f5e Track online status in FileDB 2019-07-15 15:27:53 -05:00
692733fffb Don't write to ztc_network_status table anymore in central controller 2019-07-15 13:00:16 -07:00
9d908a11ed Some new stuff, may not live forever... 2019-07-15 13:57:42 -05:00
d3728d5859 cleanup 2019-07-10 21:30:11 -04:00
389331ca29 Ticket #915, added allowSecondaryPort to optionally force ZT to use a single port 2019-07-09 10:31:03 -07:00
b2c4b7e99f Version bunmp 2019-07-09 10:36:25 -04:00
fee6aae442 Drop in faster C25519 agreement code. 2019-07-09 10:31:08 -04:00
409406d114 Whoops 2019-07-08 12:36:49 -07:00
203414910f Give up to a second for the interface to appear to assign IP addresses 2019-07-08 12:33:26 -07:00
ac0082a67e Update README.md 2019-07-02 11:56:19 -07:00
9ccbe85923 Fix compiling on Raspberry PI Zero W on Arch Linux
* Should also fix it for Raspberry PI 1
* "gcc -dumpmachine | cut -d '-' -f 1" reports armv6l
2019-07-01 14:56:02 +01:00
dffbd2113a Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-06-28 11:20:49 -07:00
7db073d993 Start 1.4.0 release notes. 2019-06-28 11:20:38 -07:00
3c02c2e4bd Windows installer bump 2019-06-28 08:48:06 -07:00
a17c760181 Fix Mac installer 2019-06-27 14:36:31 -07:00
54d2fa65dd Version bump, cleanup 2019-06-27 14:31:10 -07:00
a019c3dd5d Tighten up credential push just a bit for faster up-time with older nodes, should not have significant impact on bandwidth. Also some cleanup and push direct path timing fixes. 2019-06-25 13:42:20 -07:00
a3ef9b8a15 Cleanup 2019-06-25 10:06:50 -07:00
4d599e2f9f Linux build with CMake 2019-06-21 15:16:20 -07:00
d3b33e5512 Can now build the Windows UI via CMake as well 2019-06-21 12:54:53 -07:00
c8487cc395 no message 2019-06-20 16:15:19 -07:00
0b3b5f6174 Beginning CMake configuration for ZT
Only tested on Windows so far
2019-06-20 16:13:52 -07:00
554e0b7c6d Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-06-20 15:20:46 -07:00
fd74e2a583 Windows build changes for 1.2.99 (1.4.0pre) 2019-06-20 15:20:42 -07:00
af5d3a7f0b dockerfile updates 2019-06-20 14:17:38 -07:00
bb0808c99c Remove current multithreaded receive path, which is not that efficient. We will do something better in the future. 2019-06-19 10:19:59 -07:00
f0295b154b Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-06-17 15:50:11 -07:00
b041de831a More stack->heap 2019-06-17 15:50:05 -07:00
21e844cd82 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2019-06-17 15:32:27 -07:00
4e2439bd12 Don't call _phy->getIfName if localSocket is -1 2019-06-17 15:32:21 -07:00
c5a07c7f20 More stack->heap 2019-06-17 15:28:02 -07:00
e2900f4f3c Fix valgrind warning... not sure if it is an actual issue. 2019-06-17 15:23:52 -07:00
aa831dd843 More stack->heap... 2019-06-17 14:55:33 -07:00
2dc783214c Allocate outp on heap in Peer. 2019-06-17 14:38:27 -07:00
523df47a65 Check for null data ptr 2019-06-17 14:02:35 -07:00
f66fac3982 Win32 build fix 2019-06-17 13:48:42 -07:00
9c51ce9c40 Windows build fixes, fix double/float types to get rid of warnings. 2019-06-17 13:32:41 -07:00
9797540212 merge 2019-06-13 12:53:05 -07:00
ce2338c24a Fix null ptr on managed routes if no IPs are set. 2019-06-13 12:52:38 -07:00
3b188ba672 no message 2019-06-13 10:38:42 -07:00
eb84d61deb remove these from jenkins for now 2019-06-13 10:35:54 -07:00
47d29ddcaf Compiler warning cleanup 2019-06-13 10:28:09 -07:00
f411eb1651 Remove old RethinkDB.cpp/.hpp files from visual studio project 2019-06-13 10:15:45 -07:00
94bd2918fa Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2019-06-12 13:14:23 -07:00
c3bfcf560b Removed check for port number in multipath path replacement logic 2019-06-12 13:14:14 -07:00
5b2b088714 Cleanup, version bump. 2019-06-11 14:58:23 -07:00
0bdfad52e7 docs 2019-06-11 13:51:10 -07:00
cf046a4039 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-06-11 11:01:20 -07:00
700cc92083 Indent fix 2019-06-11 11:01:12 -07:00
2eb9c0924a Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2019-06-11 10:54:14 -07:00
ebadc6f203 Added s390x arch flags to makefile and ZeroTierOne.h for ticket #950 2019-06-11 10:54:06 -07:00
87bce1a36b GitHub issue #886 2019-06-11 10:53:35 -07:00
848f822171 . 2019-06-06 10:04:11 -07:00
d4199ddb3e Commented out RingBuffer::dump() as an alternative solution to PR #952 2019-06-03 11:00:04 -07:00
e4abc91d35 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2019-05-31 15:10:53 -07:00
37d321afc8 dont spin as much in the onlineNotificationThread 2019-05-31 15:10:45 -07:00
541e5c510e CLI improvements (peers, and get/set ip, ip4, ip6, etc) 2019-05-31 11:41:24 -07:00
90d324ae96 Fixed ZT_SDK build issue. Moved ZT_SDK preprocessor directives to more permanent homes 2019-05-17 10:15:40 -07:00
cacdb445c7 Bump protocol version to 10 2019-05-14 13:54:27 -07:00
4743ad0b16 Added convenience swtich for disabling JSON support in SDK build 2019-05-13 12:24:55 -07:00
2d5c6fa975 Disabled compression for outbound packets in SDK build 2019-05-13 12:24:22 -07:00
95ef13f7a1 Added divisor for ZT_PEER_ACTIVITY_TIMEOUT, gives quicker indication to status change in SDK 2019-05-13 12:24:01 -07:00
298e1d5a74 Added 90x90 AppIcon 2019-05-01 12:53:50 -07:00
87c75d033e pt 2 2019-04-22 11:36:14 -07:00
71ae678930 Make things compile with Android NDK again 2019-04-22 11:35:35 -07:00
6a027c9c0a amqp_consume_message now has a timeout
RabbitMQ::consume() will return an empty string if the call to amqp_consume_message times out
2019-04-18 14:57:06 -07:00
6014df2847 fix compile & sql errors 2019-04-04 15:11:01 -07:00
55a9e6e05e Queue up inserts in onlineNotificationThread() into a multiple insert statement 2019-04-04 12:40:49 -07:00
02f0eead1c More new Mac ethernet tap bugs. 2019-03-29 15:14:03 -07:00
d77846dcea Add bigness to buffers to prevent overflow on high traffic (Mac tap). 2019-03-29 12:45:02 -07:00
92c811deb7 Destroy feth devices before creating to delete old ones if they were left behind (MacEthernetTap). 2019-03-29 12:14:03 -07:00
92f199ab98 More bug fixing for AARCH64. 2019-03-28 22:40:28 +00:00
b65feeba85 One more AARCH64 fix. 2019-03-28 15:23:53 -07:00
6914425b03 cleanup 2019-03-28 13:58:19 -07:00
89f57124b2 Never mind, only unused on some builds so leave them there. 2019-03-27 09:30:45 -07:00
65823332d4 Comment out some unused functions. 2019-03-27 09:29:34 -07:00
ee8682ac75 Temporarily disable the symmetric NAT port prediction code since the current version adds protocol overhead and probably is not that effective. 2019-03-26 15:23:51 -07:00
e3e5137757 Fix more alignment hell in LinuxNetLink for AARCH64 and probably other pedantic architectures. 2019-03-25 22:53:06 +00:00
d81549a7b1 Various other fixes including removal of more mem*() issues and netlink fixes for AARCH64. 2019-03-25 22:19:52 +00:00
d5ac8512e3 ... 2019-03-25 12:58:43 -07:00
f23e354272 Nope, more... 2019-03-25 12:56:03 -07:00
6475e1faf6 I think this is the last one. 2019-03-25 12:53:31 -07:00
752fc0742e More mem*() stuff... sigh... 2019-03-25 12:52:19 -07:00
e1091611da More mem*() stuff... 2019-03-25 12:41:59 -07:00
678116b6d1 One more. 2019-03-25 12:36:54 -07:00
0a9e2227e8 ... and more 2019-03-25 12:00:54 -07:00
2600b1f144 Removal of more mem*() calls. 2019-03-25 11:59:14 -07:00
b56753ea9f Get rid of some mem* calls that are bad C++ form (but worked fine) and cause warnings. 2019-03-25 11:45:32 -07:00
97046b265c Kill ZT_FAST_MEMCPY in selftest. 2019-03-22 15:52:16 -07:00
2966eac64f Get rid of ZT_FAST_MEMCPY because this is not really needed. 2019-03-22 15:50:15 -07:00
d530356055 RingBuffer<> is now templated with size, buffer is now static. 2019-03-22 14:39:52 -07:00
af3ec000a0 Merge branch 'dev' into edge 2019-03-22 09:38:41 -07:00
8051127c3b Update credits. 2019-03-21 16:43:53 -07:00
e37eb0aa54 More cleanup of old stuff no longer used. 2019-03-21 16:42:52 -07:00
130fa35bb1 cleanup 2019-03-21 16:39:56 -07:00
39e1021f62 Replace certificate based gating of multicast like/gather with a simpler more efficient method, fix some minor issues with request based com/cert push, and clean up some other random stuff. 2019-03-21 16:18:49 -07:00
63ec19674c . 2019-03-19 16:43:43 -07:00
af60e769b0 Allow mac users to make central-controller
Made the smallest change I could figure out.
Had to remove -Werror because something in the postgres adapter woudn't
compile.

brew install postgresql rabbitmq-c
and seems to put the libs in the right place
2019-03-18 17:01:05 -07:00
087c75d5ee More cleanup. 2019-03-14 16:40:22 -07:00
e03102dbcb Clean out some unnecessarily pedantic auth stuff in favor of a simpler way of gating multicast gathers. 2019-03-14 14:29:15 -07:00
9d7b7c72b2 Merge branch 'dev' into edge 2019-03-14 13:49:49 -07:00
99c3f02343 Update controller readme
Delete `/controller/network/<network ID>/active` docs

re: #921
2019-03-12 13:02:49 -07:00
95bfc29c92 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2019-03-11 12:26:57 -07:00
e3cc7c9a80 fix non-central controller builds 2019-03-11 11:16:44 -07:00
d4c0349de9 Revert "#ifdef'd out multipath/QoS statistics buffers allocations for ZT_PROTOCOL_VERSION<10"
This reverts commit 270debb3fc.
2019-03-11 09:44:40 -07:00
d7a6357393 Merge branch 'dev' into edge 2019-03-08 13:16:02 -08:00
6fbf21b4f0 Use a smaller MTU, which should not impact throughput since 2800+overhead/2 still fits in two of these. 2019-03-08 13:15:47 -08:00
993d850f69 more logs 2019-03-08 10:50:33 -08:00
cda07b20a2 add mutex to channel numbering 2019-03-08 10:29:36 -08:00
52c85aa605 now with more -fPIC 2019-03-08 10:29:19 -08:00
e5155df6d5 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2019-03-08 10:21:19 -08:00
293d2064c4 librabbitmq built with same clang version as zt 2019-03-08 10:20:53 -08:00
171cc3e01a reorder a couple of things 2019-03-08 10:20:19 -08:00
8141043560 finish up rabbitmq integration 2019-03-06 16:16:49 -08:00
9a3cc93d74 update dockerfile to generate rabbitmq config settings when necessary 2019-03-05 15:47:04 -08:00
fcb4221f97 rabbitMQ implementation 2019-03-05 15:11:50 -08:00
1f13374a4f added struct for rabbitmq config 2019-03-04 17:01:16 -08:00
801401a6e7 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2019-03-04 16:31:36 -08:00
de1fc43cc5 added librabbitmq library for central controller 2019-03-04 16:27:39 -08:00
270debb3fc #ifdef'd out multipath/QoS statistics buffers allocations for ZT_PROTOCOL_VERSION<10 2019-03-01 13:28:00 -08:00
59a0a25f35 Merge branch 'controller-live' into dev 2019-03-01 11:13:49 -08:00
a788486803 Remove /controller/network/<network ID>/active from controller documentation as that path no longer exists.
GitHub Issue #921
2019-02-25 12:13:55 -08:00
3d21f0a91f update docker registry used 2019-02-08 10:40:57 -08:00
f726044e29 no message 2019-02-05 11:48:03 -08:00
a4b1917361 Fixed a bug where UI elements were attempting to be updated in a background thread.
Also code cleanup & removed confusing startup UI
2019-02-05 11:47:37 -08:00
a3b2aeb001 Take netmask bits from most specific route. 2019-02-01 14:06:34 -08:00
5b1ef2fb03 Take netmask bits from most specific route. 2019-02-01 14:05:29 -08:00
d0f78f1e03 Bugfix for heap-use-after-free in concurrent packet processing code (manifests only after terminate() is called) 2019-02-01 11:50:52 -08:00
541e91ed8e Fixed potential memory leak in RingBuffer 2019-02-01 11:44:43 -08:00
321cada1d7 Wrong criteria was wrong. Now with less wrong. 2019-02-01 11:38:19 -08:00
34c1023ba7 Wrong criteria was wrong. Now with less wrong. 2019-02-01 11:37:30 -08:00
82a21d4b71 Bugfix for heap-use-after-free in concurrent packet processing code (manifests only after terminate() is called) 2019-01-30 22:29:51 -08:00
23996c7e6b Fixed potential memory leak in RingBuffer 2019-01-27 14:43:29 -08:00
d7091a0bac Fixed sign-comparison compile warnings in QoS code 2019-01-25 13:24:31 -08:00
7414418e2e insert/update host_port on controller start 2019-01-21 11:29:13 -08:00
2294770e56 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2019-01-21 11:18:25 -08:00
d98bdb5643 WIP: Pass listen port down to Postgres 2019-01-21 11:18:20 -08:00
21f4f16e63 Disable HTTP control plane for libzt builds, introduction of getRoutes() for SDK API 2019-01-14 11:34:46 -08:00
0e597191b8 Updated licenses for 2019 2019-01-14 10:25:53 -08:00
001ba1a4a7 Update link to knowledge base. 2019-01-09 10:19:02 -08:00
b59c4a2106 Print error & exit on local.conf parsing error 2019-01-07 11:19:50 -08:00
c35933cd1e Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-12-10 12:27:00 -08:00
0da2efa633 add application_name to pgbouncer connectio string 2018-12-10 12:26:20 -08:00
e23d95bf03 sleep 60 seconds between deployments 2018-12-07 15:17:12 -08:00
f6e9f0e2a2 cleanup 2018-12-07 01:58:23 -08:00
4a89729529 add INCOMING_PACKET_CONCURRENCY environment variable to be able to specify max threads for receive in controller 2018-12-07 00:59:08 -08:00
56a58f2b11 more logging of exits from the central controller 2018-12-06 13:26:53 -08:00
e959908c51 log message 2018-12-06 13:19:36 -08:00
6e3144370a exit controller if onlinenotification thread exits while _run == 1 2018-12-06 13:10:59 -08:00
20f02bb772 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-12-06 13:08:39 -08:00
1c86f25fab update # of threads for Postgres 2018-12-06 13:08:31 -08:00
e6f9ab929d More speed stuff. 2018-12-06 12:47:58 -08:00
18d1772bb4 stuff for speed and stuff (testing) 2018-12-06 12:00:49 -08:00
5535cad773 Revert mutex change. 2018-12-04 16:15:46 -08:00
ec84934d48 Disable spinlock to check CPU usage implications on multithreaded controllers. 2018-12-04 15:59:39 -08:00
328d08781a finish pgbouncer integration 2018-12-03 16:12:15 -08:00
c8d5215870 add handling for PGBOUNCER_CONNSTR environment variable.
alows Central controllers to connect to PGBouncer on some threads.  LISTEN threads still require a direct connection to the DB
2018-12-03 15:19:15 -08:00
62ccb48a0b allow alternative ports for central controllers 2018-12-03 15:06:26 -08:00
82409eb345 add script to cycle central controllers 2018-12-03 15:04:46 -08:00
b75f212d70 Replace RethinkDB section in controller/README with PostgreSQL 2018-11-30 10:41:54 -08:00
ccb856749f back to plain old libpq in dev 2018-11-30 10:40:57 -08:00
9d2bc9bf4e Merge branch 'master' into dev 2018-11-28 08:44:45 -08:00
52c4385c16 Merge branch 'master' of http://git.int.zerotier.com/zerotier/ZeroTierOne 2018-11-28 08:44:12 -08:00
5da7d6d1ae Merge docker update PR 2018-11-28 08:43:50 -08:00
65e0a74718 Merge pull request #869 from bltavares/patch-2
Update ZeroTier version on Docker
2018-11-28 08:41:42 -08:00
01d5d7d78b Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-11-13 16:20:01 -08:00
e3381a4c1f fix member init query 2018-11-13 16:19:55 -08:00
03e35b25b8 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-11-13 16:02:31 -08:00
e2b0fb26b1 self-test build fix. 2018-11-13 16:02:26 -08:00
01c18cc442 update makefile for libpqxx controller 2018-11-13 16:01:43 -08:00
01e6df4d46 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-11-13 16:00:17 -08:00
882b03436d WIP: libpxx instead of libpq 2018-11-13 16:00:13 -08:00
690bd933d5 Support shutdown with postLimit in BlockingQueue 2018-11-13 13:52:45 -08:00
6684559cd9 More Mac tap improvements and threading efficiency improvements. 2018-11-13 13:51:25 -08:00
4ed7d20a48 Another stability fix... turns out vfork is problematic here. 2018-11-13 12:46:36 -08:00
350116c513 Stability improvements for Mac virtual Ethernet tap driver. 2018-11-13 12:42:03 -08:00
7bde2c089d Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-11-13 12:08:02 -08:00
90631adb9b Improve multithreading support for OneService (faster, dynamic adjustment of thread count based on HW concurrency). 2018-11-13 12:07:58 -08:00
f6450cd7e1 Cleanup and a minor performance improvement. 2018-11-13 10:19:51 -08:00
3b6b1d1674 Make incoming packet processor thread pool dynamic based on core count. 2018-11-13 09:35:20 -08:00
33d7b22abe Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-11-11 23:06:31 -08:00
2f9712e6a7 utility script to update public controllers 2018-11-11 23:06:24 -08:00
b937aeb857 cleanup 2018-11-11 23:03:51 -08:00
f3d8846df3 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-11-11 22:55:57 -08:00
2729db9555 exceptions 2018-11-11 22:55:53 -08:00
1cec4b1c4c Raise thread count to 8 2018-11-11 22:55:38 -08:00
7048c77ebc Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-11-11 22:35:26 -08:00
c9c17eaddd Retire RethinkDB, simple receive path multithreading. 2018-11-11 22:35:15 -08:00
f1b82b734a Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-11-11 21:09:35 -08:00
4c0e7aa8b0 more error checking 2018-11-11 21:08:51 -08:00
296e4616cc Migrate Windows to use Visual Studio 2017 Community instead of 2015. 2018-11-11 20:31:31 -08:00
15649334a6 Do not use new "feth" devices for ZT traffic. 2018-11-11 19:22:07 -08:00
b3c2c0866f Times should be int64_t, not uint64_t 2018-11-11 17:38:17 -08:00
c6ae81fac7 Added preprocessor check for __APPLE__ as an attempted fix for ticket #600 2018-11-11 14:23:24 -08:00
79086f0858 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-10-26 12:00:01 -07:00
c148a23df4 Added preprocessor check for ZT_NO_CAPABILITIES around header includes 2018-10-26 11:59:55 -07:00
c56831767e Fix Mac tap agent abort on EINTR. 2018-10-25 20:44:32 -07:00
72a724f075 Clean up some stuff after new feth tap implementation, and comment agent file. 2018-10-25 13:10:24 -07:00
96e1df5854 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-10-25 12:43:35 -07:00
2e44b90f63 OSX no longer requires the kext due to feth black magic! The MacEthernetTapAgent must be installed in /Library/Application Support/ZeroTier/One for ZT to work now. Eventually this can let us do an app bundle, get rid of the pkg, and have ZT itself run with normal or reduced privileges. Also fixes GitHub issue #870 (at least for me) and may be faster than the old kext. 2018-10-25 12:43:30 -07:00
5a0adba798 Setup docker container to use jemalloc 2018-10-24 13:36:21 -07:00
761cc5c923 remove another noisy log line 2018-10-24 13:36:07 -07:00
f901b9dd6b Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-10-24 12:08:48 -07:00
d87fcca176 Fully operational pgsql controller 2018-10-24 12:06:17 -07:00
7c72653385 because Windows.... 2018-10-23 13:21:25 -07:00
7dbccf08ae Removed unnecessary block before get request. Possible bug fix for Synology NAS ticket #27 2018-10-23 10:58:25 -07:00
2d21c18ebd Update ZeroTier version on Docker
This commit changes the Dockerfile ot use the multi-stage build and help
to get an automated build on Docker.

The idea of the multi-stage build is to use the already stable Debian
distribution channel to provide up-to-date versions of ZeroTier.

The benefit is that it would be possible to automate the image build,
either on Docker Hub, Travis or taking advantage of the [docker-library/official-images] infrastructure.

This changes follows the best-practices suggested by
[docker-library/official-images], such as using a High Availability GPG
keyserver, providing a default CMD, allowing "bash" on `docker run` and
others.

Given that both the builder `debian:stretch` and `alpine:latest` are
official messages and have [manifests], this means that this Dockerfile
is also multi-platform. This means that this same Dockerfile will
pick-up the correct Debian package according to the architecture of the
running system during build.

With this changes we could try to promote the image to be parte of
[docker-library/official-images], and take advantage of automated
publishing of multi-architecture images. Others would be able to use
`docker run zerotier` and download the latest version appropriate to
their system.

Related to #682

[docker-library/official-images]: https://github.com/docker-library/official-images
[manifests]: https://blog.docker.com/2017/09/docker-official-images-now-multi-platform/
2018-10-21 11:28:04 -03:00
15d0aad3c0 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-10-19 10:06:06 -05:00
f0fc9b1766 Merge branch 'master' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-10-19 10:05:51 -05:00
7c0331997a Ticket #739 - Fixed what appears to be a copy-paste error for machine type detection in linux makefile, added line for armv7hl 2018-10-03 15:40:16 -07:00
04de2302a7 More insightful errors for get command 2018-10-03 14:24:21 -07:00
1da1409db2 get rid of a noisy log line 2018-09-28 10:58:26 -07:00
c1ea1329c1 Merge branch 'dev' into libpq 2018-09-28 10:56:40 -07:00
417aa9547b Working controller & docker container for GKE 2018-09-28 10:55:39 -07:00
60d5a3c631 Merge pull request #853 from darkain/dev
Fix IPv6 address string representation
2018-09-25 15:32:39 -07:00
7a42416a78 Merge pull request #822 from dschulz/controller-patch1-dschulz
Add functionality to erase members from networks using file backend i…
2018-09-25 11:38:25 -07:00
2a143a7505 Merge pull request #858 from tommyang/fix/mac-uninstall-script
macOS uninstall script: remove symlinks from the actual location
2018-09-25 11:36:28 -07:00
0510f85a8f Merge branch 'dev' into libpq 2018-09-25 10:19:59 -07:00
5b222d0a09 cleanup connections after errors 2018-09-25 10:17:15 -07:00
133b64679c Update README.md 2018-09-24 15:02:11 -07:00
79b88a22c3 Update README.md
Document that allowManagementFrom is an array
2018-09-24 14:58:44 -07:00
88d879987d Remove symlinks from the actual location
Binary symlinks are in `/usr/local/bin` instead of `/usr/bin` since commit 0cf4ddd
2018-09-23 16:53:30 -07:00
27c37a18f3 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-09-17 14:42:33 -07:00
b8268d894b Changed home path for Synology 2018-09-17 11:44:56 -07:00
79b47b055a Only null terminate the first character 2018-09-15 12:13:06 -07:00
8e260bae11 Correcting conversion to/from IP address / string
1) Use existing standard libraries to convert to/from IPv4/IPv6 strings and binary representation.
2) Move null terminator assignment InetAddress::toIpString to top of function, this way if ANY errors occurs that don't write content to the buffer, we're not passing a potentially dangerous buffer around.
2018-09-14 22:42:58 -07:00
af61ee6f3a Merge pull request #836 from skunkwerks/feature/add-freebsd-debugs
add support for debug flags in FreeBSD
2018-09-14 08:08:59 -07:00
04d7a1df96 Merge pull request #837 from skunkwerks/feature/update-ext-json
update external JSON dependency to address libc++ compatibility
2018-09-14 08:08:21 -07:00
b9fd50e348 Merge pull request #845 from asbjornenge/docker-updates
Using multi-stage build for Dockerfile
2018-09-14 08:07:36 -07:00
ef48d11266 Merge pull request #848 from darkain/master
Fix compile on FreeBSD targeting ARMv6 (Raspberry Pi)
2018-09-14 08:05:39 -07:00
a47559d9e3 dev should have odd minor version 2018-09-14 08:05:07 -07:00
cffb992ae8 Adding ARM/NEON detection for non-Linux targets 2018-09-12 19:51:28 -07:00
39e720e811 Adding proper EABI target for ARM32/Salsa 2018-09-12 19:49:14 -07:00
7b87e9c0cb Added ability for OneService to monitor local.conf for changes and automatically reload 2018-09-11 16:55:46 -07:00
3dd9b1aa9b Added ability to specify zt home directory via ZEROTIER_HOME - Addresses ticket #829 2018-09-10 16:25:39 -07:00
0fddebc791 Added ability to manually set secondary and tertiary ports in local.conf 2018-09-10 13:06:05 -07:00
701d64936d Using builder pattern to build in container while keeping final image small 2018-09-07 14:11:25 +02:00
0ec6215493 Send member/network change notifications via Postgres 2018-09-06 15:14:16 -07:00
de45bdb448 quieting things down a little bit 2018-09-05 17:03:49 -07:00
7b608c6ca3 Fix testing for true/false. Dont attempt to update member status on networks that we know dont exist 2018-09-05 16:54:23 -07:00
6ff78c9c26 fix crashes 2018-09-05 16:08:06 -07:00
d701f4e331 Added some exception hadling. Dont want to live *too* dangerously here 2018-09-05 11:49:07 -07:00
92abc92463 Theoretically we have PostgreSQL support now 2018-09-05 11:30:17 -07:00
a4be9ceb5a dont insert/update creation time. Let the database handle it with the default value 2018-09-04 16:08:26 -07:00
e21b6e1daf commit thread WIP 2018-09-04 16:05:34 -07:00
2e3b03fff9 members initialized 2018-09-04 14:51:35 -07:00
cd657da431 Online Update/Notify thread 2018-09-04 14:00:02 -07:00
17af09a5cc Postgres Integration has begun 2018-08-31 14:58:15 -07:00
ceff48b07c Update bug_report.md 2018-08-29 10:15:10 -07:00
199566965e Update issue templates 2018-08-29 09:39:18 -07:00
46e46e9b7b Update issue templates 2018-08-29 09:37:39 -07:00
8b292d2dc7 ext: update nlohmann/json to v3.2.0
- include libc++7 compatibility for FreeBSD
- see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230629
2018-08-24 08:19:38 +00:00
88abd6ffc6 add support for debug flags in FreeBSD 2018-08-24 08:18:25 +00:00
76b4ec12a0 Vault-related amendments 2018-08-09 14:32:26 -07:00
0e4cfd897b Multipath-related amendments from merge into edge 2018-08-09 13:40:49 -07:00
515d7962b0 Build fixes. 2018-08-09 11:39:42 -07:00
553101e8b5 merge dev 2018-08-09 11:31:37 -07:00
3cd0ab1b3b Remove direct include of bits/sockaddr.h 2018-08-03 16:20:08 -07:00
fc6dba0797 Add functionality to erase members from networks using file backend in controller microservice
Signed-off-by: Diego Schulz <dschulz@gmail.com>
2018-08-02 17:13:55 -04:00
e01c0adff2 Added ifdef checks to omit some ManagedRoute code in SDK builds 2018-08-01 17:17:04 -07:00
e75a093a8c 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-07-27 14:14:09 -07:00
dcffb042ff Windows Advanced Installer to 1.2.12 2018-07-27 13:35:20 -07:00
d724af6a99 Replace Sao Paolo root with Buenos Aires in default planet def (will push to network too) 2018-07-25 15:03:01 -07:00
b30f423fc9 . 2018-07-25 12:11:59 -07:00
1fc14292fe Version bumps. 2018-07-25 12:09:31 -07:00
fa7e7fc6f9 Revert fix for GitHub issue #600 because it causes route objects to build up forever (at least on Mac). Bleh. #600 is a rare issue and will need some other fix after reliable duplication. 2018-07-20 15:53:19 -07:00
5b114791e5 Fix a bug that caused a crash on empty HTTP requests (localhost only) and add a lightweight lock to the RX queue to prevent possible threads stepping on each other in parallel receive paths. 2018-07-20 14:01:58 -07:00
9bc11a369c Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-07-20 07:41:52 -07:00
ac40f2191c . 2018-07-20 07:41:47 -07:00
62a93c58fd Added ifdefs surrounding usage of getifaddrs() on Android 2018-07-19 17:50:10 -07:00
65b0030342 Added basic QoS rule handling 2018-07-11 16:55:13 -07:00
f302fac423 Minor tweak to linux makefile 2018-07-11 16:32:49 -07:00
f94aea8119 Return error 503 if RethinkDB is down when built as RethinkDB-based controller. 2018-07-11 10:42:31 -07:00
28cb40529d Rough draft of fq-codel implementation 2018-07-10 16:50:12 -07:00
37ae3b2b80 Remote debug printf. 2018-07-03 12:52:35 -07:00
73e4286fbf Fix two controller bugs: filesystem bug and another possible infinite recursion bug. 2018-07-03 12:51:41 -07:00
4e6151ebd9 Added "Create and Join Network" menu item to windows system tray UI 2018-06-28 15:24:45 -07:00
fc225401a5 use easy mode for network creation 2018-06-28 15:05:24 -07:00
d74817f79f Added blurb about allowTcpFallbackRelay to README 2018-06-22 16:46:50 -07:00
bdcdccfcc3 Improved path selection, more efficient traffic allocation, lower QoS/ACK overhead 2018-06-22 16:30:20 -07:00
352ec3430f Add a define to set FD_SETSIZE=1024 on Windows
Default on Windows is extremely low at 64 and is the likely culprit behind the UI and CLI not being able to talk to the background service
2018-06-21 12:11:10 -07:00
978d2fcb56 Optimize C25519 and Poly1305 on Windows even in debug. 2018-06-21 12:08:15 -07:00
52264d5e28 Fixed aggregateLinkLatency(). Also changed unit for throughput from byte to bit 2018-06-14 16:48:35 -07:00
17fbb020e7 Added multipath field to zerotier-cli status output. Adjusted how path estimates are computed and cached 2018-06-14 16:34:45 -07:00
f8005b88ad Minor cleanup. More efficient push() operation for RingBuffer 2018-06-13 14:50:37 -07:00
0faa655b83 Reduced how often relative path qualities and aggregate link allocations are computed 2018-06-12 16:30:46 -07:00
6fddf31db3 Improved rate limit logic for QoS/ACK packets. Also reduced how often processBackgroundPathMeasurements() is called 2018-06-12 15:24:12 -07:00
01257a461e Merge branch 'dev' of github.com:zerotier/ZeroTierOne into dev 2018-06-12 09:39:15 -07:00
817b9d012e Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-06-12 09:38:52 -07:00
04b3525e0f Merge pull request #755 from skunkwerks/fix/c++-17-deprecation
fix clang C++17 deprecation when building with ZT_DEBUG=1
2018-06-12 09:38:26 -07:00
d55c732e19 Merge pull request #764 from Elfe/master
fix MAC address rule parsing as even/uneven switches at every colon
2018-06-12 09:37:28 -07:00
d223427e22 Merge pull request #773 from alexforencich/master
Add UFW firewall application preset
2018-06-12 09:37:01 -07:00
64856adc3c Merge pull request #776 from Wykks/patch-1
Improve debian service requirements
2018-06-12 09:36:46 -07:00
7c53adbcfe quieting things down unless ZT_TRACE is defined 2018-06-11 10:47:58 -07:00
dce9cb27c1 helps to have an ==0 on a strcmp 2018-06-11 09:53:11 -07:00
4199c56e99 cant compare character arrays with == 2018-06-11 09:53:00 -07:00
9681fedbb4 Spellcheck sweep across codebase 2018-06-07 17:25:27 -07:00
b6d97af451 Added rate gates for QOS and ACK packets 2018-06-07 15:26:18 -07:00
a9ca26c698 Added TX queue cap for issue #769 2018-06-07 12:58:07 -07:00
9463d4abe4 Fix for issue #778
Double quote before member name in `/controller/network/network_id/member` API
2018-06-05 12:55:39 -07:00
b9975845ff Merge branch 'rtnetlink' into edge 2018-06-04 12:24:58 -07:00
b22405b64b rtnetlink integrated. no more callouts to iproute2 2018-06-04 12:24:12 -07:00
62210e57f1 helps to have an ==0 on a strcmp 2018-06-04 11:24:24 -07:00
4dd093efc9 cant compare character arrays with == 2018-06-04 11:07:12 -07:00
91a22a686a Added auto-escalation to multipath if both peers support it. Improved QoS/ACK tracking. Related bug fixes 2018-06-01 18:03:59 -07:00
a307dff3b7 Improve debian service requirements 2018-05-31 23:55:36 +02:00
20f0bed2f6 Add UFW firewall application preset 2018-05-30 19:10:51 -07:00
46a7a2be2e Added VERB_ACK and VERB_QOS_MEASUREMENT, refined notion of path quality 2018-05-30 17:45:29 -07:00
8199dbd0dc Merge branch 'dev' into edge 2018-05-30 11:19:12 -07:00
dfe426e4e0 fix MAC address rule parsing as even/uneven switches at every colon 2018-05-26 21:00:09 +02:00
3ace61ef85 comment out addInterface/removeInterface code for now
We already have ioctl based code to do this
2018-05-25 15:37:00 -07:00
442595d6fc also store binary representation of mac address in the interface lookup table for later use 2018-05-25 14:25:44 -07:00
be469f4dd0 add/remove routes via rtnetlink 2018-05-25 14:18:06 -07:00
7da4b0af15 better data localization in LinuxNetLink now that I know what Im doing 2018-05-24 16:15:03 -07:00
2fff651378 whoops. committed a binary 2018-05-24 16:14:32 -07:00
c24d16e62e ManagedRoute uses ioctl to add/remove routes on Linux
Added LinuxNetLink to talk to the rtnetlink socket for adding interfaces, addresses routes.  Not yet complete.  Can currently monitor changes on the system.
2018-05-24 15:22:11 -07:00
c36c92e077 node: remove deprecated register hint for C++17 compatibility
when building with `ZT_DEBUG=1` this hint produces a warning:

> node/Packet.cpp:335:43: error: 'register' storage class specifier is deprecated and incompatible with C++17 [-Werror,-Wdeprecated-register]
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4340
2018-05-18 09:09:27 +00:00
c0efba79c7 Merge branch 'dev' of http://git.int.zerotier.com/zerotier/ZeroTierOne into dev 2018-05-11 13:40:22 -07:00
5809941ae9 Windows 1.2.10 2018-05-11 13:40:03 -07:00
535ba8a207 Consolidated powerpc64le machine types, added 32-bit powerpc machine type and a flag to disable use of Linux capabilities 2018-05-09 13:51:32 -07:00
43331d3fe8 Merge branch 'master' into dev 2018-05-09 10:31:19 -07:00
9765ba334a 1.2.10 2018-05-08 13:07:20 -07:00
0cd01b6ff8 Fix silly bug where moons and networks were being loaded by the address of an array rather than the proper value. 2018-05-07 12:51:39 -07:00
5f85e33510 GitHub issue #734 (warning removal) 2018-05-07 12:15:55 -07:00
22301a4599 Added override directive to CFLAGS for Synology builds in make-linux.mk 2018-05-04 14:31:34 -07:00
c8a907fd71 Added override directive to CXXFLAGS for Synology builds in make-linux.mk 2018-05-04 13:03:52 -07:00
d01b1ffde5 Added -fPIC for Synology builds 2018-05-04 12:09:04 -07:00
f4e993c814 Debian clean fix and CentOS 6 upgrade fix. 2018-05-03 12:51:49 -07:00
91c8e82c42 Adjusted locking order of _paths_m for path pruning. Other minor multipath changes 2018-05-02 15:24:14 -07:00
776ff46db7 User useradd not adduser on Debian. 2018-05-02 14:12:10 -07:00
9001ab5858 Do not add zerotier-one user if it does not exist (Debian) 2018-05-02 14:08:42 -07:00
1debe2292d Cleanup. Misc type conversion and signedness fixes 2018-05-02 11:22:07 -07:00
6a2ba4baca Introduced basic multipath support 2018-05-01 16:32:15 -07:00
836d897aec Re-ordered local.conf and node init logic, also split software update config into separate method to fix bad node pointer reference 2018-05-01 13:39:06 -07:00
740b0fbbf6 Merge branch 'dev' into edge 2018-04-30 13:08:24 -07:00
92e716d93d Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-04-30 13:08:16 -07:00
c7115a0671 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2018-04-30 13:07:52 -07:00
020bbed935 ARM32 fix. 2018-04-30 13:07:32 -07:00
0c60963a94 app icon with no alpha channel 2018-04-30 12:08:09 -07:00
d704f5f2d2 Remove alpha channel from app store icon 2018-04-30 12:06:41 -07:00
381bbb0e5e Merge branch 'dev' into edge 2018-04-30 08:47:51 -07:00
0ebd19c14a Merge branch 'dev' of /media/psf/Code/ZeroTier/ZeroTierOne into dev 2018-04-27 20:49:46 -07:00
d4160afac8 Another squeeze fix to see if we can make this work. 2018-04-27 19:51:27 -07:00
fffb037873 Fix for packaging on old Debian squeeze. 2018-04-27 18:53:55 -07:00
1df5d0453d Remove separate dh-systemd dependency since this is obsolete on newer Debian anyway. 2018-04-27 18:50:40 -07:00
19d453cb90 Add some more icon sizes
20x20, 60x60, 1024x1024 pngs
getting ready for an iOS release
2018-04-27 16:48:34 -07:00
6e7437a0d0 Add some more icon sizes
20x20, 60x60, 1024x1024 pngs
getting ready for an iOS release
2018-04-27 16:40:36 -07:00
caf849fcba Typo. 2018-04-27 16:22:36 -07:00
7533d244a9 Debian build fix. 2018-04-27 16:21:22 -07:00
0a52840fa3 1.2.8 Windows Advanced Installer update. 2018-04-27 13:52:33 -07:00
a7d0905b74 1.2.8 bump for all but Windows install files. 2018-04-27 13:06:00 -07:00
05bfafbce8 Merge branch 'master' into edge 2018-04-25 06:41:44 -07:00
d32a26f780 Merge pull request #428 from danielskowronski/netbsd-support
NetBSD support (we still consider this unsupported, but it might work -- thanks!)
2018-04-25 06:39:37 -07:00
42ec780a6f Merge branch 'dev' into netbsd-support 2018-04-25 06:39:02 -07:00
4608880fb0 Re-enable faster ed25519 signatures on x64 thanks to PR from @jonathonf 2018-04-25 06:34:34 -07:00
7492e2789f Merge pull request #722 from jonathonf/dev
Fix ed25519-amd64-asm PIC compatibility
2018-04-25 06:08:12 -07:00
9564a8eaf6 Delete junk. 2018-04-23 14:56:22 -07:00
f12c0e79c9 GitHub issue #723 2018-04-23 14:11:26 -07:00
e4e0be979e Fix ed25519-amd64-asm PIC compatibility
The Hyperledger implementation (https://github.com/hyperledger/iroha-ed25519)
contains changes to the assembly code to allow PIC. This in turn fixes
compilation/linking of ZeroTier One when "full hardening" flags are used.
2018-04-21 16:18:00 +01:00
86637cda9f Disable ASM ed25519 by default (it only helps significantly on controllers) so fPIE will work -- GitHub issue #717 2018-04-20 11:35:50 -07:00
94f41e2332 Merge branch 'dev' of github.com:zerotier/ZeroTierOne into dev 2018-04-18 08:08:06 -07:00
3d2a50f811 Merge pull request #654 from atopuzov/armv7l
Add support for armv7l
2018-04-18 08:06:53 -07:00
c2ffbb8627 Merge pull request #673 from neutronscott/dev
check physical blacklist for interface binding as well
2018-04-18 08:05:51 -07:00
54218f6c3c Merge pull request #690 from Pablohn26/master
Warn about invalid network id instead of help
2018-04-18 08:05:28 -07:00
6fdbdf9272 Merge pull request #712 from elmar/master
fix typo in documentation
2018-04-18 08:04:19 -07:00
3de7691af3 Merge branch 'master' of github.com:zerotier/ZeroTierOne
* 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 driectly 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.
2018-04-17 13:32:39 -07:00
bbed93bcf4 * 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 driectly 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.
2018-04-17 13:30:37 -07:00
8900b30b6e Windows installer tweaks and version bumps. 2018-04-17 12:47:33 -07:00
ae4fb799e4 More versioning 2018-04-17 12:14:59 -07:00
3f1d1fb3c3 'versioning' 2018-04-17 12:12:49 -07:00
f0a23ae0ea docs 2018-04-17 10:48:00 -07:00
c14f9cc247 fix typo in documentation 2018-04-14 10:52:30 +02:00
e276b6463e Release notes, and shorten Linux canonical network ID derived device names a bit. 2018-04-12 10:33:06 -04:00
9da7967197 Merge branch 'dev' into edge 2018-04-12 09:08:48 -04:00
74f2b78c04 Refactor some potentially unsafe SharedPtr<> code. 2018-04-06 08:10:34 -07:00
2021f8cb5f Merge branch 'dev' into edge 2018-03-29 13:34:54 -07:00
40a9ebd078 GitHub issue #675 2018-03-29 10:44:57 -07:00
8c1b73b29c GitHub issue #701 2018-03-29 10:25:29 -07:00
6679a55693 certutil needs -f in case TrustedProvider store is not yet created 2018-03-27 19:15:14 -07:00
1101c1d919 Works on 32-bit too now. 2018-03-27 18:46:06 -07:00
fcb529b348 Take two on unattended driver installs. I think it works now.' 2018-03-27 17:53:28 -07:00
680b1ca208 Upgrade installer AIP versions and redo how we bundle the driver sub-installer to allow unattended driver installs (hopefully). 2018-03-27 14:19:45 -07:00
af74fe1711 Merge branch 'dev' into edge 2018-03-21 15:32:04 -07:00
494cf4049e Add specification of anchor and multicast hub address (optional) to new multicast and IPv4 enabled ad-hoc network ID format. 2018-03-21 15:31:48 -07:00
c908b9f67a Add anchor and multicast hub address field to new multicast enabled ad-hoc address format. 2018-03-21 15:27:26 -07:00
209f6d9d2d Merge branch 'dev' into edge 2018-03-19 11:18:54 -07:00
916077012e Make sure fopen is in binary mode on Windows. 2018-03-16 11:27:11 -07:00
beb170e4fb Use X64 ASM ed25519 signatures on Linux/x64, which are about 10X faster. Will matter a lot for network controllers, not so much for other things. 2018-03-13 06:51:17 -07:00
a59912f3af SHA512 using libcrypto (not enabled by default) 2018-03-12 16:56:47 -07:00
610e594a50 Speed tweaks for signatures, etc. 2018-03-12 16:16:20 -07:00
b4e2547052 Minor tweak to QNAP path getter 2018-03-12 11:23:10 -07:00
a9778549f2 Warn about invalid network id instead of help 2018-03-11 03:39:13 +01:00
b601041b5b Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2018-03-09 07:51:43 -08:00
0945d6ec0d Merge branch 'dev' into edge 2018-03-09 07:50:38 -08:00
78d9cee416 Other fixes to IPv4 ad-hoc networks. 2018-03-09 00:10:01 -08:00
bbdb2aa672 Some work on IPv4 enabled ad-hoc networks. 2018-03-08 23:53:57 -08:00
574b24c082 docs 2018-03-08 22:41:42 -08:00
874a187c7f cleanup 2018-03-08 22:39:51 -08:00
e8fb443313 Forgot one other use in RethinkDb driver. 2018-03-08 22:34:51 -08:00
57b96af2c4 Fix for FileDB _networkChanged / _memberChanged problem. 2018-03-08 22:33:08 -08:00
e61d4ab67a Merge branch 'dev' into edge 2018-02-23 13:58:24 -08:00
2ee358dbfc TAP driver requires input and output buffers for calls passed into DeviceIoControl
Otherwise the driver returns STATUS_INVALID_PARAMETER and the call fails.  This should fix some Multicast issues on Windows
2018-02-23 13:42:02 -08:00
e3bb67d188 Added debug output convenience macros 2018-02-16 16:55:31 -08:00
2d289a3308 Just a little cleanup 2018-02-16 15:20:07 -08:00
bdb2cc7c85 Linux: link system libcurl when compiling with ZT_VAULT_SUPPORT=1
Requires libcurl and development headers to be installed
2018-02-16 15:08:04 -08:00
7793060723 Add HashiCorp Vault storage of ZeroTier's public & secret identity
Adds a "vault" section to local.conf.  Example local.conf:

{
  "config": {
    "vault": {
      "vaultURL": "https://some.vault.host:8200",
      "vaultToken": "my-super-secret-vault-token",
      "vaultPath": "secure/place/to/put/identity"
    }
}

Additionally, the following environment variables can be set.  Environment variables override local.conf:

VAULT_ADDR
VAULT_TOKEN
VAULT_PATH

Identities will be placed in the keys "public" and "secret" under the user specified path.  If no path is specified, they will be placed in the token specific cubbyhole.

If identity.public and identity.secret exist on disk and vault is configured, they will be automatically added to Vault and removed from disk.

TODO:
 *  Decide behavior for if Vault cannot be reached.
 *  Add libcurl as a dependency in Linux & Mac builds
 *  Add libcurl as a requirement for linux packages
2018-02-16 14:30:27 -08:00
84302ae9c7 Add CURL libs to VC project 2018-02-16 14:21:38 -08:00
cd801b96fa libcurl binaries for Windows 2018-02-16 10:31:37 -08:00
5ff0653f9e Hooks into StateGet and StatePut for grabbing identity.secret from Vault 2018-02-16 10:18:10 -08:00
9574d635c1 Add Vault configuration option parsing to local.conf
{
   "settings": {
       ...
      "valut": {
         "vaultURL": "...",
         "vaultKey": "...",
         "vaultPath": "..."
      }
   }
}
2018-02-16 10:18:10 -08:00
1bec8ddce4 Better error messages when the ZeroTier service can't be contacted
Fixes #681
2018-02-13 16:41:21 -08:00
f9b07c63db Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-02-12 09:30:12 -08:00
8828fc7520 some JNI error checking 2018-02-12 09:29:44 -08:00
978d8fcd4a Merge branch 'dev' of http://10.187.63.16/zerotier/ZeroTierOne into dev 2018-02-09 06:35:09 +00:00
51aadcf901 A few fixes dicatated by valgrind. 2018-02-09 06:35:01 +00:00
db952a050a Added platform checks for Windows in OneService 2018-02-08 14:15:32 -08:00
f049740ae5 silence LOGV and LOGD in release builds for android 2018-02-07 15:53:23 -08:00
73ca9b6373 check physical blacklist for interface binding as well 2018-02-03 14:53:46 -05:00
c6949aad2d Linux build fix on some versions. 2018-02-02 17:11:23 -08:00
e57d0fdccc Update README.md
this ip changes sometimes
2018-02-02 10:30:49 -08:00
82f383be43 A few other make changes. 2018-02-01 15:58:58 -08:00
26aaf253ac Allow us to build a semi-dynamic official binary that works back to CentOS 6, at least on x64, and is very fast since we can build it with newer clang or icc. 2018-02-01 15:52:41 -08:00
51715376bf Use Intel icc if available on Linux. 2018-02-01 13:05:17 -08:00
ff95b0278c Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-02-01 12:46:40 -08:00
fe1fa20c6c Fix build on Intel C/C++ Compiler for Linux. 2018-02-01 12:46:35 -08:00
a867fe404b Omit pragma comment for ZT_SDK builds on Windows 2018-01-31 17:08:42 -08:00
d6e8a5f3ca Fix Windows compile error. 2018-01-30 16:07:41 -08:00
4878d8ec15 Add CAP_NET_BIND_SERVICE to capabilities 2018-01-30 10:47:31 -08:00
f7019d9e80 Tie up the rest of hub and spoke designated replicator multicast mode. 2018-01-26 22:14:10 -05:00
6d8e1e8783 More cleanup of old stuff. 2018-01-26 21:34:56 -05:00
939ab43ceb Do not send to origin in second buffered multicast path. 2018-01-26 21:22:51 -05:00
d3d58ba8a7 Add support for designated multicast replicators to Multicaster::send(). 2018-01-26 21:19:51 -05:00
f03fd57997 Clean up some multicast code. 2018-01-26 20:38:44 -05:00
e74cd4b4ef A little more cleanup. 2018-01-26 20:06:11 -05:00
f3dfd63634 Clean up some old stuff. 2018-01-26 20:00:37 -05:00
5f5302e595 More useful to allow arrays of IPs to bind to. 2018-01-25 17:27:08 -05:00
125ec622ca Add bindToWildcard local.conf option. 2018-01-25 14:59:11 -05:00
384e5b66de More work on GitHub issue #666 2018-01-25 14:16:07 -05:00
7e7723e98f A small memory use reduction. 2018-01-25 09:57:02 -05:00
4419734a7d Implement continuous contacting of designated anchors and multicast replicators - GitHub issue #666 2018-01-25 07:11:59 -05:00
f821db29f3 . 2018-01-24 17:12:53 -05:00
6c64f1816d cleanup 2018-01-24 16:16:00 -05:00
34e2ad0dfc Stub out NetworkConfig for GitHub issue #666 2018-01-24 14:43:04 -05:00
055b99c3cb cleanup 2018-01-12 15:44:27 -08:00
531842dc6b Update miniupnpc to latest version (included library) 2018-01-12 15:30:40 -08:00
d7f3c33d72 Add zerotier-idtool to Windows. 2018-01-12 15:03:45 -08:00
4e689998f9 Sanity checks on array sizes and fix a bug in IPv4 auto-assign. 2018-01-12 10:38:19 -08:00
cd2a4b709c Reduce maximum batcn size for status updates but increase the number of whole record commit threads. 2018-01-12 09:18:27 -08:00
d96aeac335 docs 2018-01-11 16:44:24 -08:00
c594351bcc Remove old code. 2018-01-11 14:32:55 -08:00
5f976d7430 Reenable faster lock. 2018-01-11 14:31:19 -08:00
f87326fc21 Fixes for lock ordering -- GitHub issue #573 2018-01-11 14:29:57 -08:00
0574a70fac docs 2018-01-11 09:49:13 -08:00
4e79804cd3 cleanup 2018-01-10 16:56:39 -08:00
86d5264167 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-01-10 16:55:15 -08:00
5bc4399a58 cleanup 2018-01-10 16:55:07 -08:00
406bcf7d3f Fix compilation on Windows
DEBUG macro from miniupnpc interferring with enum Trace::DEBUG;
2018-01-10 15:24:54 -08:00
f17cc1c6d8 cleanup 2018-01-10 15:03:39 -08:00
57077e4607 Added (get) command blurb in cli help 2018-01-10 14:40:31 -08:00
6304c85d3f Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-01-10 14:31:31 -08:00
a1992d76f2 Doc updates and other fixes. 2018-01-10 14:31:28 -08:00
98b07f7f3c Added (get) command to cli to single out JSON fields 2018-01-10 14:05:28 -08:00
6e1823ac81 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-01-10 12:43:18 -08:00
640cc22749 Added allowTcpFallbackRelay to local.conf, fixed logic in Binder's route enumeration 2018-01-10 12:41:52 -08:00
9bab49d2f9 Move DB stuff into Db. 2018-01-09 12:39:25 -08:00
2751a6d56d cleanup 2018-01-09 12:31:00 -08:00
07cb62a503 cleanup 2018-01-09 11:41:26 -08:00
8a3b698407 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-01-09 11:23:44 -08:00
0c71d658fb cleanup 2018-01-09 11:23:39 -08:00
7e2d614975 Attempted fix for ticket #656 (failes to acknowledge physical blacklists) 2018-01-09 10:16:49 -08:00
09e4ab9aa1 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2018-01-09 10:00:01 -08:00
2e1bc6e500 Cleaned up old code for attempted fix for ticket #600 2018-01-09 09:59:55 -08:00
1aea096b63 GitHub issue #492 2018-01-09 09:05:22 -08:00
30694f0b20 Allow trusted paths over global IPs for legacy config format too. 2018-01-09 08:59:26 -08:00
01b4cb64ee cleanup 2018-01-09 08:35:02 -08:00
6fbd15f8b2 cleanup 2018-01-08 15:56:53 -08:00
65c07afe05 Copyright updates for 2018. 2018-01-08 14:33:28 -08:00
e338c5f91d cleanup 2018-01-08 14:27:55 -08:00
0b0b5da240 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2018-01-08 13:06:30 -08:00
9c7ee5a21e Tear out old "link quality" stuff since it is not currently used and will be done differently. 2018-01-08 13:06:24 -08:00
f7b3ffe8a0 Commented out block which ignores added routes if there already exists an IP in the route's range. Attempted fix for #600 2018-01-05 17:10:59 -08:00
381857ea49 macOS: add libcurl to libraries when ZT_VAULT_SUPPORT=1 is specified on the make command line 2018-01-03 11:56:20 -08:00
50aef368f6 Add support for armv7l
* GCC running on Raspberry Pi 3 on Arch linux ARM reports arch as
  armv7l-unknown-linux-gnueabihf
2018-01-02 11:32:17 +01:00
a9c4ce38f0 eh 2017-12-18 15:07:58 -08:00
bbc39d7648 Restore managed ZT routes that are deleted or otherwise mangled locally (Attempted fix for ticket #600) 2017-12-18 15:05:19 -08:00
d3e8e9629b More optimization work. 2017-12-15 14:24:17 -08:00
1f0b3a32d5 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-12-15 11:03:27 -08:00
0608704626 Some micro-optimizations, including a memcpy that is faster than Linux for most distro/compiler versions. 2017-12-15 11:03:20 -08:00
cb8e7b4d5e Make UDP read loop eventually move on. 2017-12-15 10:15:13 -08:00
346fa4d7f4 Added ZT_SANITIZE option to makefiles. This your new memory debugging best friend 2017-12-14 13:27:49 -08:00
7a22f01dd8 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-12-14 08:53:32 -08:00
4704d115c4 Some controller fixes. 2017-12-14 08:53:24 -08:00
12c621c230 Removed build flag in CMake script 2017-12-13 14:57:20 -08:00
cba65d897a Added CMake build script for libzerotiercore.a 2017-12-13 14:55:17 -08:00
e4a10cc510 Member commit bug fix. 2017-12-08 19:00:38 -05:00
249c27afd5 Fix old bug invoking idtool personality with -i 2017-12-08 11:17:07 -08:00
38cc89b2ca Add time to rethinkdb message output in controller. 2017-12-08 12:39:20 -05:00
aeb1794be1 Comment out storage of secret ID in RethinkDb. 2017-12-07 16:04:41 -08:00
dae728124e Fix to network path in conventional filesystem controller DB. 2017-12-07 14:42:33 -08:00
cf30b1fcdf GitHub issue #589 2017-12-07 17:13:24 -05:00
19bfef36f1 Build fix. 2017-12-07 16:45:43 -05:00
8d9464c414 docs, and make RethinkDB controller DB driver upsert into the Controller DB and also update the hostname field. 2017-12-07 13:39:25 -08:00
ada611d597 Go ahead and load kext so MacOS High Sierra users will see kext auth dialog right away. 2017-12-07 08:56:15 -08:00
f13886d343 Warning removal. 2017-12-05 17:53:28 -05:00
520b0601db Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-12-05 14:51:06 -08:00
926ecf9640 docs 2017-12-05 14:50:59 -08:00
c57198decd Add remoteTraceLevel to controller. 2017-12-05 17:49:20 -05:00
431716e249 Disable trace by default, stderr message improvements in RethinkDB driver. 2017-12-05 17:16:45 -05:00
694709f392 Add timestamp to network status. 2017-12-04 19:21:56 -05:00
16613ab5fb Clean up remote tracing code, add per-network remote trace settings, add remote trace level, and make local trace output readable again. 2017-12-04 14:40:10 -08:00
c26bf45e28 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-11-29 04:47:16 -08:00
23e5c7b38d Fix self-test compile. 2017-11-29 04:47:10 -08:00
382dd82eb6 Fix for local.conf virtual path blacklist (ticket #594) 2017-11-27 15:31:25 -08:00
f18d5b2efe Attempted fix for github issue #597, leaking sockets. Added call to closenatpmp() after failure to init 2017-11-27 14:23:55 -08:00
0fb22df633 Get ephemeral status fields out of the configs. They do not belong there and it just complicates things. 2017-11-09 17:01:16 -05:00
750e36993f GitHub issue #617 2017-11-09 11:35:46 -05:00
f7f658605d Move more ephemeral stuff to a tiny MemberLastRequest table instead of the main Member table. 2017-11-08 20:19:46 -05:00
192e5dbff8 Another fix for uptime logging. 2017-11-08 20:02:10 -05:00
ef224c3547 RethinkDB build fix. 2017-11-08 19:52:36 -05:00
c12b68a6b2 More Central work. 2017-11-08 11:32:01 -08:00
4166d8ca35 Fix a deadlock and some more work on RethinkDB (for central) integration. 2017-11-08 11:06:14 -08:00
53e7e950f1 Windows build fixes. 2017-11-07 16:39:12 -08:00
0612879dec Fix const. 2017-11-07 16:23:56 -08:00
3b21f946e4 Remove manual define of include rethinkdb driver symbol. 2017-11-07 16:18:48 -08:00
9f85371073 cleanup 2017-11-07 15:23:16 -08:00
cb550ab4fe Merge branch 'dev' into edge 2017-11-07 14:59:18 -08:00
b8cbf08617 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-11-07 14:59:03 -08:00
1613f42d00 Re-integrate in-filesystem DB into new controller DB structure. 2017-11-07 14:44:46 -08:00
e5d1243dd2 Minor changes to SDK-related portions of OneService 2017-11-06 13:43:56 -08:00
7fc9094d8e More fixes to RethinkDB. 2017-11-03 22:40:26 -04:00
92c7070aa8 RethinkDB fixes. 2017-11-03 20:55:16 -04:00
b68bca35db Linux build fixes, linux build rule for RethinkDB mode controller, also force disable shitty allocators in libstdc++. 2017-11-03 16:59:36 -04:00
d97adc8789 Preparing for test. 2017-11-03 12:32:56 -07:00
f5014d7d71 RethinkDB direct connectivity integration. 2017-11-03 11:39:27 -07:00
4e88c80a22 RethinkDB native connector work, minor fixes. 2017-11-02 07:05:11 -07:00
a6203ed038 icon 2017-10-29 12:01:15 -07:00
1db547d607 Windows build fixes, AIP file update. 2017-10-25 16:25:57 -07:00
2cc4dc5a6f Clean peers.d periodically and delete peers older than 30 days. 2017-10-25 16:08:14 -07:00
fac7dc9c91 Stop duplciate IPv6 addresses due to privacy mode IPs. 2017-10-25 16:01:36 -07:00
508fa6a7fe A few fixes for cluster mode. 2017-10-25 15:44:10 -07:00
71bdaa9508 Now with more worky. 2017-10-25 13:27:28 -07:00
459f1e7bfb Refactor path stability stuff and add basic multipath support. 2017-10-25 12:42:14 -07:00
0d8b8d8426 Remove some unused constants. 2017-10-24 15:04:19 -07:00
2d0dc62a53 docs 2017-10-24 14:57:02 -07:00
0d8e134f9f Warning removal. 2017-10-24 14:54:15 -07:00
c7d370c17f Delete something that turns out not to be useful. This will be handled differently. 2017-10-24 14:49:38 -07:00
395d8b3139 Full and clearer implementation of GitHub issue #588 2017-10-24 13:33:53 -07:00
b92ef67e56 Merge pull request #550 from surgicalcoder/patch-2
Peer's role misses a PLANET role
2017-10-24 12:22:38 -07:00
5a8aa66641 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-10-24 12:22:02 -07:00
e87ef18826 cleanup 2017-10-24 12:21:56 -07:00
7b78d4f11f Merge pull request #605 from oneguynick/patch-1
Update make-linux.mk to include support for Armv7l
2017-10-24 12:21:32 -07:00
65ac61b2ea Update make-linux.mk to include support for Armv7l
When running ArchlinuxARM with 64bit support on Raspberry Pi3, the default build fails due to the architecture look-up at the beginning of the build process. A simple addition of the Armv7l section above allows the build to continue and successfully run.
2017-10-19 09:21:24 -04:00
629a3a2a24 call setFriendlyName() after tap adapter is initialized 2017-10-16 12:16:05 -07:00
ee4783e3fb ifdef omit of deletePersistentTapDevice() in OneService for libzt builds on Windows 2017-10-10 15:01:15 -07:00
f2c69ede96 Conditionally omit reference to CancelSynchronousIo in Thread.hp when MINGW32/64 is detected for libzt build - Symbol not supported 2017-10-10 12:21:52 -07:00
ceeb35eaac If lastSend/lastReceive is < 0, just put 0. 2017-10-05 13:19:25 -07:00
099bedd2e9 A few more uint64_t -> int64_t changes for timestamps 2017-10-04 12:01:17 -07:00
4177a11522 remove some leftover debug code 2017-10-04 09:18:13 -07:00
3d4a1b575e Update Android NDK with uint64_t -> int64_t changes 2017-10-03 11:25:26 -07:00
b1d60df44c timestamps changed from uint64_t to int64_t
There were cases in the code where time calculations and comparisons were overflowing and causing connection instability.  This will keep time calculations within expected ranges.
2017-10-02 15:52:57 -07:00
7cf70d111a Return an explicit NULL shared pointer at the end of Topology::getPeer() 2017-09-28 10:40:27 -07:00
e564c56dce Set size of buffer after setting data with unsafeData() call 2017-09-28 10:39:43 -07:00
239c2540d6 Mutex::lock and ::unlock just called themselves 2017-09-27 15:05:13 -07:00
c53d140145 Replace '_' with '__' in network names on toolbar menu in Windows
Otherwise WPF gobbles up the underscores
2017-09-27 13:24:29 -07:00
12a6a2f2d2 remove reference to invalid file 2017-09-27 13:07:24 -07:00
9c903567bb Hashtable needs to include Constants.hpp for ZT_EXCEPTION_OUT_OF_MEMORY 2017-09-25 13:42:19 -07:00
6782dee64a Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2017-09-25 10:10:17 -07:00
302c15140e Fix API problem with path configuration.. 2017-09-25 08:53:55 -07:00
c666f92e35 new startup process UI for Windows 2017-09-22 15:33:09 -07:00
eb42ef68ee Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2017-09-22 10:22:22 -07:00
52916eebcf Keep attemting to upgrade direct path if path is not private to facilitate better use of LANs and backplane networks. 2017-09-14 20:56:50 -07:00
f8014413a3 Add UDP MTU configurability. 2017-09-01 16:25:34 -07:00
2d858b05ac Another fix for ye old tyme clients. 2017-09-01 12:03:31 -07:00
b1fb020aea Raise chunk size to max packet size for network configs. Chunking breaks really ancient clients, so this helps them live a little longer. No real downside for new clients. 2017-09-01 10:43:44 -07:00
02ed84774c Non-x86 build fix. 2017-08-31 20:47:44 -04:00
283e8d5bc0 Start threads in Central harnessed mode. 2017-08-31 18:01:21 -04:00
f39e2e2a53 Fixed typo of mysterious origin 2017-08-31 11:37:29 -07:00
5bf5d5e9cb Minor controller stuff. 2017-08-30 17:22:25 -07:00
e51e212b95 Add some defines of use to low level developers. 2017-08-25 16:04:04 -07:00
6418d02572 Fix HTTP DELETE stupid bug. 2017-08-24 15:33:24 -07:00
49fa30d495 Ticket lock for x64/gcc/clang platforms. 2017-08-23 18:52:32 -07:00
dd8b03a5c5 Threading issue fix? 2017-08-23 18:28:40 -07:00
4d5983114c Fix another deadlock. 2017-08-23 17:14:06 -07:00
0a9c3b5571 Fix possible deadlock. 2017-08-23 16:59:31 -07:00
180049a277 Fix pointer bug. 2017-08-23 16:55:22 -07:00
6ee201865b Clean up WHOIS code. 2017-08-23 16:42:17 -07:00
b1d94c9f93 Performance improvement to RX queue ring buffer. 2017-08-23 15:19:26 -07:00
a156a4dbe2 Symmetric NAT cleanup. 2017-08-23 15:12:00 -07:00
2cebe7a5e0 Fix name difference. 2017-08-23 14:09:29 -07:00
9cfc109527 Tighten a few timings. 2017-08-23 14:00:08 -07:00
64758c46b6 Implement peer serialization and deserialization. 2017-08-23 13:40:51 -07:00
4352202349 Reduce TCP relay latency -- see GitHub issue #564 2017-08-18 14:54:10 -07:00
ba07a60c44 Fix PPC PR. 2017-08-18 14:40:10 -07:00
72bfe0953a Merge pull request #560 from andyfangdz/patch-1
Add `ppc64le` arch
2017-08-18 14:38:41 -07:00
bab5647522 Add make rule for official-static. 2017-08-18 14:00:35 -07:00
fcaf1d89c2 Get rid of some noisy remote traces that should not be needed. 2017-08-18 13:59:22 -07:00
106dff0d53 Make remote trace target null by default, which is probably what we want. 2017-08-18 13:52:10 -07:00
174ba8884e Delete support in harnessed mode. 2017-08-17 13:10:10 -07:00
1ce0dcf0ea Another Central harnessed mode fix. 2017-08-16 14:41:42 -07:00
1387e15c1b Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-08-16 14:14:56 -07:00
50e7ea088b More work on controller for new Central harnessed mode, remove old http mode. 2017-08-16 14:14:49 -07:00
59b7cbb591 Rename SocketTap to VirtualTap to prevent confusion on role 2017-08-15 16:22:28 -07:00
23fe8975e7 . 2017-08-14 11:44:07 -07:00
a4bc40542b GCC/G++ build fixes, GitHub issue #563 2017-08-14 11:43:39 -07:00
ee1dc16e8f Added getRoutes() for libzt 2017-08-10 00:59:15 -07:00
1c04cc0485 . 2017-08-09 17:42:35 -07:00
2c682b4d1c Small controller revisions, first run of controller API model JavaScript. 2017-08-09 14:37:19 -07:00
6842490c1f Add menu option to open ZeroTier Central in the system default browser 2017-08-09 14:19:37 -07:00
ff5e22031a Small fix: should expire packets to prevent repeated WHOISes. 2017-08-08 13:24:37 -07:00
e3cf756785 Make rxQueue lock-free using an atomic counter ring buffer. 2017-08-08 13:21:10 -07:00
7e6598e9ca Possible deadlock fix. 2017-08-07 14:13:08 -07:00
48d2017629 Add ppc64le arch
I've only tested locally, on a power8 box running Ubuntu 16.10, but everything (and earth) checks out.

Let me know if more testing infrastructure is needed.
2017-08-06 02:06:00 -07:00
e4823381c6 . 2017-07-19 15:16:15 -07:00
66feaeb519 . 2017-07-19 15:06:23 -07:00
8c6b833fb3 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-07-19 14:13:23 -07:00
b62296a40b Bug fixes in new harness mode. 2017-07-19 14:13:17 -07:00
fc7728212f Fix ifndef on Windows 2017-07-18 15:59:11 -07:00
31785f7f6e Automatic periodic status dump from controller. 2017-07-18 15:36:33 -07:00
ae65eb5105 Cleanup and replace trace field names with sane ones because usability > a few bytes. 2017-07-18 14:28:38 -07:00
727ccb1125 Cleanup and stdin/stdout harness mode for controller. 2017-07-18 13:57:37 -07:00
77ce238457 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-07-17 17:02:57 -07:00
1685659e37 Remote tracing works. 2017-07-17 17:02:50 -07:00
0f03d4ef51 Update Jenkinsfile for new NDK in Jenkins 2017-07-17 16:55:00 -07:00
bcf697cc2b Wire up PortMapper in Android
Enables UPnP port mapping for Android client on networks with UPnP routers
2017-07-17 16:16:25 -07:00
5e2ea4a81a Cleanup. 2017-07-17 14:24:57 -07:00
b9e1d53d7a Minor cleanup. 2017-07-17 14:21:09 -07:00
ab0806a036 Cleanup. 2017-07-17 13:48:39 -07:00
3a1ec07db0 Remove some exception copypasta. 2017-07-17 10:43:28 -07:00
d939d8d21d A bit more remote tracing stuff. 2017-07-14 14:57:40 -07:00
d9552fb120 Add remoteTraceTarget to network and member configs in controller. 2017-07-14 14:33:36 -07:00
4ecc0c59ca Plumbing through of remote trace into controller code. 2017-07-14 13:03:16 -07:00
0655a1fcbe Move old cluster code into attic. 2017-07-13 16:42:43 -07:00
c8d0cf2c40 Merge branch 'dev' of github.com:zerotier/ZeroTierOne into dev 2017-07-13 16:31:30 -07:00
c692f2e740 Fix for new identity generation bug. 2017-07-13 16:31:16 -07:00
a83c7c0d07 remove debugging flag 2017-07-13 15:13:20 -07:00
ba6fd16823 More tracing stuff. 2017-07-13 15:08:57 -07:00
54893c35c1 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-07-13 10:51:19 -07:00
495c5ce81d Bunch of remote tracing work. 2017-07-13 10:51:05 -07:00
4cc773ec1b fix Windows build 2017-07-12 13:52:45 -07:00
69ae35494e put the correct file extensions on data written to disk in JNI 2017-07-12 13:36:22 -07:00
512c3af4ea fix packet sending functions 2017-07-12 13:12:45 -07:00
d8f1c3dff7 Update JNI code to reflect new ZeroTier API 2017-07-12 11:34:53 -07:00
0a11dd2d24 Fix NeighborDiscovery code now that ZT_SOCKADDR_NULL doesn’t exist 2017-07-11 15:45:36 -07:00
78ee7f6573 Peer's role misses a PLANET role
Peer's role misses a PLANET role in documentation vs what's returned from API.
2017-07-09 15:39:49 +01:00
dab0fb9e05 Remote trace: plumbing, replace old TRACE with calls to Trace object. 2017-07-07 16:58:05 -07:00
e14d5d49a1 Merge branch 'master' into dev 2017-07-07 09:36:54 -07:00
782b2b1514 Merge pull request #537 from laduke/patch-1
Update README.md
2017-07-07 09:32:37 -07:00
a9582417e2 Merge pull request #547 from surgicalcoder/patch-1
Clarification on how to use JSON API with secret
2017-07-07 09:32:23 -07:00
69922b6c39 BSD build fix. 2017-07-07 09:29:24 -07:00
6fc70f7c16 More cleanup, Linux build fixes. 2017-07-07 06:50:40 -07:00
a274e774ee Clarification on how to use JSON API with secret
Makes it clear on how to use the authtoken.secret file when making requests.
2017-07-07 10:11:21 +01:00
f23a43fb81 More cleanup. 2017-07-06 17:32:41 -07:00
88997a0314 Windows build fixes. 2017-07-06 16:29:11 -07:00
d2415dee00 Cleanup. 2017-07-06 16:11:11 -07:00
53728b79b4 . 2017-07-06 12:35:23 -07:00
dff8c02cfe Pull out and deprecate old cluster code. New cluster code will not be merged yet. 2017-07-06 12:33:00 -07:00
640ad577d1 . 2017-07-06 11:56:46 -07:00
cd63ecd3f3 . 2017-07-06 11:45:48 -07:00
f18158a52d . 2017-07-06 11:45:22 -07:00
84748aab51 Merge branch 'dev' into edge 2017-07-06 10:26:04 -07:00
3fadc64ee0 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-07-06 10:25:58 -07:00
47594f7c99 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2017-07-06 10:25:44 -07:00
2f20258807 . 2017-07-06 10:25:36 -07:00
47122a3804 Merge branch 'dev' into edge 2017-07-03 13:29:54 -07:00
1730f8f5b7 also cluster.hpp 2017-07-03 13:04:11 -07:00
d258a75cd3 remove Cluster.cpp from build list as it's been removed 2017-07-03 13:03:43 -07:00
baa10c2995 . 2017-06-30 17:32:07 -07:00
207d6572e0 fix for changelist posting to mattermost 2017-06-30 14:24:40 -07:00
10264cec2f slackSend -> mattermostSend 2017-06-30 13:43:39 -07:00
0ea1749c59 Merge pull request #540 from skunkwerks/master
build: all BSDs expect gmake here
2017-06-30 09:55:43 -07:00
dd83c680e5 build: all BSDs expect gmake here 2017-06-30 13:11:05 +00:00
1a40f35fd4 Merge branch 'dev' into edge 2017-06-27 11:32:14 -07:00
8a99113c88 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-06-27 11:32:07 -07:00
ada2ea3a6b Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2017-06-27 11:31:39 -07:00
355cce3938 Rename Utils::snprintf due to it being a #define on one platform. 2017-06-27 11:31:29 -07:00
9b2e08dd09 Update README.md
We've had multiple questions in the community chat regarding posting new
network and getting the curl syntax correct.
2017-06-26 11:53:35 -07:00
04cee3b8d3 Merge branch 'dev' of https://github.com/zerotier/ZeroTierOne into dev 2017-06-26 02:13:40 -07:00
c61440efea Detect platformDefaultHomePath on QNAP systems 2017-06-25 20:20:30 -07:00
02d18af57d Remove Cluster.hpp 2017-06-23 16:10:26 -07:00
2225bb093a Merge branch 'edge' into dev 2017-06-23 16:06:38 -07:00
75a6a7baca Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-06-23 16:05:58 -07:00
6b130e8311 fix for windows compilation (related to SDK implementation) 2017-06-21 14:58:39 -07:00
1b18923824 except wondows/lib 2017-06-13 14:25:53 -07:00
fc2ce439e2 remove unneeded files 2017-06-13 14:23:11 -07:00
5b3d9f9184 added Windows SDK in form of dlls 2017-06-13 13:28:23 -07:00
dd68c207f4 Stuff old Cluster code in attic. 2017-06-08 08:51:49 -07:00
9a3c34b5b3 Build fix, use -Os on Linux too. 2017-06-07 17:19:33 -07:00
951d911531 Last bit of new cluster code, ready to test. 2017-06-06 16:11:19 -07:00
4f2179b0df . 2017-06-05 13:42:43 -07:00
9b287392a4 . 2017-06-05 12:15:28 -07:00
aa06470cb6 More cleanup for cluster refactor. 2017-06-01 20:32:43 -07:00
d7b4f24a7a . 2017-06-01 17:21:57 -07:00
e8d11eb5c5 . 2017-06-01 17:21:04 -07:00
7f4da08ff7 . 2017-06-01 12:57:44 -07:00
1f9414a30f . 2017-06-01 12:38:04 -07:00
6015b529a0 More clustering work. 2017-06-01 12:33:05 -07:00
76452b4e28 Data structure fixup. 2017-06-01 07:39:31 -07:00
64b7d9ef82 New clustering work. 2017-06-01 07:15:46 -07:00
7bc9666aac fix for SDK's route/tap association in getTap() 2017-05-31 13:07:03 -07:00
2a4a50b1da Add some also-ZeroTier-written ext/ code for use in new clustering, delete some old code, and change Mac to use -Os which is just as fast as -Ofast and may be faster due to cache effects. 2017-05-31 08:36:09 -07:00
2ec88e8008 Remove old circuit test code. Rules engine will let us do this much better and more simply. 2017-05-30 10:19:45 -07:00
36049a940c added campaign tags to README.md 2017-05-25 17:09:21 -07:00
952834f7f3 Let Android Studio determine debug/release build 2017-05-23 14:56:29 -07:00
f9a9c2d009 Config object was never even being initialized on leave. Never noticed since desktop and server clients did not use. 2017-05-23 14:45:16 -07:00
fb71a6e2b4 skipRootCheck should also prevent dropping of privs on Linux 2017-05-19 16:16:10 -07:00
5e6a2a17b0 Cluster build fix. 2017-05-19 15:32:52 -07:00
92289c1981 Move to canonical device naming on Linux. 2017-05-19 15:18:47 -07:00
99e2098a48 Add a way to specify a different interface prefix (for internal use mostly). 2017-05-19 14:00:08 -07:00
5fc1c1de28 . 2017-05-19 13:24:40 -07:00
2fac693243 I guess there's a bug in Clipboard.SetText(). Clipboard.SetDataObject() works, though. 2017-05-12 16:42:54 -07:00
e9b956ed71 Swallow a possible ArgumentNullException when copying text to the system clipboard 2017-05-12 16:05:29 -07:00
236a952458 typo 2017-05-11 14:26:46 -07:00
426b7c2c76 Stupid bug is stupid. 2017-05-11 14:13:38 -07:00
22780a8504 Merge branch 'dev' of http://10.187.63.16/zerotier/ZeroTierOne into dev 2017-05-10 13:48:55 -07:00
a437fd420c version 2017-05-10 13:48:47 -07:00
2d74c60d47 Add branch hints to bounds checking in Buffer. 2017-05-09 21:54:23 -07:00
ceee56af51 Fix for small stacks. 2017-05-09 21:36:25 -07:00
d297d8fe2e Musl fix 2017-05-09 21:21:56 -07:00
f479b76772 define likely/unlikely 2017-05-09 20:22:08 -07:00
73f7088b45 Run Join/Leave commands asynchronously so the UI doesn't lock up on thoise commands 2017-05-08 16:17:33 -07:00
b3dd5c0e3a Build fix. 2017-05-08 14:51:12 -07:00
ee7ee22555 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-05-08 14:46:54 -07:00
cf49e511a5 More makefile changes. 2017-05-08 14:46:45 -07:00
505b9c7f56 Makefile reorg to allow core to be built as a library. 2017-05-08 14:36:55 -07:00
8c30b2b9f5 Fixed falling out of the network monitor thread if the ZeroTier service isn't running on Windows 2017-05-08 13:27:54 -07:00
b9c1407013 Adjust PUSH_DIRECT_PATH circuit breaker, and comment out traces to reduce noise. 2017-05-08 09:36:37 -07:00
d905607353 Small optimizations. 2017-05-08 08:35:55 -07:00
e5e90b1f71 Wire MTU through to service. 2017-05-04 20:10:49 -07:00
d5ed025871 Support MTU reconfigure for Windows. 2017-05-04 19:50:02 -07:00
b55422a528 MTU integration in taps. 2017-05-04 19:31:50 -07:00
909a14fb48 MTU support in controller. 2017-05-04 17:22:24 -07:00
107e3e4106 First pass of configurable MTU and max MTU increase. 2017-05-04 17:12:02 -07:00
6ef247fb93 More ARM stuff. 2017-05-04 16:00:53 -07:00
b8e46b835b Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-05-04 15:54:15 -07:00
0900fee5d9 Linux build stuff for ARM. 2017-05-04 15:54:08 -07:00
1f26cb98de updated OneService convenience functions for SDK 2017-05-04 15:26:44 -07:00
ceeb8ee0bc added isEqualPrefix to InetAddress 2017-05-04 15:25:48 -07:00
54c47a1e03 Add some historic code just for the heck of it. 2017-05-04 10:42:22 -07:00
6bb855873d GitHub issue #494 -- shut down and restart UI on Mac pkg install/upgrade. 2017-05-03 15:03:26 -07:00
39db45e144 Fix crash on exit (sometimes) in controller. 2017-05-03 09:48:08 -07:00
41c187ba12 Another very small crypto optimization. 2017-05-03 07:43:23 -07:00
d7c99728bc Echo back ping payload. 2017-05-02 17:28:18 -07:00
8e19188f49 Do the sometimes rather big "pong" in a background worker thread. 2017-05-02 16:58:51 -07:00
625e3e8e25 Tiny optimization to prealloc string space. 2017-05-02 13:53:47 -07:00
fde99e2fcf Fix for post size limit in Http library. 2017-05-02 12:08:53 -07:00
132643cd4a Fix small issue preventing pongs if there are never seen members. 2017-05-02 10:34:33 -07:00
faf7b81c01 Send last requets time in status, and do not set physicalAddr unless we know one. 2017-05-01 15:48:52 -07:00
bcc6799902 Send member uptime in pong posts. 2017-05-01 15:23:21 -07:00
718e1d6c08 Finish removing constantly changing stuff from controller. 2017-05-01 13:21:26 -07:00
a9ce773584 Remove lastModified field in config which literally nothing uses anywhere, and prevent some unnecessary writes. 2017-04-28 19:58:21 -07:00
d69bc4fb5e Main license file. 2017-04-27 20:54:42 -07:00
1b68d6dbdc License header update. 2017-04-27 20:47:25 -07:00
62578a2162 Reduce memory use and a bit of cleanup. 2017-04-27 19:36:03 -07:00
9e80db0fd1 Cleanup, fix a valgrind error, stack use reduction. 2017-04-27 00:59:36 -07:00
e8ab6adf89 Deadlock fix. 2017-04-26 12:17:43 -07:00
7c184cf991 Another performance improvement to controller. 2017-04-26 10:35:59 -07:00
72def658d0 Add a dummy Ethernet tap and a build option to enable it. 2017-04-26 08:42:49 -07:00
e7cd888c7d dev is now 1.2.5 2017-04-26 06:50:12 -07:00
1205578935 Big cleanup of controller code, should help performance. 2017-04-26 06:48:08 -07:00
4e77365e8d Remove a little cruft. 2017-04-25 16:17:54 -07:00
4f2a779769 JSONDB performance improvements, threading fix. 2017-04-24 20:51:02 -07:00
cafbe44dde Controller optimizations -- make locking more fine-grained, use true hardware concurrency, etc. 2017-04-24 19:16:36 -07:00
6234bfd8bf 4-core Debian build. 2017-04-24 18:40:34 -07:00
77796caba6 Static ARM32 build fixes. 2017-04-24 18:12:58 -07:00
97f1d7ae2e . 2017-04-24 16:56:18 -07:00
487e89d4d0 Add i486 and i586 to Linux makefile for detection of ia32. 2017-04-24 15:19:03 -07:00
fe5257df81 VERSION 1.2.4: Bug fixes and performance improvements
* 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-04-24 11:41:23 -07:00
9161424c97 Version bumps. 2017-04-24 11:41:01 -07:00
cdda0dd043 Windows version bump. 2017-04-24 11:37:54 -07:00
f4feccc626 Do not serve controller requests until init is done. 2017-04-24 09:09:04 -07:00
44cb2f4efd ++version 2017-04-21 15:32:00 -07:00
cacb8fae0d GitHub issue #463 -- fix MacOS uninstall script. 2017-04-21 13:55:44 -07:00
fa99a5cf12 docs 2017-04-21 13:27:34 -07:00
e700165eba GitHub issue #465 - Windows route amnesia 2017-04-21 13:26:02 -07:00
8542ee59db Windows crash fix. 2017-04-21 12:42:51 -07:00
76108671f6 BSD makefile fix for OpenBSD. 2017-04-21 08:42:45 -07:00
8b0ce1cc00 More BSD make fixes. 2017-04-21 08:09:18 -07:00
0e88c73f68 Mirror over some arch rules from Linux to BSD make, and enable fast crypto there. 2017-04-21 08:04:33 -07:00
ba0d73d102 Windows build fixes. 2017-04-20 10:21:40 -07:00
d3ecd1d670 docs 2017-04-20 10:21:08 -07:00
f9ae5938d0 Makefile fix, only bifurcate routes for default, and release notes. 2017-04-20 10:08:46 -07:00
a8ced184dc Some code cleanup and make sure any type punning is guarded with ZT_NO_TYPE_PUNNING. 2017-04-20 09:33:35 -07:00
e7a2c6ecef Integrate ARM/NEON crypto. 2017-04-19 17:11:56 -07:00
a376bcc654 ARM NEON Salsa20/12 in build and selftest. Almost 2X speedup on a Raspberry Pi. 2017-04-19 23:49:26 +00:00
8e1ac9fb0c ARM NEON Salsa20/12. 2017-04-19 15:58:20 -07:00
bc61357a44 HTTP backend support for JSONDB 2017-04-18 17:37:44 -07:00
f6d92eb737 JSONDB fix. 2017-04-18 13:48:19 -07:00
48cadcd2fc More build fixes. 2017-04-18 12:48:56 -07:00
bd63a840c7 Mac build fix. 2017-04-18 12:44:27 -07:00
aaf597f020 Cleanup, Windows fixes, Self test fix 2017-04-18 12:22:44 -07:00
72bd3064a2 Windows build fixes, self test cleanup. 2017-04-18 11:00:29 -07:00
a1c316b940 Makefile cruft. 2017-04-18 09:19:39 -07:00
02f84b225c Add MIPS architectures to Linux Makefile and add an error if architecture cannot be determined. 2017-04-18 09:14:33 -07:00
6551c20005 Enable x64 ASM Salsa20/12 on Linux. 2017-04-18 08:57:32 -07:00
a1e94154be Just incorporate the X64 ASM version of Salsa20/12 for X64 platforms. This gives us (for example) 1.5gb/sec encryption on a Core i5 2.8ghz. 2017-04-18 08:45:37 -07:00
4938e82795 Delete junk. 2017-04-17 18:01:51 -07:00
7a94f63058 Back out NaCl since the old one with xmm6 salsa2012 does not support multi-block use and the new one is slower. 2017-04-17 17:54:12 -07:00
db0edf154c Use right deployment target in OSX bin. 2017-04-17 16:54:41 -07:00
a1cd94a61d Actually include .a 2017-04-17 16:43:36 -07:00
df48738ac9 Enable use of NaCl for faster X64 Salsa20 implementations. Also include binary for OSX for easy build. Blazingly fast. 2017-04-17 16:43:03 -07:00
d8f5cfdee4 Windows profile build target (CPU profiling), and a little bit of optimization revealed by such. 2017-04-17 15:45:49 -07:00
95e5345cc3 Cluster build fix. 2017-04-17 10:12:13 -07:00
ba5d0cc2f9 Silence some TRACE noise. 2017-04-17 09:31:07 -07:00
1d8ded3293 Tiny largely non-consequential credential fix. 2017-04-17 09:30:28 -07:00
2487a8bede Fix for 100% cpu issue. 2017-04-17 09:14:21 -07:00
f1c0563c40 Fix for cluster handoff. 2017-04-14 18:02:04 -07:00
139c4b5633 Significant simplification to path logic. 2017-04-14 17:53:32 -07:00
645bf4a764 Resurrect zerotier-containerized. 2017-04-14 13:30:12 -07:00
88a4a3b1ba Pass tptr on leave. 2017-04-11 08:47:02 -07:00
6fabaae736 Add simple root server watcher (for our own new dashboard, but also for user use). 2017-04-04 16:47:14 -07:00
1b2cfd63e5 add libstdc++ dependency 2017-04-04 14:10:38 -07:00
ff2b219abd root-watcher code 2017-04-04 12:39:14 -07:00
33c3af752b Need to just have a make option for soft float ARM. 2017-04-04 11:26:50 -07:00
f73a1d2d56 Linux ARM flags. 2017-04-04 09:41:34 -07:00
470ad39d0d More Linux ARM stuff. 2017-04-04 09:15:38 -07:00
5ad120208f Small fix, should filter by temporal validity. 2017-04-04 08:46:12 -07:00
b48a70db2e Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-04-04 08:39:22 -07:00
cd050b3423 Performance improvement in controller. 2017-04-04 08:39:19 -07:00
eddbc7e757 Logic simplification, cleanup, and memory use improvements in Membership. Also fix an issue that may cause network instability in some cases. 2017-04-04 08:07:38 -07:00
8a62ba07e5 Membership cleanup work in progress. 2017-04-04 06:47:01 -07:00
b3298a8f57 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-03-30 09:54:10 -07:00
e5284771e4 Add ping/pong to API so controller supervisor in Central can do a full-path check of controller uptime, etc. 2017-03-30 09:54:04 -07:00
5f611dad51 added orbit/deorbit methods to java Node implementation 2017-03-29 13:29:02 -07:00
1c5fdb8a0a fix path checker initialization 2017-03-29 13:28:06 -07:00
de4b9e9a16 Added path checking interface for Java 2017-03-29 12:52:52 -07:00
57b5a33fbb Fix bug preventing default from being set to null if already set to an integer. 2017-03-29 12:32:59 -07:00
3f4f7145a3 Another rule compiler fix. 2017-03-28 22:25:24 -07:00
b959148447 Small rule compiler fix with tag defaults. 2017-03-28 21:50:44 -07:00
855361b5b8 fix native end of JNI code for new thread data ptr 2017-03-28 17:49:00 -07:00
91c9f4cb20 Fix TRACE and CLUSTER builds. 2017-03-27 17:33:25 -07:00
e4896b257f Add thread PTR that gets passed through the entire ZT core call stack and then passed to handler functions resulting from a call. 2017-03-27 17:03:17 -07:00
592cac5815 Remove from a few other places. 2017-03-27 12:09:37 -07:00
4244cca48c Delete comically named SSL gateway code, which is going elsewhere. 2017-03-27 12:08:38 -07:00
179ab5220a Set macOS deployment target to 10.10 for UI applet
Must use CLI for older versions of macOS
2017-03-27 11:36:11 -07:00
d6bb1b72c3 Fix some text colors to work on old OS X versions 2017-03-27 11:15:36 -07:00
3d9a5a4f91 Popovers now appear to work 2017-03-27 10:55:47 -07:00
683ba79ff0 Added ButtFlare stub code 2017-03-24 17:00:14 -07:00
0c69fc719f Windows UI will attempt to re-copy the auth token if a 401 error is received 2017-03-22 10:48:42 -07:00
03b48a4ad4 add lock around [ServiceCom key] and remove some debug code 2017-03-22 10:22:15 -07:00
aa71292265 A couple more places we should check HTTP status 2017-03-22 10:18:12 -07:00
d72eee6cf7 If we get a 401 error from the ZeroTier service in the macOS UI, try re-copying the auth token 2017-03-22 09:58:13 -07:00
6bb19e7947 build fix 2017-03-21 09:08:32 -07:00
3d2518f799 crazy formatting fix 2017-03-21 08:21:11 -07:00
5268909075 Add a facility for full flow-through uptime test of controller by Central. 2017-03-21 06:31:15 -07:00
c62141fd98 Make controller do a simple write-through cache without revalidating. Means you must restart if files change on disk, but will decrease I/O considerably. 2017-03-21 06:15:49 -07:00
ae303ee902 dev is now 1.2.3 2017-03-20 16:17:11 -07:00
cfe0d0971f VERSION 1.2.2
Version 1.2.2 fixes a few bugs discovered after the 1.2.0 release. These are:

 * 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-17 21:13:41 -07:00
c5c8facc2d Windows installer version bump and a build fix. 2017-03-17 20:20:47 -07:00
f78d6a8a93 docs 2017-03-17 20:04:25 -07:00
78ef2c5f16 Windows build fixes, app about text revisions. 2017-03-17 20:01:58 -07:00
ec8e1178e5 Version bumps, and fix Debian so default is to build normally and .static files are used in our builds. 2017-03-17 19:16:34 -07:00
4f3f471b4c GitHub issue #460 2017-03-17 18:19:51 -07:00
e10325e133 GitHub issue #461 -- plus a bit of cleanup and optimization 2017-03-17 17:15:23 -07:00
ef46d3c97d LZ4 cleanup 2017-03-17 23:09:18 +00:00
a9c08c5975 . 2017-03-17 22:35:56 +00:00
c467c3b7e4 ARM tweaks 2017-03-17 22:26:08 +00:00
cdc0eaec3a Fix attempt to WHOIS self. 2017-03-17 22:13:34 +00:00
a7cb738175 . 2017-03-17 14:25:54 -07:00
d1bb22a583 . 2017-03-17 14:09:30 -07:00
553d972de5 bump that version. bump it good. 2017-03-17 13:56:45 -07:00
cc883cc3d8 Merge branch 'master' of http://10.6.6.2/zerotier/ZeroTierOne 2017-03-17 13:56:01 -07:00
c6a39ed927 Fixes for possible ARM issues, cleanup, fix for spurious meaningless exceptions on NETWORK_CONFIG_REQUEST 2017-03-17 13:55:26 -07:00
df30255542 Merge branch 'master' into dev 2017-03-17 12:37:23 -07:00
d5102539dd Merge pull request #457 from skunkwerks/master
build: use clang on FreeBSD
2017-03-17 12:18:54 -07:00
e3feaf3f5d Warning removal, and dev is now 1.2.1 2017-03-16 16:45:11 -07:00
25dc596397 build: use clang on FreeBSD
this avoids a whopping 500+Mb dependency on gcc and friends at runtime
2017-03-16 12:58:04 +01:00
0daff26fba 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.
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 capabilites provide advanced methods for implementing fine grained permission structures and micro-segmentation schemes without bloating the size and complexity of your rules table.

See 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/).)

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.

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.

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.

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.

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.

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.

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 desintation 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.

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.

 * **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.
 * **Segmenation faults on musl-libc based Linux systems**: Alpine Linux and some embedded Linux systems that use musl libc (a minimal libc) experienced segmentation faults. These were due to a smaller default stack size. A work-around that sets the stack size for new threads has been added.
 * **Windows firewall blocks local JSON API**: On some Windows systems the firewall likes to block 127.0.0.1:9993 for mysterious reasons. This is now fixed in the installer via the addition of another firewall exemption rule.
 * **UI crash on embedded Windows due to missing fonts**: The MSI installer now ships fonts and will install them if they are not present, so this should be fixed.

 * **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.

Merge branch 'master' of github.com:zerotier/ZeroTierOne
2017-03-14 22:08:48 -07:00
94ba5b3fbe 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.
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 capabilites provide advanced methods for implementing fine grained permission structures and micro-segmentation schemes without bloating the size and complexity of your rules table.

See 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/).)

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.

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.

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.

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.

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.

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.

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 desintation 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.

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.

 * **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.
 * **Segmenation faults on musl-libc based Linux systems**: Alpine Linux and some embedded Linux systems that use musl libc (a minimal libc) experienced segmentation faults. These were due to a smaller default stack size. A work-around that sets the stack size for new threads has been added.
 * **Windows firewall blocks local JSON API**: On some Windows systems the firewall likes to block 127.0.0.1:9993 for mysterious reasons. This is now fixed in the installer via the addition of another firewall exemption rule.
 * **UI crash on embedded Windows due to missing fonts**: The MSI installer now ships fonts and will install them if they are not present, so this should be fixed.

 * **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.
2017-03-14 22:07:26 -07:00
002f9bb105 . 2017-03-14 22:05:39 -07:00
e86b1146a6 Windows version bump. 2017-03-14 21:35:41 -07:00
d44fb3a2f6 bump bump bump that version 2017-03-14 21:23:47 -07:00
1ef3069a7e 1.2.0 release notes and a few final tweaks and cleanup. 2017-03-14 21:21:12 -07:00
f99b62c48d fix stupid thing. 2017-03-14 15:38:24 -07:00
0fd45a640b Allow multiple architectures in software update dist .json file arch fields. 2017-03-14 15:19:16 -07:00
0b0d03dbe2 Merge branch 'dev' of http://10.187.63.16/zerotier/ZeroTierOne into dev 2017-03-14 14:40:27 -07:00
533baf921f Software update cleanup, and a fix for updates on Windows. 2017-03-14 14:40:17 -07:00
8e9767f3c6 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-03-14 13:17:16 -07:00
27d4bedd73 Wait a minute (literally) before doing software update check on startup. 2017-03-14 13:17:10 -07:00
c1c26ec73a Version 1.2.0 bump 2017-03-13 15:41:42 -07:00
8f592ff6e8 Controller performance tweaks. 2017-03-13 13:58:29 -07:00
37629aaf87 Use cache on requests to decrease DB load. 2017-03-13 12:22:06 -07:00
d09d193715 release notes, and delete MANUAL from this repo for now since it isn't quite done and will take shape on the web site 2017-03-13 09:37:24 -07:00
010d0a7d56 Docs and a bit of cleanup. In particular ALL makes no sense for revocations because they have IDs. In that case you would just revoke the COM. 2017-03-13 06:53:23 -07:00
902807ea50 Software update check every 10min. 2017-03-10 22:03:07 -08:00
d0224b3623 Software update fix. 2017-03-10 22:02:08 -08:00
0f3148bda2 Roots need to respond to lots of WHOISes 2017-03-10 20:08:07 -08:00
e3b1fc2ac0 Tweak WHOIS path for federation. 2017-03-10 19:52:08 -08:00
6194d2af3d Return 200 from JSON API when moon is POSTed. 2017-03-10 19:37:03 -08:00
db87d95c1d getUpstreamPeer issue with interim federated roots 2017-03-10 19:31:51 -08:00
47166c9614 Sigh. Another thinko. 2017-03-10 17:54:14 -08:00
ecacdf27a9 Build fix (typo) 2017-03-10 17:45:05 -08:00
aad6f79efa Also must mask off counter bits in IV in cryptField. 2017-03-10 17:44:25 -08:00
0c00b83702 cryptField() used to obscure extended fields in HELLO cannot use mangleKey() 2017-03-10 17:34:41 -08:00
7320e26730 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2017-03-10 11:34:00 -08:00
1520534660 fix some rediculousness in NDK-14
Apparently having -fPIC on the command line multiple times turns it back off
2017-03-09 17:48:40 -08:00
6d6719da27 Clarify key semantics. 2017-03-08 17:03:32 -08:00
20085cd15b No need to put time in .moon filename. 2017-03-08 16:51:12 -08:00
9b001823f6 Add ifdef for synology around synology-only code in Linux Ethernet tap. 2017-03-08 16:12:54 -08:00
ed4f84cc57 Fix exception thrown in NetworkMonitor thread that can cause the UI to stop polling service for updates 2017-03-08 14:54:58 -08:00
c8e66a2b45 Don't crash when attempting to join a network while the zerotier service isn't running 2017-03-08 14:50:37 -08:00
6eb2e3ffa9 forgot to add prereq for adduser getent on fedora 2017-03-08 13:13:12 -08:00
748ad8a978 create zerotier-one user via rpm 2017-03-08 12:26:16 -08:00
d2f897f8de add dependency on adduser 2017-03-08 12:26:16 -08:00
4b511d80a1 Windows directory cleanup and a Windows build fix. 2017-03-08 10:38:43 -08:00
a74e9e1dd3 remove debug line 2017-03-08 10:27:13 -08:00
9c1a9f984b Clean iddb.d periodically. 2017-03-08 10:18:12 -08:00
04c7adea07 cleanup 2017-03-08 08:58:07 -08:00
5249ce8fb4 Small amount of cleanup. 2017-03-08 08:45:04 -08:00
ebd865dbda Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-03-07 18:25:44 -08:00
d377ef01af Windows build process updates, and repackage everything using new EV certificate and SHA256. 2017-03-07 18:25:06 -08:00
393aa3c527 fix debuild comand 2017-03-07 14:20:06 -08:00
d7b6de57c5 update debian build files 2017-03-07 14:20:06 -08:00
05d4b0cd94 Update RPM spec file 2017-03-07 14:20:06 -08:00
5dbafc2eeb Add config to status in JSON API. 2017-03-07 14:17:51 -08:00
a97918f812 Windows build fixes. 2017-03-07 13:57:31 -08:00
22f86df606 Merge ControlPlane into OneService to make variable access simpler. 2017-03-07 13:53:11 -08:00
712e8e828b use .exe naming convention 2017-03-07 11:58:17 -08:00
7d3846bc49 Bump version to 1.1.19 in prep for release and software update testing. 2017-03-07 10:26:36 -08:00
9980526aaf Consistent field names. 2017-03-07 10:12:05 -08:00
1d2cb867b2 Close all open FDs before exec in Unix software update code. 2017-03-07 09:26:27 -08:00
3859533e73 Minor software updater cleanup. 2017-03-07 09:18:00 -08:00
7ea7e1898a Fix a bug that could cause duplicate IP address assignment on networks if many new members join the controller at once. 2017-03-06 16:21:49 -08:00
5e6a4e5f5e Send revocations automatically on deauth for instant kill, also fix some issues with the RP. 2017-03-06 15:12:28 -08:00
66dfc33de9 Fix circuit test post in controller. 2017-03-06 11:23:46 -08:00
d56f740dc6 Now with less bugs. 2017-03-03 13:49:21 -08:00
a109d341ef Send timestamp with new circuit test response. 2017-03-02 14:35:38 -08:00
87b53d67c5 Fix selftest build. 2017-03-02 10:02:29 -08:00
a577b8d381 Update how controller handles circuit tests -- save results to filesystem. 2017-03-01 16:33:34 -08:00
136fddc7f1 Fix FILTER_TRACE breakage. 2017-03-01 15:14:57 -08:00
ce0c87f8ff Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-03-01 15:12:26 -08:00
d79585d44d Circuit tests now report link quality. Also fixed a little thing in revocation propagation. 2017-03-01 15:12:17 -08:00
592b628523 comment broken TRACE message 2017-03-01 14:50:28 -08:00
39f886ad88 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-03-01 14:37:01 -08:00
1d39be61b2 ZeroTier now has link quality measurement. We are not using this yet but decided to put it in to prep for future QoS support and SD-WAN stuff. 2017-03-01 14:36:52 -08:00
2bf9145ae6 Outgoing side of packet counter for link quality reporting. Also some cleanup and a cluster mode build fix. 2017-03-01 10:22:57 -08:00
127bcb02ff Save space in expecting-reply-to tracking. 2017-03-01 09:41:37 -08:00
4430fc47c6 Added HTTP authorization block for synology builds 2017-02-28 16:30:20 -08:00
2b10a982e9 Match on tag sender equals or tag recipient equals. 2017-02-28 09:22:10 -08:00
31bece7fa0 Add ipauth handling of IPv6 NDP neighbor solicitations and advertisements. IPv6 works well now with ipauth. 2017-02-28 07:43:40 -08:00
4436824faf ipauth characteristic now works with ARP 2017-02-27 17:51:58 -08:00
dd92f1d03d . 2017-02-23 17:56:36 -08:00
b6f87565a9 Add wake on LAN (wol) to rules language ethertype shorthand. 2017-02-23 16:03:43 -08:00
0b909997b8 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-02-23 14:27:48 -08:00
9d7ff26f25 Helps if you actually add the ipauth mask to the characteristics mask. 2017-02-23 14:27:31 -08:00
06c866ceb4 Android JNI fix 2017-02-23 12:47:07 -08:00
fe19ad328c Windows build fix. 2017-02-23 12:40:21 -08:00
010dbc8b2b Merge. 2017-02-23 12:35:20 -08:00
72653e54f9 Finish wiring up ipauth and macauth to Network filter. 2017-02-23 12:34:17 -08:00
93ec86a26e iOS fixes 2017-02-23 12:26:11 -08:00
10185e92fa Certificate of ownership -- used to secure against IP address spoofing, especially for IPv4 and regular IPv6. 2017-02-23 11:47:36 -08:00
33b94e8478 fixed double firing of the leave network API call causing an error popup on windows 2017-02-22 16:54:57 -08:00
2ee53b0e75 Fix bug in default capability flag in rule parser. 2017-02-22 15:52:55 -08:00
fb00f0f94c Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-02-22 15:34:49 -08:00
b679ebde3b Ad-hoc networks, a cool and easy to implement little feature that allows controllerless networks. These only allow IPv6 6plane, no multicast, and the network ID encodes the allowed port range. 2017-02-22 15:32:55 -08:00
f3ca08b0f1 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2017-02-21 17:55:07 -08:00
946e413997 properly fill out ifcfg files. also removed route re-add code for synology 2017-02-21 17:55:00 -08:00
b475bf4a21 . 2017-02-21 15:28:01 -08:00
54fa73844c Fix crash. 2017-02-21 13:48:29 -08:00
32f5a0ab18 Add default tag values and default set capabilities for new members. 2017-02-21 13:27:20 -08:00
e4135ffb35 Decreased ZT_BINDER_REFRESH_PERIOD for Synology build 2017-02-16 16:56:23 -08:00
b5b335a6f8 Route re-add patch for linux build on Synology devices 2017-02-16 16:41:26 -08:00
57ef31d51c Route re-add patch for linux build on Synology devices 2017-02-16 16:06:04 -08:00
61b413b57f Found it in a few other places. 2017-02-16 09:54:52 -08:00
d2c0203dc9 Fix stupid inverted sense bug. 2017-02-16 09:53:39 -08:00
afba19e01c When deciding whether to send PUSH_DIRECT_PATHS we should check global trust flag, not the one passed into receive(). 2017-02-16 09:44:04 -08:00
b989c03416 Fix build on Linux if PR_CAP_AMBIENT is not defined, which is the case for some libc-dev installs. 2017-02-16 00:57:33 +00:00
3361b4030b Integrate and test linux privilege drop code (from contributor PR). It works now if a "zerotier-one" user is present on a Linux system. Does everything automagically. 2017-02-15 16:25:49 -08:00
bdadd50251 . 2017-02-14 16:49:10 -08:00
d01f31197a Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-02-14 16:43:29 -08:00
8b82f1c609 Add rules compiler script. 2017-02-14 16:43:22 -08:00
de7e8a1ca4 fix About view on Mac so that it opens links in the system web browser 2017-02-14 16:39:15 -08:00
aa2ee3f7be Right and left click both will now open the context menu on Windows 2017-02-14 16:31:11 -08:00
af4e79735c Fix "orbit" semantics. Federation works. 2017-02-13 16:38:21 -08:00
969e09210d Fix loading of existing moons. 2017-02-13 16:14:48 -08:00
cd7b571da0 Add a local.conf option to set the port. 2017-02-13 15:55:38 -08:00
0052877d2f Add CLI shortcuts for adding federated roots. 2017-02-13 15:41:53 -08:00
23bb44f2d6 Fix small typo. 2017-02-13 14:28:17 -08:00
16f11e91d1 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-02-13 14:27:14 -08:00
4b11566505 Integrate moon concept into http config bus, and clean up that code quite a bit. 2017-02-13 14:27:08 -08:00
9ae49b5b85 Update JNI with new root terminology 2017-02-13 10:51:36 -08:00
c95bae2d73 Small fixes to moon-management code in CLI. 2017-02-13 10:05:00 -08:00
e4b6611201 Only accept world updates from upstreams. 2017-02-13 09:46:34 -08:00
e6840a1863 Can't erase from vector using const_iterator on some C++ compilers.' 2017-02-13 09:26:05 -08:00
78d5f1a803 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-02-13 09:03:54 -08:00
42f28bce52 Cleanup and make moons (federated roots) a little easier to deal with. 2017-02-13 09:03:48 -08:00
9a6c3e05ad Fix for deleted networks not being removed from the network details list on macOS 2017-02-10 16:10:23 -08:00
cdc289fa9c Tags work. 2017-02-07 14:06:40 -08:00
672f17c6e9 Add a mask and value range to the IP tos rule field. This allows TOS to be matched more usefully. This will break anyone using tos in the beta, but nobody seems to be and its pre-release so now is the time. 2017-02-07 09:33:39 -08:00
723a9a6e9a Small additional efficiency improvement. 2017-02-06 17:20:22 -08:00
59ba7c8bf5 Improve efficiency of pushCredentials() method since it gets called a lot. 2017-02-06 17:10:20 -08:00
78d548458b Capabilities basically work but need to refactor a bit for performance reasons. 2017-02-06 16:38:48 -08:00
ac3e883c05 One more place to add "break". 2017-02-06 14:07:30 -08:00
9ddc2a4331 Add a break action to rules engine to make capabilities easier to use. 2017-02-06 14:00:49 -08:00
435e4c4695 Fix HELLO parse bug. 2017-02-06 12:06:10 -08:00
21f4a97c35 CSPRNG performance improvement, self test build fix. 2017-02-06 11:49:41 -08:00
e0d63c50db One more tweak after thinking about related keys and key stream reuse. Just a precaution. 2017-02-06 07:45:57 -08:00
803f74634a Tweak how we do crypto of the masked portions of HELLO just to be more "boring" in the DJB sense. 2017-02-06 07:39:38 -08:00
f85a630a64 Docs and a small build fix in debug mode. 2017-02-06 07:17:45 -08:00
43182f8f57 Docs, code cleanup, and protect the extra new fields of HELLO with encryption as a precaution. 2017-02-05 16:19:03 -08:00
594cb1fad8 Small fix for duplicates in world definitions. 2017-02-04 19:29:39 -08:00
5eab6c2e5d More docs. 2017-02-04 19:19:30 -08:00
3587aa1ea7 Add and send certificates of representation to tell people what our valid upstreams are. These are not used yet but will be needed for future privacy modes, etc. Also some cleanup. 2017-02-04 13:17:00 -08:00
beb642faa5 Stub out CAN_REACH. 2017-02-04 10:21:31 -08:00
31db768e4d A bit of code cleanup. 2017-02-04 00:23:31 -08:00
d9e4ba1280 Eliminate a little copypasta. 2017-02-04 00:04:44 -08:00
dcb1233b0d Slight refactor to RENEDEZVOUS sending code for federation. 2017-02-03 23:54:02 -08:00
8a2ff0b31e Actual documentation. 2017-02-03 19:47:00 -08:00
be2881ae8d . 2017-02-02 16:53:27 -08:00
88cba48f45 Eliminate warning. 2017-02-01 15:24:41 -08:00
9284e4edfe agree() must be called on our identity, the one with the secret 2017-02-01 15:22:14 -08:00
62a705af1c Eliminate another check in cluster frontplane mode. 2017-02-01 14:35:07 -08:00
29ec7bf3a2 Add more specific check in source==self case instead of dumping it. 2017-02-01 14:18:56 -08:00
fc3f4fb988 Yeah that could never have worked (normal packets in cluster mode). 2017-02-01 14:05:13 -08:00
60ff280dcb Another tweak to cluster I/O rules. 2017-02-01 13:52:53 -08:00
b378f5dcd7 Take 3 2017-02-01 13:20:51 -08:00
e778d45128 Still want to send WANT_PEER under two failure modes. 2017-02-01 12:51:52 -08:00
5e11cf6378 Can't armor() a packet until all flags are set. 2017-02-01 12:32:06 -08:00
5dbebc513a Minor send path refactor to make packet I/O work on clusters if they are members of networks. Also fix a crash if compiled in cluster mode but no cluster is enabled. 2017-02-01 12:00:25 -08:00
6d5a3cd2e2 Remove debug code. Cluster network config sharing seems to work. 2017-01-30 16:23:38 -08:00
f9ad80aa13 . 2017-01-30 16:15:47 -08:00
ed31cb76d6 Fix to cluster network configs. 2017-01-30 16:04:05 -08:00
eebd271bb1 Implement cross cluster sharing of network configs to make clusters able to actually join networks. 2017-01-30 15:40:22 -08:00
ff74ec2482 Cluster build fix. 2017-01-30 21:39:44 +00:00
49e31ca647 InetAddress.hpp needs to be included in OneService.hpp 2017-01-30 09:16:16 -08:00
471108f2e4 Slightly increase thread stack size for safety (primary Alpine related) possibly GitHub #443 2017-01-30 08:01:36 -08:00
2ceb162df0 Merge pull request #442 from zielmicha/allow-managed
allow user to specify arbitrary allowed IP networks in allowManaged
2017-01-30 06:54:49 -08:00
915206405c docs 2017-01-27 17:41:07 -08:00
5fa1d9796c zerotier-idtool commands to init and generate moons 2017-01-27 17:34:39 -08:00
77a1dd4737 Dead code removal, fix minor issue in upstream endpoint check. 2017-01-27 16:25:53 -08:00
9e7c778cc8 Fix deadlock. 2017-01-27 16:16:06 -08:00
1d775af34a Fix moon persistence. 2017-01-27 15:35:21 -08:00
9f7919f71f Add comments to join ("orbit") moons. 2017-01-27 15:27:26 -08:00
0b3b994241 Relay policy can now be computed. 2017-01-27 14:05:09 -08:00
bc218f9414 little fix 2017-01-27 13:52:29 -08:00
f102fd7f92 Extend in-band world updates to handle moons too. 2017-01-27 13:50:56 -08:00
64774d0d4f Replace piecemeal designation of upstreams with the concept of moons, which is simpler and easier to use and inherits all the cool live update stuff of worlds (now called planets) and global roots. 2017-01-27 13:27:52 -08:00
b88f573733 tap-windows-ndis5 is definitely dead 2017-01-27 07:29:42 -08:00
b211e61671 debian rules 2017-01-26 16:12:50 -08:00
871cacf040 Remove junk. 2017-01-26 15:02:52 -08:00
7c3984413e Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-01-26 15:02:20 -08:00
967ce78a57 Add static build option so we can build a static Linux binary for ancient distros (wheezy, etc.) 2017-01-26 15:02:03 -08:00
923d3f1fe8 remove references to deleted source files in Android NDK build files 2017-01-26 15:01:45 -08:00
e11f42a089 remove reference to BackgroundResolver.cpp/.hpp on Windows 2017-01-26 14:29:39 -08:00
9b8d9b7042 fix copy stage for paths with spaces 2017-01-26 14:27:39 -08:00
902e03bccc build fix 2017-01-26 14:23:22 -08:00
ec0e8a9a43 Rip out resolver and use anycast address instead. In the long term existing TCP proxy dies anyway. Fixes static build problem for old Linux versions. 2017-01-26 13:59:20 -08:00
9e488ce322 delete binary 2017-01-26 21:55:35 +00:00
c111bf3080 Fix tcp-proxy build. 2017-01-26 21:54:55 +00:00
8f2a42d1ad allow user to specify arbitrary allowed IP networks in allowManaged 2017-01-23 12:16:40 +01:00
9a475eeff9 Windows build fix, warning removal. 2017-01-20 12:00:18 -08:00
91a37ec639 docs 2017-01-20 11:02:54 -08:00
db1e2aae41 docs 2017-01-20 11:00:18 -08:00
4a7c76a11b docs, cleanup, temporarily put cli in attic since it is not done. 2017-01-20 10:51:55 -08:00
f1ed57c62d Update nlohmann/json (header only lib). 2017-01-20 10:09:47 -08:00
3b0969e3a5 Fix build on G++ 4.9 on FreeBSD-11. 2017-01-20 10:07:25 -08:00
35174a8766 Basic BSD gmake install/uninstall. 2017-01-19 15:15:31 -08:00
d79f792e6f OpenBSD fixes, workaround for apparent libstdc++ bug. 2017-01-19 15:05:26 -08:00
7b231b38b0 Now builds on OpenBSD, but segfaults. So not yet but close. GitHub issue #439 2017-01-19 10:39:42 -08:00
13263b8401 docs 2017-01-19 16:23:25 -08:00
a604294b1b local.conf docs 2017-01-19 16:10:36 -08:00
89d74cd293 Add a portMappingEnabled flag to local.conf to allow uPnP/NAT-PMP to be disabled. 2017-01-19 15:57:50 -08:00
56e5b34934 Bump bundled miniupnpc to 20161216 2017-01-19 15:52:39 -08:00
f43365e4ba Take LZ4 out of Debian depends. 2017-01-19 15:44:16 -08:00
4d071081bb docs 2017-01-19 15:22:43 -08:00
b67b370dba docs 2017-01-19 15:20:55 -08:00
0995c1dcaa Encapsulate LZ4 in Packet.cpp to eliminate dependency. 2017-01-19 15:16:04 -08:00
7612bf3302 Fix LZ4 warning. 2017-01-19 14:54:39 -08:00
ba158d8dc6 Include LZ4 README and LICENSE. 2017-01-19 14:48:40 -08:00
a90f2249e8 Upgrade LZ4. 2017-01-19 14:48:01 -08:00
d8f36db5dd Fix FreeBSD build in dev. 2017-01-19 12:11:49 -08:00
fd460d93c4 docs 2017-01-19 10:53:44 -08:00
989cbb4d8d Merge pull request #434 from zielmicha/fix-ip
Binder.hpp: gather all IPv4 interface addresses
2017-01-19 10:47:47 -08:00
e9007b1f56 NodeJS migration script for old Sqlite controller.db to new controller data format. 2017-01-19 10:44:26 -08:00
0fb3d1d582 Add a build version for software update use so we can do very minor updates within a version. 2017-01-18 09:16:23 -08:00
81910c1d92 Replace update signing key with real key generated on air-gapped system. 2017-01-13 16:07:57 -08:00
d150f9b2bd Windows update build in Advanced Installer, and warning removal. 2017-01-13 15:19:59 -08:00
1346e31a8e Windows build fixes, Software update fix, warning removal. 2017-01-13 14:22:36 -08:00
54f25b14ee Software updater log for distributors (does not affect real users much). 2017-01-13 14:03:06 -08:00
0e4d3244b2 "make official" for Mac now builds update image as well as pkg (update image is just PKG + SFX script) 2017-01-13 13:09:42 -08:00
87e3b5f076 Mac updater SFX code. 2017-01-13 12:42:49 -08:00
f8e18f2098 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-01-13 12:13:20 -08:00
f81c67c0f0 Make sure to respond to GET_LATEST with the actual latest. 2017-01-13 12:13:14 -08:00
4f4dd3446c Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2017-01-13 11:36:53 -08:00
f149dd9401 fix Android NDK build 2017-01-13 11:36:48 -08:00
3a730c4a5c Remove debug printfs in software updater. It works! At least for unix. Now to test Windows. 2017-01-13 11:24:00 -08:00
b03247ec3c SoftwareUpdate::apply() 2017-01-13 10:46:16 -08:00
8ebb49e972 Cache downloaded updates to disk. 2017-01-12 15:21:14 -08:00
84bfec8329 . 2017-01-12 14:35:52 -08:00
e1727d6297 Fix to software update repeat downloads. 2017-01-12 14:34:52 -08:00
e7bab66d29 Auto-apply updates if enabled. 2017-01-12 13:54:08 -08:00
ab25c96821 Build fixes. 2017-01-12 13:51:06 -08:00
c6b0b07605 More software update work, and settings in local.conf. 2017-01-12 13:18:11 -08:00
b5b583c397 . 2017-01-11 18:10:42 -08:00
56d969c709 . 2017-01-11 17:59:51 -08:00
3fedf16f35 . 2017-01-11 17:57:12 -08:00
5da56776d6 . 2017-01-11 17:54:43 -08:00
d58870a92d . 2017-01-11 17:53:19 -08:00
15ed7423ac . 2017-01-11 17:50:02 -08:00
d7e7ad4f88 Can't send a user message to self. 2017-01-11 17:46:52 -08:00
823a1963f6 init fix. 2017-01-11 17:45:09 -08:00
6513b21426 debug code. 2017-01-11 17:42:57 -08:00
d4321cdd41 Wire up user message handling in OneService event handler. 2017-01-11 17:20:43 -08:00
d301540d92 Software update stuff for test. 2017-01-11 16:58:37 -08:00
af5a3376f3 Should fix Windows build. 2017-01-11 16:56:16 -08:00
4aa52ffc77 Software update stuff. 2017-01-11 16:47:42 -08:00
47b62ece18 Software update integration. 2017-01-11 16:34:33 -08:00
2aab26a08e Software update work. 2017-01-11 15:22:16 -08:00
565842b5ec Software updater work. 2017-01-11 14:37:31 -08:00
a064e19b8a Refactor some JSON stuff for performance, and fix a build error. 2017-01-10 13:51:10 -08:00
6fb49f68fc Comment out and disable old auto-update code. 2017-01-10 12:20:29 -08:00
ef7faa7291 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2017-01-09 15:55:13 -08:00
d5528e4e9a Wire up VERB_USER_MESSAGE in core. 2017-01-09 15:55:07 -08:00
f730f65aaf bring window to front if already open 2017-01-09 14:23:37 -08:00
dbd577c6b0 Merge branch 'winroute' into dev 2017-01-09 12:41:45 -08:00
7ebb207005 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2017-01-05 13:56:15 -08:00
e41d71cd19 add implementations of compareTo() and equals() for VirtualNetworkRoute().
Android app was relying on these, but since they didn't exist, they didn't function properly
2017-01-05 13:56:07 -08:00
0f6c53589e remove commented out function declaration 2017-01-05 11:46:33 -08:00
e2b1a7157e Potential fix for routing issue on Windows
Move setting _initialized = true until after WindowsEthernetTap::threadMain() has actually created and brought up the adapter.  Also in OneService::nodeVirtualNetworkConfigFunction(), wait up to 5 seconds for WindowsEthernatTap::isInitialized() to return true before attempting to configure the interface and managed routes.  Without this, the adapter doesnt actually exist yet when trying to add routes
2017-01-05 11:43:26 -08:00
aaf69d1aff properly quote string arguments to copyutil in case there are spaces in the path 2017-01-03 14:03:50 -08:00
203b7e17de Binder.hpp: gather all IPv4 interface addresses 2017-01-01 23:57:15 +01:00
18c9dc8a06 fix RTF_MULTICAST and g++ -w 2016-12-27 13:07:05 +01:00
ba07d1f91d cleanup 2016-12-27 11:57:05 +01:00
9a2310395d mimic BSDEthernetTap but with creating/destroying char tap device 2016-12-27 11:42:43 +01:00
218ace51a7 use /dev/tap{0..3}; it is fully working now 2016-12-26 02:52:07 +01:00
f09eedbd7a make it compilable 2016-12-25 22:54:27 +01:00
546e8a3b44 initial netbsd support in makefile/flags 2016-12-25 20:59:12 +01:00
9a2b766aad Windows installer updates. 2016-12-23 15:57:21 -08:00
24017659df Update installer, etc., for Mac. 2016-12-23 15:25:04 -08:00
c175a5fcd7 Change org names, add makefile rule for Mac to build new UI. 2016-12-23 15:11:44 -08:00
5ec8465374 Remove dead Mac stuff. 2016-12-23 14:38:36 -08:00
6b5d6efe6c Retire old build farm (something new is coming) and update makefile for linux to not auto-build doc. 2016-12-23 14:33:04 -08:00
5bff70194b Ship pre-build man pages. We stopped doing this for a bit due to nit-picky Debian craziness but since we are not targeting core Debian at the moment bring it back. 2016-12-23 14:30:27 -08:00
d94d04d7d5 Bump to 1.1.17 for pre-1.2.0 beta. 2016-12-23 13:52:41 -08:00
bf2b9e3692 Auto-authorize new members on public networks properly. 2016-12-22 18:52:34 -08:00
c8554504f3 . 2016-12-22 18:37:46 -08:00
0d066e3b08 Fix JSON parse bug in REDIRECT target. 2016-12-22 18:26:43 -08:00
6b12d86209 Add a workaround for an edge case in TEE/REDIRECT if we are the inbound destination and teeing is only being done on the outbound side. 2016-12-22 18:06:35 -08:00
fe530548bb Fix MATCH_RANDOM in controller. 2016-12-22 16:57:45 -08:00
2eaff6d484 Fix to characteristcs in rules engine. 2016-12-22 16:36:38 -08:00
a54c2b438c Basic support for streaming of changes via stdout from controller. 2016-12-15 15:08:47 -08:00
890f6f0d35 Make allow management from a local.conf parameters. 2016-12-12 16:25:41 -08:00
bad4b72f82 Remove debug printf. 2016-12-12 14:44:21 -08:00
4702c5b4ee Add local.conf option to blacklist interfaces by name. 2016-12-12 14:43:09 -08:00
4459d5ad54 Remove debug printf 2016-12-12 12:58:39 -08:00
39fb4b1b42 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-12-12 12:55:14 -08:00
3864a2e111 Use an alternative method for enumerating interface addresses on Linux to avoid poor performance of getifaddrs() when there are many network namespaces. 2016-12-12 12:53:51 -08:00
697520f1f5 Dont write IPv6 addresses to IPv4 sections of registry TCPIP settings.
Also, dont add the prefix length to the IP addresses in there.

Appears to fix Github Issue #357.  Still waiting on some info from Microsoft for confirmation of a few things.
2016-12-09 11:36:01 -08:00
244f37179c Minor security: lock roots to only be reachable via World IPs. 2016-12-05 16:09:42 -08:00
4b3a47849d Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2016-11-30 15:21:33 -08:00
56faf774ff Store MTU as String instead of DWORD
WindowsEthernetTap was storing the MTU for the ZeroTier Adapter as a
DWORD.  When changing the value from the network adapter settings UI, it
was stored as a string.  Updated the call when creating the adapter to
store it as a string as windows expects.
2016-11-30 15:18:38 -08:00
fa2bb91ae5 Kill some old debug code. 2016-11-30 10:48:09 -08:00
32478845b2 Merge branch 'dev' into systemtray 2016-11-30 10:21:19 -08:00
44f0e3097e docs 2016-11-29 10:56:16 -08:00
289917e2b3 use msbuild instead of devenv 2016-11-28 15:30:52 -08:00
14fcb5867f rethrow windows build error 2016-11-28 14:57:37 -08:00
cf59362c4a add windows build to Jenkinsfile 2016-11-28 13:06:28 -08:00
8472918559 Change 'localhost' to 127.0.0.1
@makerspherehq reported it not working as 'localhost' via Twitter
2016-11-28 09:40:34 -08:00
ae8f51d608 . 2016-11-23 16:27:15 -08:00
4a7ee5472d Small fixes. 2016-11-23 16:23:44 -08:00
8718b33a66 docs 2016-11-23 15:57:06 -08:00
27f1155f1b docs and API stuff 2016-11-23 15:53:53 -08:00
84732fcb12 Wire through external path lookup. Static paths should now work. 2016-11-22 14:23:13 -08:00
c6c578ce1d Fixes to allow usage of ZeroTierOne.h with a C compiler 2016-11-22 13:18:52 -08:00
3c5e28a27d use new ZT_Node_Callbacks struct in JNI 2016-11-22 13:03:36 -08:00
a39f6e9b4c clear cached window positions when display settings change 2016-11-22 12:02:49 -08:00
adb7a88836 cache window positions so we only have to move after open once. 2016-11-22 11:53:06 -08:00
9892f7bb47 Upgrade nlohmann::json 2016-11-22 11:06:58 -08:00
42ba70e79e Replace long callback arg list with struct, and implement path whitelisting, path blacklisting, and local.conf support for roles. 2016-11-22 10:54:58 -08:00
cbaef66e82 Fix a deadlock in federation/upstream code. 2016-11-21 16:04:01 -08:00
97d915b06c Expose relay policy in node settings. 2016-11-21 15:35:18 -08:00
3a3a23db34 hacky way to set window position but it works 2016-11-21 15:31:32 -08:00
d159e5ca44 Allow relay policy setting in local.conf 2016-11-21 15:21:24 -08:00
d3bd10952e hyperlinks in the about page are clickable 2016-11-21 14:32:25 -08:00
40078a99de Make parse failure of local.conf non-fatal in case people have ancient files sitting around. 2016-11-21 14:14:43 -08:00
0142c0d339 fill out the about view 2016-11-21 13:25:10 -08:00
2e5de46584 local.conf and support for virtual role definition 2016-11-21 13:20:56 -08:00
1be55d6182 Merge branch 'dev' into systemtray 2016-11-21 12:59:43 -08:00
8ebcd44405 dont close the network list. just hide it so its reusable 2016-11-21 12:54:27 -08:00
ccdd4ffda7 Move split() to OSUtils since it is not used in core. 2016-11-18 15:49:28 -08:00
a6ed711492 wired up the startup registry key to the registry 2016-11-18 15:44:41 -08:00
3fb224cb22 add a checkbox for startup option in preferences 2016-11-18 15:23:07 -08:00
5ca5af619d Merge branch 'systemtray' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into systemtray 2016-11-18 14:58:01 -08:00
f61c5836b2 copy node ID by clicking on node ID menu item 2016-11-18 14:57:14 -08:00
535b33b46e copy node ID by clicking on node ID menu item 2016-11-18 14:52:04 -08:00
a8847de910 proper shutdown 2016-11-18 14:23:22 -08:00
2231e878d5 Merge branch 'dev' into systemtray 2016-11-18 14:00:25 -08:00
299a7cab20 fixed an issue where sometimes network data wouldnt be updated 2016-11-18 13:59:31 -08:00
e48d6880c9 Wired up connected checkbox and delete button. just something not working with refresh. 2016-11-18 13:52:48 -08:00
673c0c811e Wire through upstream stuff and add setRole(). 2016-11-18 13:48:49 -08:00
6e1da35c12 Remove debug. 2016-11-18 13:15:58 -08:00
25f9c294dc Small bug fix and warning removal. 2016-11-18 13:01:45 -08:00
2ea9f516e1 Rate gate expensive validation of new identities in HELLO. 2016-11-18 12:59:04 -08:00
dbe1461886 wire up the quit button 2016-11-18 12:17:57 -08:00
7bea709747 wire up the rest of the views to the menu. views not implemented yet tho. 2016-11-18 12:03:21 -08:00
6536474b94 moved stuff around again. WPF didnt like things once they were moved. Also wired up Join dialog. 2016-11-18 11:33:46 -08:00
ab4021dd0e Do packet MAC check before locallyValidate(), and add timing measurement in selftest. 2016-11-18 11:09:19 -08:00
1fcbb1fbed Proactively auto-load designated upstreams. 2016-11-18 10:39:26 -08:00
39333c9e8e Modify unite() to deal with a second layer of upstreams. 2016-11-17 16:59:04 -08:00
1615ef1114 Rename getBestRoot() etc. 2016-11-17 16:31:58 -08:00
bf8d71e82c Add notion of upstream that is separate from root in Topology, etc. 2016-11-17 16:20:41 -08:00
a4c2740852 added skeletons for join and about windows. moving things around a little bit too 2016-11-17 14:25:55 -08:00
afa1b8cb2d add timeouts to requests to the json api 2016-11-17 14:23:04 -08:00
5447c01e1f can finally join/leave networks by clicking on them in the context menu 2016-11-17 14:13:05 -08:00
b4bacd50a1 Merge branch 'dev' into systemtray 2016-11-16 16:23:56 -08:00
3c248ec61a handle removing of networks we are no longer connected to from the UI 2016-11-16 15:50:56 -08:00
78a8ceda0e IP addresses now selectable in Windows UI 2016-11-16 15:11:28 -08:00
14bf326de2 make device ID selectable 2016-11-16 14:50:25 -08:00
dc549b7f3c add JSONDB.cpp 2016-11-16 14:50:03 -08:00
456c7ca661 only changed items in the full network list are updated now 2016-11-15 16:55:24 -08:00
bab75186f5 make some fields in the network list selectable 2016-11-15 15:51:25 -08:00
07b2a3818c Fix TTL scaling in cert. 2016-11-15 14:26:05 -08:00
15c6e2ec70 Fix member deauthorization time threshold bug. 2016-11-15 14:06:25 -08:00
5bd8968eb8 Add rules engine debugging switch to make-linux.mk 2016-11-15 11:50:53 -08:00
4ad942522b Kill unnecessary check in another spot. 2016-11-14 15:57:46 -08:00
b6c99ba3ef Add (currently undocumented) option to allow management from certain networks. 2016-11-14 15:47:06 -08:00
ee5bd57d40 We don't bind to non-local IP for TCP yet, but eliminate double check. 2016-11-14 15:29:36 -08:00
6445337a32 looks like a garbage file got committed. deleting 2016-11-14 15:02:40 -08:00
f20c7303e8 remove timer thats no longer needed 2016-11-14 14:58:57 -08:00
c4c8ea62e2 Added network monitor pub/sub class 2016-11-14 14:56:36 -08:00
71aadcbecb fix serialization issue.
Apparently the JSON parser uses this same serialization method under the hood to create objects from JSON.
2016-11-10 15:21:54 -08:00
fd71ceeab5 menu now dynamically populates the network list 2016-11-10 14:17:57 -08:00
e26bee45fb Multithreading in network controller. Threads are only started if controller is used. 2016-11-10 13:57:01 -08:00
1b10d3413a Use circuit breaker only for requests. 2016-11-10 13:08:43 -08:00
f0fcd222a1 Actually push updates when things change. 2016-11-10 12:54:43 -08:00
298e4a9f14 Also avoid sending tags and caps to old members since there is no point. 2016-11-10 12:33:09 -08:00
12d32b9311 Small fix to send pushes if not a reply. 2016-11-10 11:57:45 -08:00
226123ca08 Refactor controller to permit sending of pushes as well as just replies to config requests. 2016-11-10 11:54:47 -08:00
5ebf5077f5 Log last meta-data in controller, and ease up just a bit on keepalives. 2016-11-09 17:11:10 -08:00
e1c930f1b7 update JNI wrapper to reflect removal of lastMulticastFrame and lastUnicastFrame from ZT_Peer struct 2016-11-09 16:33:01 -08:00
c61ca1dea2 Keep connections up for netconf stuff as well as frames. 2016-11-09 16:04:08 -08:00
eea712a1ae Field in wrong place fixed. 2016-11-09 13:26:14 -08:00
1ebfca666d Memo-ize some computed stuff to control CPU utilization. 2016-11-09 12:34:20 -08:00
005b5aacaf rename 2016-11-09 10:32:18 -08:00
7cf3d2caa1 Network list window opens with click on the menu item 2016-11-08 16:31:07 -08:00
e1f9f7b6dc turn APIHandler into a singleton 2016-11-08 15:50:08 -08:00
6b0543ba27 starts up to a toolbar icon with context menu. still much more to do 2016-11-08 14:54:55 -08:00
3d948a930e Send a blanket rule to old versions. New versions will still bidirecitonally enforce on the inbound side. 2016-11-08 14:24:30 -08:00
6f3595bfd2 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-11-08 12:41:32 -08:00
4524899e4d Update LM time on members on request. 2016-11-08 12:41:27 -08:00
54206fd44d add NotifyIcon NuGet package for tray icon support 2016-11-08 11:24:12 -08:00
6d8c8f9fd1 update JSON library to latest 2016-11-08 11:23:15 -08:00
00e1b0ed10 added docs for allowManaged, allowGlobal, allowDefault 2016-11-08 11:00:48 -08:00
4f8feaa530 update JSON API docs for OneService 2016-11-08 10:23:25 -08:00
0324e6ca3d Merge pull request #402 from bobberb/patch-1
Typo fix line 77
2016-11-08 08:32:47 -08:00
d773ab2806 Merge pull request #407 from misuzu/chownfix
Chown fix
2016-11-08 08:32:31 -08:00
8e76363ccf Fix chown on /var/lib/zerotier-one 2016-11-08 16:50:32 +02:00
360c84e035 Minor fixes. 2016-11-08 00:05:18 +00:00
4868d21526 Bug fixes in controller refactor. 2016-11-07 23:49:03 +00:00
c802811ad2 Added a file copy util for Windows UI
Copies the authtoken.secret file into a private local folder for the user so that the UI doesnt have to be run with Admin privileges.
2016-11-07 14:09:01 -08:00
5f63d5039b Bug fixes, self test of JSONDB disabled by default. 2016-11-07 14:01:23 -08:00
a454a37a6e Self test JSONDB. 2016-11-07 13:27:17 -08:00
a78d7311a6 Fix network list API call. 2016-11-04 16:23:41 -07:00
08ff666e99 . 2016-11-04 16:14:58 -07:00
0d108d37f6 . 2016-11-04 16:12:44 -07:00
cae9041c2a . 2016-11-04 15:52:01 -07:00
330a07a554 cleanup 2016-11-04 15:48:23 -07:00
7729cbe313 Fix ambiguous error on some compilers. 2016-11-04 15:34:49 -07:00
3e865067be Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-11-04 15:18:35 -07:00
b03c7b2f30 Refactor controller to use split-out DB for better performance and less ugly. 2016-11-04 15:18:31 -07:00
1ab9c43135 wire up allowDefault, allowManaged, allowGlobal, allowDefault options 2016-11-04 14:50:07 -07:00
efcc24a76b increase window width so IPv6 addreses don't wrap 2016-11-04 14:49:15 -07:00
4762311977 work in progress windows UI update 2016-11-04 12:39:57 -07:00
ab2ccb094a Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-11-03 14:44:49 -07:00
3c00cd0f88 Separate out JSON store from controller code. 2016-11-03 14:17:46 -07:00
a7718bae39 link in notelemetry.obj even though Microsoft said CRT telemetry would be disabled in VS2015 Update 3. Just in case. 2016-11-03 12:25:09 -07:00
8ffae313fd add new files & remove old ones from VS project. Now builds & runs on Windows again 2016-11-03 12:10:50 -07:00
8cced06a2d upgraded vcxprojs to VS2015. got the tap driver building. 2016-11-03 10:04:50 -07:00
965399ba0c fix a few warnings 2016-10-31 15:16:42 -07:00
231cc11a62 Update path to nkd-build 2016-10-27 14:28:42 -07:00
1afa9e992c add color to success output in slack 2016-10-27 14:01:00 -07:00
be543c4039 use internal changelog library 2016-10-25 15:51:30 -07:00
7e7462b39e attempting #2 2016-10-25 15:01:59 -07:00
d2ee37a3e0 attempting to add the changelog to the starting build slack message 2016-10-25 14:58:27 -07:00
1fcedb8d16 fix duplicate branch name in slack 2016-10-25 14:38:57 -07:00
5c476391da fixed build number in slack messages 2016-10-25 14:37:19 -07:00
6cb23e7069 added slack notifications 2016-10-25 14:35:31 -07:00
c976b87ac7 -scheme -> -target 2016-10-25 13:33:50 -07:00
af2bdfc421 dir directive appears to create a tmpdir rather than just cd 2016-10-25 13:14:28 -07:00
b01c551197 fix directory directive in jenkinsfile 2016-10-25 13:04:24 -07:00
df6d3ca66b add stage for building the new macOS UI in Jenkins 2016-10-25 12:58:54 -07:00
5be7374f56 added macOS build for jenkins 2016-10-25 12:40:03 -07:00
7300005398 fixed one more stage syntax for jenkins build 2016-10-25 11:21:39 -07:00
6cd36edf45 Update stages 2016-10-25 11:18:26 -07:00
604a0b1fe6 added Jenkinsfile for jenkins build config 2016-10-25 11:10:21 -07:00
046d5bb9ff Typo fix line 77 2016-10-23 15:45:45 -04:00
0e8442064e Merge pull request #376 from siigna/debian
Move debian/format to debian/source/format
2016-10-21 13:39:55 -07:00
ea1f2762cf Merge pull request #401 from zielmicha/dev
Run as nonroot user on Linux (with CAP_NET_ADMIN and CAP_NET_RAW added).
2016-10-21 13:37:27 -07:00
0f3095f130 Merge remote-tracking branch 'macui/master' into macui-merge
# Conflicts:
#	.gitignore
2016-10-17 14:50:18 -07:00
7b7ec13349 Prepare for merging into main ZeroTier repo 2016-10-17 14:44:32 -07:00
7025c7090b set proper copyright/license in code files 2016-10-17 14:43:24 -07:00
7c12991f57 wasn't setting the Connected checkbox to off if the network wasn't connected 2016-10-17 13:48:25 -07:00
f444da80bc Add a 2 second delay before the About window shows up on the first run 2016-10-17 13:43:44 -07:00
ed58467d12 Clicking "Join" to join a new network now properly closes the popover 2016-10-17 13:43:27 -07:00
c44c3b0530 cleanup 2016-10-17 12:31:59 -07:00
46e9c1195c more removal of NSMenuDelegate 2016-10-17 12:29:28 -07:00
4730111492 updated project settings for Xcode 8.0 2016-10-17 12:27:07 -07:00
a813e29491 Don't need AppDelegate to be a NSMenuDelegate 2016-10-17 12:26:48 -07:00
344a25c133 Run as nonroot user on Linux (with CAP_NET_ADMIN and CAP_NET_RAW added).
- ZT will only drop root privileges if zerotier-one user exists. It is created by
Debian postinst script - in other cases the user has to be created by administrator.
- Linux >=4.3 with ambient capabilities is required, otherwise ZT will silently
- "-U" option now also disables privileges dropping
2016-10-16 13:53:44 +02:00
772599a6fc Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2016-10-13 15:18:12 -07:00
3a3fe272bb add Revocation.cpp to android build 2016-10-13 15:18:07 -07:00
88e3fe699c Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-10-13 15:17:27 -07:00
27d997a2e5 . 2016-10-13 15:17:17 -07:00
8809c6d122 link atomic library. seems to be required in the latest Android NDK 2016-10-13 14:34:54 -07:00
6469aa9df9 typo 2016-10-13 14:28:39 -07:00
ce6b5bc6f5 . 2016-10-13 14:21:24 -07:00
4f3775bb86 Fix ICMP match. 2016-10-13 14:21:00 -07:00
2cb760e0ac Fix ICMP json. 2016-10-13 14:14:46 -07:00
8850a8610a Fix filter trace. 2016-10-13 13:59:17 -07:00
2d6a4e5974 cleanup 2016-10-13 13:52:45 -07:00
93b4ac5cb2 Remove unused POW code, will revisit later. 2016-10-13 13:17:30 -07:00
e2509af163 Fix bug in default rules init in new networks. 2016-10-12 12:30:32 -07:00
3f4c166861 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-10-11 12:00:38 -07:00
e53f63ca87 Broke down and added an OR to the rules engine. It is now possible to have a series of MATCHes that are ORed. 2016-10-11 12:00:16 -07:00
6a50291aa2 Fix the case for InetAddress::containsAddress for IPv6 route of :: 2016-10-07 14:29:06 -07:00
e59ed3e68f Fix size of neighbor solicitation struct 2016-10-07 10:03:07 -07:00
45c4ccb153 Add a tags both equal match. 2016-10-05 16:38:42 -07:00
adeb7e7da0 Make capability flags match more user-friendly and appropriate since "match any flag" is generally what we want. 2016-10-05 12:54:46 -07:00
f1c8706485 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-10-05 10:12:16 -07:00
d5f4d381d0 Go ahead and loop back packets whose destination is self. Some OSes require this since they aactually follow the full network path even for local IPs. 2016-10-05 10:12:06 -07:00
69c5976775 fix typo in assert size 2016-10-04 17:35:52 -07:00
988049f39b Add new rule to rules engine: random match. 2016-09-30 14:07:00 -07:00
6651b8310e Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-09-30 13:47:40 -07:00
0843ed62fa Network delete fix. 2016-09-30 13:47:30 -07:00
d817039f79 Add IPv6 Neighbor Discovery code. Not yet tested. 2016-09-30 13:18:17 -07:00
f0794e09b7 Controller cleanup. 2016-09-30 13:04:26 -07:00
9eaa3756f8 Fix deadlock-causing regression in Network. 2016-09-30 12:22:54 -07:00
1eeebba2f7 Drop old /active path from network. 2016-09-29 17:59:27 -07:00
2fc3d12fb6 Minor tweaks to member code in controller, and fix Linux build. 2016-09-29 14:48:39 -07:00
4fe9a4fe83 Fix memory leak. 2016-09-28 16:13:59 -07:00
01129d02b3 hashCode() for InetAddress 2016-09-28 13:45:25 -07:00
e1fbf7b34c Check multicast limit on send after NDP emulation code. 2016-09-28 12:21:08 -07:00
7e90ab3534 TRACE verbosity increase on exceptions in NETWORK_CREDENTIALS. 2016-09-28 11:06:44 -07:00
5ee1ccd659 Send need credential error on more cases. 2016-09-27 16:41:08 -07:00
0b44919ba2 Clusters can send multiple OKs so we must allow this. 2016-09-27 16:33:37 -07:00
9f550292fe Simply network auth logic and always sent error on auth failure even for unknown networks to prevent forensics. 2016-09-27 13:49:43 -07:00
5ba7ca91c0 TRACE build fix. 2016-09-27 12:44:44 -07:00
cc4bacc199 Cleanup, and implement compression disable flag for networks. 2016-09-27 12:22:25 -07:00
15c07c58b6 Refactored network config chunking to sign every chunk to prevent stupid DOS attack potential, and implement network config fast propagate (though we probably will not use this for a bit). 2016-09-27 11:33:48 -07:00
236fdb450c cleanup attic 2016-09-27 07:02:16 -07:00
7e4b6b594b It now builds. 2016-09-26 17:05:39 -07:00
eac3667ec1 Bunch more refactoring and work on revocations, etc. 2016-09-26 16:17:02 -07:00
e35bca2c3c Move debian/format to debian/source/format
Fixes the following error during package building:
dpkg-source: warning: no source format specified in debian/source/format, see dpkg-source(1)

Reference:
https://www.debian.org/doc/manuals/maint-guide/dother.en.html#sourcef
2016-09-23 20:13:37 -07:00
46049a1ef6 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-09-23 16:08:44 -07:00
1f74dd4589 Revocation work in progress, add WATCH which is TEE with implicit rate sync (thanks JG@DCVC!), and clean up some cruft in Network. 2016-09-23 16:08:38 -07:00
40d3993ceb java code still needed to reflect PEER_ROLE_RELAY rename to PEER_ROLE_UPSTREAM 2016-09-21 14:12:20 -07:00
0564bb3b35 added missing copyright/license info from ZT_jniutils 2016-09-21 14:09:46 -07:00
29711e123f Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-09-20 21:21:43 -07:00
d3524f3609 Refactor COM stuff a bit, and respond to COM requests a bit more readily for rapid setup. Will need to revisit later. 2016-09-20 21:21:34 -07:00
d87f0293e3 Don't print a few error messages when they don't matter. 2016-09-19 13:40:53 -07:00
5fadd8bdd2 ZT_PEER_ROLE_RELAY -> ZT_PEER_ROLE_UPSTREAM in JNI glue 2016-09-19 12:54:19 -07:00
3366b53247 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2016-09-18 18:10:03 -07:00
68e549233d Revise bearer token code in controller, and add relay policy as a meta-data item presented to controller by nodes (to facilitate future meshiness). 2016-09-15 13:17:37 -07:00
24fce0be86 No, definitely have to back out GitHub issue #385 (non-bisected routes) since this breaks IPv6 on OSX and probably IPv4 too if you were to encounter a 6-only situation. 2016-09-14 22:23:56 -07:00
740b34124f Naming... 2016-09-14 17:35:50 -07:00
15402933bc Add physical MTU recommendation hint to network config via API. 2016-09-14 16:55:25 -07:00
8d0b2b781e Route management bug fixes. 2016-09-13 16:25:48 -07:00
83abc00aae docs 2016-09-13 14:58:59 -07:00
5b6d27e659 Implement relay policy, and setting multicast limit to 0 now disables multicast on the network as would be expected. 2016-09-13 14:27:18 -07:00
ced8dfc639 Try a version of GitHub issue #385 (non-bifurcated default if not present) on Mac. This version adds the bifurcated routes always but also adds a device-specific non-bifurcated route. Will have to see if this still interferes with OSX route settings, since by definition device specific routes should not conflict with general routes. 2016-09-13 11:07:59 -07:00
8ef0e4bbaf Get rid of HELLO rate gate on path since its basically worthless. There are 65535 ports per IP. 2016-09-13 10:46:36 -07:00
0da9a9a3e0 Set trustEstablished in a few more places. 2016-09-13 10:33:03 -07:00
cba37c6107 Add a few more rate limit gates for anti-DOS hardening. 2016-09-13 10:13:23 -07:00
ea1da3321a Rate gate requests for COM. 2016-09-12 15:19:21 -07:00
34b146f28b Back out of GitHub issue #385 for now and maybe for this release. Would be nice but it is non-critical and rules are the priority. Current implementation bangs heads with OSX route assignment on WiFi join, etc. 2016-09-12 14:56:18 -07:00
fb46a546db Just always do route bifurcation on Linux for now... basically the old behavior. 2016-09-09 12:53:44 -07:00
debc4c45ee Set trust established flag in MULTICAST_GATHER. 2016-09-09 11:45:34 -07:00
ab9afbc749 (1) Public networks now get COMs even though they do not gate with them since they will need them to push auth for multicast stuff, (2) added a bunch of rate limit circuit breakers for anti-DOS, (3) cleanup. 2016-09-09 11:36:10 -07:00
ef87069957 Fix gating of multicast GATHER replies since these can come from upstream, etc., and fix an issue with sending ECHO to recheck marginal paths. 2016-09-09 09:32:00 -07:00
0d4109a9f1 More refactoring to clean up code, and add a gate function to make sure we do not handle OK packets we did not expect. This hardens up a few potential edge cases around security, since such messages might be used to e.g. pollute a cache and DOS under certain conditions. 2016-09-09 08:43:58 -07:00
16df2c3363 Clean up handling of COMs, network access control, and fix a backward compatiblity issue. 2016-09-08 19:48:05 -07:00
5ed5b22525 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2016-09-08 17:45:46 -07:00
dccca7df1a another couple of missing semicolons 2016-09-08 17:45:40 -07:00
1f6b13b7fd Fix bug causing null addresses to get in memberships[] hash. 2016-09-08 16:09:56 -07:00
d23ade879b Do not bifurcate if not replacing an existing route. (Still need to tie up Linux and Windows.) 2016-09-08 15:42:46 -07:00
8afdb0aa65 GitHub issue #346 2016-09-07 17:07:06 -07:00
daf8a66ced More correct and efficient to initialize member relationship push stuff lazily when member is learned. 2016-09-07 15:47:20 -07:00
20278bb9e4 Also send MULTICAST_LIKEs to controllers. 2016-09-07 15:34:34 -07:00
c7a4da3dd3 Turns out we do not need to pass network to receive(). 2016-09-07 15:24:53 -07:00
1908aa55f5 Refactor MULTICAST_LIKE pushing to eliminate redundant and unnecessary pushes and simplify code. 2016-09-07 15:15:52 -07:00
1c08f5e857 Tweak some expire times. 2016-09-07 12:25:19 -07:00
c9ee8612e4 Credential TTL (tags/capabilities) should be credential time max delta, since we could get pushed one that is newer. 2016-09-07 12:12:52 -07:00
a7d988745b Use ECHO instead of HELLO where possible. 2016-09-07 12:01:03 -07:00
a9f404aac3 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-09-07 11:20:47 -07:00
ff9f8b1c2b Typo fix. 2016-09-07 11:15:36 -07:00
b5c86b6ba4 Bunch more path refactoring. Peers no longer forget paths, but do not normally use expired paths. Expired paths might still be tried if nothing else is reachable. 2016-09-07 11:13:17 -07:00
407ad659ea Reflect changes to strut ZT_PeerPhysicalPath 2016-09-06 17:59:01 -07:00
f2d2df2b11 Cluster build fix. 2016-09-06 15:06:07 -07:00
48a374c82c (1) fix crazy bug introduced in doRENDEZVOUS(), (2) reclaim Paths after paths[] condense, (3) fix an edge case around symmetric NAT and external IP change detection. 2016-09-06 14:05:58 -07:00
deee39343e Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-09-06 12:45:37 -07:00
8a2e8bd585 Rework how paths are set as remote cluster preferred. The code is now clearer and cluster preference indications are now very sticky as they should be. 2016-09-06 12:45:28 -07:00
43780742b0 comments, docs 2016-09-06 11:10:04 -07:00
68a966fa55 Merge branch 'dev' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into dev 2016-09-05 16:19:10 -07:00
43b3ec4b1a forgot a semicolon in a JNI java type specifier. 2016-09-05 16:19:04 -07:00
dcf1f70868 re-adding file 2016-09-05 16:12:29 -07:00
598ca48ed6 Attempting to fix VirtualNetworkRoute having 2 entries in git. Yay non case sensitive filesystems 2016-09-05 16:12:06 -07:00
3790ebe77a Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-09-05 15:49:07 -07:00
d7f2287ce9 More tweaks to path behavior. 2016-09-05 15:47:22 -07:00
9f717e79ea Fixing filename again.... 2016-09-05 14:42:36 -07:00
26d43c9b06 fix capitalization on file 2016-09-05 14:27:44 -07:00
8682c90c7d ensure routes are also equal when checking for equality on VirtualNetworkConfig objects 2016-09-05 14:10:07 -07:00
d063f583ee Added VirtualNetworkRoute class and added it to VirtualNetworkConfig 2016-09-05 13:52:29 -07:00
eebcf08084 Tweaks to new Path code for dual-stack operation, and other fixes. 2016-09-03 15:39:05 -07:00
01aa469591 Remove debug line. 2016-09-02 14:26:04 -07:00
4992ac2d9f Cluster sub-optimal is in fact necessary... 2016-09-02 14:20:55 -07:00
412979ba8f Attempt to reactivate dead paths. 2016-09-02 13:55:33 -07:00
4f8253dcdb Tweaks to path handling... 2016-09-02 13:33:56 -07:00
4931e44998 Implement "weak pointer" behavior on Topology Path canonicalization hash table. 2016-09-02 12:34:02 -07:00
d1101441b3 Tweak some timings. 2016-09-02 11:54:59 -07:00
e8f6b4b5d3 Rest of big Path canonicalization refactor. 2016-09-02 11:51:33 -07:00
94263ffcc1 Added error handling messages 2016-09-01 19:02:27 -07:00
a3bdae9735 Work in progress: Path canonicalization refactor. 2016-09-01 15:43:07 -07:00
d5e6f59004 . 2016-09-01 13:45:32 -07:00
22271f2a49 Cleanup. 2016-09-01 13:36:41 -07:00
8b6d23b9f6 Optimize filter code a bit, and add a network-level setting for what should happen if an unsupported or unknown MATCH is encountered in a rules table. 2016-09-01 12:07:17 -07:00
25056de5d3 Also need to send credentials when TEEing and REDIRECTing. 2016-08-31 17:56:59 -07:00
994b25af4e Simplify some logic. 2016-08-31 17:45:55 -07:00
74afef8eb1 Think through and refine a few things in rules, especially edge case TEE and REDIRECT behavior and semantics. 2016-08-31 16:50:22 -07:00
54489a7f61 rename SAMENESS to DIFFERENCE which is less confusing 2016-08-31 14:14:58 -07:00
8e3004591b Add overlooked MATCH_ICMP to rule set. 2016-08-31 14:01:15 -07:00
2ff2a8fd9a Cluster build fixes and warning elimination. 2016-08-31 09:38:21 -07:00
c2a01f6db4 Added a path for error handling when fetching data from the ZeroTier daemon
Still need to wire up error messages to the user.
2016-08-30 20:28:52 -07:00
7a00036954 Tweak log length to fit JSON for members within two 4096-kb blocks. 2016-08-29 18:10:02 -07:00
914c42537c Type fixes. 2016-08-29 17:48:36 -07:00
cb63babac4 Debug output fixes. 2016-08-29 16:38:10 -07:00
ac1c127b68 Debug output fixes. 2016-08-29 16:24:08 -07:00
cb82193333 Debug output fixes. 2016-08-29 16:19:26 -07:00
f0636ffd4a EXT_FRAME messages should always be accepted if we are the destination for a matching TEE or REDIRECT rule. 2016-08-29 15:54:06 -07:00
51a420671f Make rules engine debug a bit more verbose. 2016-08-29 15:17:34 -07:00
77c2bf3ad9 Kill dead field from network JSON. 2016-08-29 14:47:19 -07:00
7223685b96 . 2016-08-26 15:30:20 -07:00
e7dff1c785 Change logic a little for self-as-destination in TEE and REDIRECT. 2016-08-26 15:28:31 -07:00
a5383d83d8 Do not TEE or REDIRECT to self. 2016-08-26 15:25:00 -07:00
a3c7627acf Push more than one packet for credentials if we happen to have a whole lot. Should not happen often but might if a member has tons of tags. 2016-08-26 14:43:16 -07:00
297b1b4258 Another tiny API bug fix. 2016-08-26 14:16:55 -07:00
35ac995d05 Fix setting of v6AssignMode in controller. 2016-08-26 14:04:27 -07:00
6bd5aba4fa fix frame size range bug 2016-08-26 13:26:26 -07:00
fb5217761b Add missing names in filter debug code. 2016-08-26 13:20:55 -07:00
90f3e94565 Always output trace info when debugging rules. 2016-08-26 12:21:44 -07:00
ded5a53a6c Documentation updates, add rules engine revision to network config request meta-data. 2016-08-26 10:38:43 -07:00
d637988ccf Fix chicken or egg problem in tags, and better filter debug instrumentation. 2016-08-25 18:21:20 -07:00
858e8c5217 one more... 2016-08-25 16:28:54 -07:00
df1ce856c9 A little bit more controller code cleanup. 2016-08-25 16:25:28 -07:00
b5e0d014ab Controller bug fixes 2016-08-25 16:08:40 -07:00
5eaf397a94 Add a debug log feature in the filter, which only works if enabled in Network.cpp. 2016-08-25 13:31:23 -07:00
1814016eb7 Add daemon thread to controller and move network member cache refreshes there. 2016-08-25 11:26:45 -07:00
6ecb42b031 docs and null check in controller code 2016-08-25 10:46:03 -07:00
584228b2b5 Dead code removal, and get rid of reliable() because we will no longer make that distinction. 2016-08-24 17:56:35 -07:00
cd3683f2ba Fix a missing receive(). 2016-08-24 17:50:51 -07:00
347ebcd899 Set trust flag in network controllers if remote query is accepted to allow NATed network controllers to better traverse. 2016-08-24 17:48:13 -07:00
e52c2c41ec Add a circuit breaker to prevent too many credentials from being stored per member. 2016-08-24 17:24:35 -07:00
95ff057e04 Increase rule limits a little since chunking in netconf can accomodate this. 2016-08-24 17:16:26 -07:00
60bc291414 Add noAutoAssignIps for member of networks. 2016-08-24 17:05:43 -07:00
c476285bd6 Harden PUSH_DIRECT_PATHS and simplify things by only doing it on receive when hops>0 and trust has been established. 2016-08-24 16:16:39 -07:00
63e8ad4cc3 TRACE stuff. 2016-08-24 15:45:37 -07:00
2cdda38dc4 It basically works... at least on current controllers. 2016-08-24 15:26:18 -07:00
ccea3d04d6 Push NETWORK_CONFIG_REFRESH on POSTs to /member/... in controller. 2016-08-24 14:28:16 -07:00
90bd3e07a0 Remove http-parser from RPM spec. 2016-08-24 13:53:24 -07:00
8e3463d47a Add length limit to TEE and REDIRECT, and completely factor out old C json-parser to eliminate a dependency. 2016-08-24 13:37:57 -07:00
8d594f8b53 cleanup 2016-08-23 16:05:10 -07:00
5f4df0c6a9 Controller cleanup and perf improvements. 2016-08-23 15:30:36 -07:00
0ee4d3554a Stub out USER_MESSAGE. 2016-08-23 14:38:20 -07:00
0a7a33ef8f Instantaneous blacklisting and credential revocation. 2016-08-23 13:46:36 -07:00
32fa061700 Compute credential TTL et al. 2016-08-23 13:02:59 -07:00
7036831203 Sign Dictionary in doNETWORK_CONFIG_REQUEST. 2016-08-23 11:57:56 -07:00
68b4ca9b31 Cleanup. 2016-08-23 11:52:10 -07:00
0dfc08b317 Tidy up a few minor protocol things, improve documentation in Packet.hpp. 2016-08-23 11:29:02 -07:00
77f7dcf40a Obsolete "test network" removal. 2016-08-23 09:39:38 -07:00
9a3c652a51 Get rid of expiration in Capability and Tag and move this to NetworkConfig so it can be set network-wide and reset if needed. Also add NetworkConfig field for this and centralize checking of credential time validity. 2016-08-22 18:06:46 -07:00
6db47de25e Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2016-08-22 14:26:17 -07:00
b0d888d235 Signing of Capability and Tag objects. 2016-08-22 14:25:59 -07:00
af53e63ae2 Kube tut update 2016-08-22 11:33:10 -07:00
35d5ed9c2b version bump i forgot to commit 2016-08-19 18:13:00 -07:00
9827b8991d Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2016-08-18 18:18:56 -07:00
4dce71879f . 2016-08-18 18:18:50 -07:00
727fb197d8 kube tutorial update 2016-08-18 15:32:26 -07:00
c2f10a52de zt-kubernetes tutorial update 2016-08-18 15:16:24 -07:00
cf2ec0797e zt-kubernetes tutorial update 2016-08-18 15:15:38 -07:00
6443049f86 Merge branch 'edge' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into edge 2016-08-18 15:13:49 -07:00
44bee4e3ff zt-kubernetes tutorial update 2016-08-18 15:13:43 -07:00
212a5af9a5 Capabilities and tags in POST JSON. 2016-08-18 14:37:56 -07:00
1cadbfb4d1 Little fixes. 2016-08-18 13:47:02 -07:00
4729fec2eb Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2016-08-18 13:00:00 -07:00
f119c4a456 Cache network members for performance, add network non-persisted fields. 2016-08-18 12:59:48 -07:00
3e261fb999 updated entrypoint 2016-08-17 18:33:49 -07:00
0fd3afe2c8 examples files for kube int 2016-08-17 18:03:34 -07:00
9dc507c9ae examples files for kube int 2016-08-17 17:52:19 -07:00
5d37eabb59 Merge branch 'edge' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into edge 2016-08-17 17:43:44 -07:00
169664ffc2 examples files for kube int 2016-08-17 17:43:34 -07:00
4c0a7c0fb2 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2016-08-17 17:37:48 -07:00
faa9a06bf5 Controller fixes... 2016-08-17 17:37:37 -07:00
183434d30e examples files for kube int 2016-08-17 17:29:14 -07:00
c84ce76c59 examples files for kube int 2016-08-17 17:22:05 -07:00
1833c61556 kubernetes tutorial update 2016-08-17 15:35:00 -07:00
ba78676ace kubernetes tutorial update 2016-08-17 15:28:48 -07:00
0d37b7b665 zt-kubernetes tutorial outline 2016-08-17 15:12:48 -07:00
1254dece5b Linux build fixes, and build controller. 2016-08-17 14:19:29 -07:00
b7ebf6edbf Cleanup and log how member was authorized. 2016-08-17 13:54:32 -07:00
b72847d504 Finally implement network join auth tokens, at least at the protocol level. 2016-08-17 13:41:45 -07:00
168b86fdcd Controller docs and API fix. 2016-08-17 12:27:07 -07:00
a13f4d8353 We now always build the controller in ZeroTier One, at least for desktop and server targets. Also means that ZeroTier One now requires C++11. (Still keeping C++11 out of the core in node/ though.) 2016-08-17 10:42:32 -07:00
cc808cc2dd Rules parsing stuff. 2016-08-17 10:25:25 -07:00
ce001198d8 . 2016-08-16 16:57:45 -07:00
c0639ccd37 Just about ready to test. 2016-08-16 16:46:08 -07:00
58701c1ca8 . 2016-08-16 14:08:08 -07:00
402d99ea8d C++11 mode build fix. 2016-08-16 14:07:11 -07:00
b08ca49580 More controller work -- it builds! 2016-08-16 14:05:17 -07:00
bd15262e54 Bunch of rule JSON stuff. 2016-08-15 18:49:50 -07:00
3cb2e1197f . 2016-08-12 15:32:45 -07:00
7762cd680b fix json include path in cli 2016-08-12 11:30:50 -07:00
c30f74987f Starting refactor of controller... 2016-08-12 11:30:27 -07:00
628ef14d80 added more spacing at the bottom of each network info cell 2016-08-11 17:50:15 -07:00
bc48a097f8 add @2x versions of menu bar icon 2016-08-11 17:41:54 -07:00
dd21c8a577 Rev nlohmann/json 2016-08-10 17:27:46 -07:00
7d906df805 Better instrumentation for filter, and filter bug fixes. 2016-08-10 14:27:52 -07:00
d166b494ee Rule parse fix. 2016-08-10 13:41:22 -07:00
81959f14af Refactor and redesign symmetric NAT predictor. This is cleaner. 2016-08-10 10:28:54 -07:00
2300f3c92b bump build number 2016-08-09 20:04:33 -07:00
73fd934fec * Fixed menu icon size
* Added icon for dark mode
* Added detection for interface mode changing from light to dark and adjusting the icon accordingly
2016-08-09 20:02:12 -07:00
a7b635a980 add border around About web view. added padding to text div in the about page 2016-08-09 19:03:09 -07:00
91b8d6f34f [pasteboard declareTypes] needs to be called before every time you set a string to the pasteboard. 2016-08-09 18:03:48 -07:00
c9d7845fea Minor bug fix and some instrumentation stuff for testing. 2016-08-09 17:00:01 -07:00
0b0cda2be4 ZT_TRACE fix. 2016-08-09 15:55:41 -07:00
e1310a764a More cleanup and removal of cruft due to obsolete network-specific relays (will be replaced with federation stuff). 2016-08-09 15:45:26 -07:00
dbf3e6c3c9 Dead code removal. 2016-08-09 15:01:46 -07:00
dee7f75f7e Minor cleanup. 2016-08-09 14:46:11 -07:00
774c7e0ea5 Put CONFIG_REFRESH back. 2016-08-09 13:52:08 -07:00
4d498b3765 Handling of multi-part chunked network configs on the inbound side. 2016-08-09 13:14:38 -07:00
bcd05fbdfa Chunking of network config replies. 2016-08-09 09:34:13 -07:00
2ba9343607 Encode and decode of tags and capabilities in NetworkConfig. 2016-08-09 08:32:42 -07:00
8ae07fb9c9 build number bump 2016-08-08 19:04:50 -07:00
13682bd919 Change Deployment Target to 10.7. Apparently going below 10.10 was only an issue with Swift 2016-08-08 19:02:09 -07:00
b5cab8afaa update build number 2016-08-08 17:46:01 -07:00
c15c9775bd explicitly link to WebKit framework 2016-08-08 17:45:52 -07:00
51cf49a24f cleanup 2016-08-08 17:40:22 -07:00
00fd9c3a15 It builds... almost ready to test some rules engine stuff. 2016-08-08 17:33:26 -07:00
8007ca56aa Refactor and tie-up of capabilities and tags and packet evaluation points. Some optimization is possible here but it is minor and we will make it work first. 2016-08-08 16:50:00 -07:00
8d7f851b4e Now translated. One minor crash to figure out. 2016-08-07 20:19:36 -07:00
5b13b282ed Replace JoinNetworkViewController with obj-c 2016-08-07 19:13:12 -07:00
d965768004 Replaced the network list with Obj-C 2016-08-07 18:19:47 -07:00
a91187e60e Convert NetworkMonitor to obj-c 2016-08-07 17:25:34 -07:00
179324e44a Replace Preferences view. Removed LaunchAtLoginController and replaced with simpler code 2016-08-07 16:34:54 -07:00
c6dba50e35 replace AboutViewController 2016-08-07 15:18:32 -07:00
b51d68a419 replace ServiceCom with objc class 2016-08-06 19:45:58 -07:00
a0db48571d Convert Network to OBJC 2016-08-06 18:50:50 -07:00
4d7f625aa1 . 2016-08-05 15:55:38 -07:00
e2f783ebbd . 2016-08-05 15:02:01 -07:00
7a12d8193b Replace NodeStatus object with Obj-C Class 2016-08-04 17:55:57 -07:00
4d9b74b171 . 2016-08-04 15:27:20 -07:00
37d139177d Integrate Filter into OutboundMulticast properly. 2016-08-04 13:01:14 -07:00
8a7753cfe3 Filter cleanup, prep for filter integration in a few places. 2016-08-04 12:35:25 -07:00
331382cf2f More cleanup and a tiny federation prep item. 2016-08-04 12:14:13 -07:00
98152d974a More cleanup and removal of DeferredPackets, will do the latter in a more elegant way. 2016-08-04 11:40:38 -07:00
56febbf2ba . 2016-08-04 10:39:28 -07:00
5cf410490e . 2016-08-04 10:18:33 -07:00
404a0bbddd ... 2016-08-04 09:51:15 -07:00
f057bb63cd More work on tags and capabilities. 2016-08-04 09:02:35 -07:00
7e6e56e2bc Bunch of work on pushing and replication of tags and capabilities, and protocol cleanup. 2016-08-03 18:04:08 -07:00
67cb03742e Add tag rules and split out rule serialize/deserialize so the code can be reused. 2016-08-03 14:12:38 -07:00
a08246ce5d update build number 2016-08-02 20:30:49 -07:00
f54d5e9e8f the quest for leaks is over.
Why a singleton doesn't leak, vs calling static methods on a class is beyond me
2016-08-02 20:30:09 -07:00
91940cbcf5 Kill network preferred relays -- this feature is gone (and was seldom used anyway) in favor of federation. 2016-08-02 14:40:26 -07:00
77bd8aacd1 merge cli from edge 2016-08-02 13:50:09 -07:00
ecc1324bb0 Rules engine work: capability based security model with tags and capabilities, and some cleanup across other places. 2016-08-02 13:36:17 -07:00
d3b0081447 Cleanup... 2016-07-28 12:09:58 -07:00
22e44c762b More rules engine work: key/value pair matching for microsegmentation. 2016-07-28 10:58:10 -07:00
78e5a00a68 Only poll the ZeroTier service when the menu or Network List are visible. Reduces CPU idle prevention by a a LOT 2016-07-26 20:31:06 -07:00
b9a4d138fc only update the network list view if it's visible 2016-07-26 20:05:33 -07:00
36a9aff283 Show "About" view on first run.
Still needs some work to show up in the right place
2016-07-26 20:04:59 -07:00
e1755e569e build number bump 2016-07-26 19:16:33 -07:00
ae374a78fc add some non Lorem Ipsum content to the about page 2016-07-26 19:15:12 -07:00
62befe006d Route clicked links in the web view to the default web browser 2016-07-26 18:21:39 -07:00
1e6e112806 Dockerfile for building zerotier/zerotier-containerized for CoreOS et al. 2016-07-26 17:08:09 -07:00
830250759c Fix for running under MUSL libc (e.g. Alpine Linux) 2016-07-26 16:39:02 -07:00
13100b245c Fix for running under MUSL libc (e.g. Alpine Linux) 2016-07-26 16:36:20 -07:00
4929be08f7 Cleanup and stub out new object transfer messages. 2016-07-26 12:33:51 -07:00
088bbd1c08 Filter fixes. 2016-07-25 17:03:26 -07:00
7404eb46c4 Integration of Filter into inbound and outbound packet path. 2016-07-25 16:51:10 -07:00
eaf6d6c938 Basic L2/L3 filter for rules engine (not integrated yet) and some cleanup. 2016-07-25 15:52:16 -07:00
02d288e9d4 Merge branch 'dev' of Y:/ZeroTier/ZeroTierOne into dev 2016-07-21 20:45:17 -07:00
6f15c4a561 1.1.14 Windows version stuff 2016-07-21 20:45:05 -07:00
ae491c277e VERSION 1.1.14: bug fixes!
This version fixes two bugs: a possible infinite loop when using network-specific relays,
and a bug causing a crash on Android.
2016-07-21 20:29:15 -07:00
ebe7e15475 sys/sysctl.h is required on OSX and probably other BSD 2016-07-21 19:21:51 -07:00
dced40361b Bump version in most places to 1.1.14 2016-07-21 19:15:03 -07:00
faf864b8a2 Merge branch 'master' into dev 2016-07-21 19:07:50 -07:00
8a23d764de Merge branch 'master' of http://10.6.6.2/zerotier/ZeroTierOne 2016-07-21 19:06:31 -07:00
f21af60a13 Init trusted path count to zero. Meh. 2016-07-21 19:06:18 -07:00
10564d8e14 Init trusted path count to zero. Meh. 2016-07-21 19:05:14 -07:00
095aef5f30 Merge pull request #348 from the-maldridge/remove-sysctl
Remove explicit sys/sysctl.h includes
2016-07-21 15:16:22 -07:00
145ac31c8a Merge pull request #362 from mwarning/space-between-literal-and-string-macro
C++11 requires a space between literal and string macro
2016-07-21 15:16:05 -07:00
b7a5f783ba Merge pull request #364 from mwarning/fortify-source-needs-optimization-flag
fix _FORTIFY_SOURCE warning
2016-07-21 15:15:42 -07:00
3d25a2ea02 Merge pull request #363 from mwarning/move-declaration-out-of-scope
move sourceAddress out of scope
2016-07-21 15:15:27 -07:00
76b785c90f fix _FORTIFY_SOURCE warning
warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
2016-07-21 23:08:58 +02:00
b3073f44a2 move sourceAddress out of scope
sourceAddress is used in the catch block
2016-07-21 23:03:04 +02:00
bcdd158ad8 C++11 requires a space between literal and string macro 2016-07-21 22:41:02 +02:00
693ac4e86c add web view and placeholder about page with ZT logo and lorem ipsum 2016-07-19 19:12:41 -07:00
6320879fe1 Fix for GitHub issue #358 and bump version to 1.1.13 (dev) 2016-07-18 10:56:33 -07:00
2afe3d89d0 Merge branch 'master' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne 2016-07-14 19:29:10 -07:00
8a15b42dab switch to GCC for Android 2016-07-14 19:29:00 -07:00
4b9e84f42f docs 2016-07-14 17:47:32 -07:00
ba87640e4c Release howto for internal use. 2016-07-14 17:46:22 -07:00
a5400e0162 Windows installer now installs a batch file and Path variable settings to make zerotier-cli work in the Windows CLI (1.1.12 MSI updated on web for this too) and a Chocolatey packaging job for ZeroTier One. 2016-07-14 17:09:40 -07:00
bdc3b0834b VERSION 1.1.12: yet another minor fix to managed routes
This version just contains another minor fix to managed routes for
GitHub issue #352.
2016-07-12 15:09:44 -07:00
1a285e5342 Version bump again. Slack has updated their client twice in one day so its okay. 2016-07-12 15:03:06 -07:00
8912515011 Fix to fix to GitHub issue #352 2016-07-12 15:00:30 -07:00
6ec3464ee9 JSON fix for trusted paths (does not affect normal op) 2016-07-12 13:58:15 -07:00
4b5e43ab0d VERSION 1.1.10: minor managed route fixes
Version 1.1.10 is a minor bug fix release. It fixes the following two issues:

 * Routes are no longer added 'via' IP addresses of the current node's ZT interface.
 * IPv6 default route is now fixed on Mac.
 * IP addresses are now deleted before new ones are added to allow changes to netmask
   on Mac and some other platforms.

This version also quietly introduces a feature called trusted paths. We'll be
documenting this in our community section soon. This is an experimental feature
for in-LAN SDN use.
2016-07-12 13:37:38 -07:00
a6d9ae3a36 Man page fix on fedora-22 2016-07-12 13:30:15 -07:00
34e7c8652a Version bumps. 2016-07-12 12:30:35 -07:00
1861f67fa7 Version bump to 1.1.10 2016-07-12 12:21:36 -07:00
b5e9d3f6f4 Rename file to be intuitive. 2016-07-12 11:41:19 -07:00
9785fde32a Trusted paths work! 2016-07-12 11:40:45 -07:00
9657675755 Plumbing through trusted path stuff to OneService. 2016-07-12 11:30:22 -07:00
5d7174b162 Go back to bundling libhttp-parser on Debian, at least for our own internally-created packages, since this library has a massively unstable ABI and causes nothing but problems if referenced from the distro. 2016-07-12 10:11:00 -07:00
cdb5ceac7b Should remove old IPs before trying to add new ones. 2016-07-12 09:43:12 -07:00
23391ff9da More OSX IPv6 fixes. 2016-07-12 09:22:04 -07:00
3f2b21ce71 Do not shadow our own route twice on Mac if there is no default route. (Fix for issue found during IPv6 default route override testing.) 2016-07-12 08:55:57 -07:00
6535730255 GitHub issue #352 2016-07-12 08:42:36 -07:00
765082fdb6 Trusted path support, and version bump to 1.1.9 2016-07-12 08:29:50 -07:00
aff62e9e10 Version bump in Mac pkg. 2016-07-08 14:28:34 -07:00
2d598dd433 Automatically add symlinks to redhat distro. 2016-07-08 14:25:25 -07:00
f86e9b7df2 Bump version in RPM spec and DEB. 2016-07-08 13:57:16 -07:00
898d889537 VERSION 1.1.8: minor Linux bug fix, controller fixes, controller doc improvements
1.1.8 is a very minor update. It contains a small fix to IP address management
on Linux but other than that there are no changes to the regular ZeroTier One
code.

The 1.1.8 controller contains several fixes and improvements:

 * Network authorizedMemberCount works again
 * Managed IP addresses are pushed as long as they fall within a LAN-local managed
   route. The v4AssignMode and v6AssignMode settings only control automatic IP
   assignment from pools. In previous versions v4AssignMode had to be on for IPs
   to be pushed at all, making it impossible to just manually assign IPs.
 * IPv6 now has an auto-assign mode ('zt' to match V4) that can work alongside the
   special RFC4193 and 6PLANE modes (though it is not NDP emulated). If this is
   enabled IPv6 addresses will be auto-assigned from IPv6 ranges in the assignment
   pool list.
 * Controller documentation is MUCH better! See controller/README.md for actual
   useful information!

Finally 1.1.8 has several improvements to linux-build-farm including Debian wheezy
support.
2016-07-08 13:53:37 -07:00
0e2964261f docs 2016-07-08 13:42:04 -07:00
ffe7d8d024 docs 2016-07-08 13:40:21 -07:00
c01ebbcbde docs 2016-07-08 13:38:47 -07:00
a6e5914aa7 docs 2016-07-08 13:37:51 -07:00
6d8de214eb Docs and controller API version 2016-07-08 13:10:02 -07:00
5bf3c54cd3 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-07-08 10:08:06 -07:00
959b64777f 1.1.8 bump 2016-07-08 10:08:01 -07:00
be0af135bc update JNI code for 1.1.6 2016-07-07 20:07:07 -07:00
2d7c58540f v6AssignMode bug fix 2016-07-07 17:05:12 -07:00
951038a304 Ignore /bits in IP assignments and just copy it from the corresponding LAN-local route. Having each managed IP assignment have its own bits field was just a source of user error and poor UX and was completely worthless. 2016-07-07 16:28:43 -07:00
912ee199ed Tiny fixes to LinuxEthernetTap 2016-07-07 16:10:36 -07:00
b9329dc49a Fix to IPv6 picking for small ranges. 2016-07-07 15:55:40 -07:00
6e08e1ae97 A few controller changes: (1) assign managed IPs that are assigned regardless of "assign mode" which now only controls auto-assignment or special addressing, (2) support proper issuing of managed IPv6 IPs, (3) support IPv6 auto-assign ranges 2016-07-07 15:42:10 -07:00
dd1d2b4d00 GitHub issue #343 -- fix authorizedMemberCount 2016-07-07 14:49:54 -07:00
f6d53cc568 . 2016-07-06 18:12:31 -07:00
b6cc815447 . 2016-07-06 18:07:42 -07:00
ddbbb8afec Wheezy stuff 2016-07-06 18:04:13 -07:00
a8a497c621 Debian wheezy work. 2016-07-06 17:59:08 -07:00
1a89694980 Remove explicit sys/sysctl.h includes
Explicitly including sys/sysctl.h breaks the ability to build
against muslc.
2016-07-06 02:38:23 -05:00
5c03416e84 Actually remove http-parser-devel 2016-07-05 14:28:58 -07:00
b732c445b8 Xenial fix (clang broken) and bundle http-parser even in Fedora because it is so version sensitive. 2016-07-05 14:09:33 -07:00
97ec88e346 . 2016-07-05 12:30:58 -07:00
192bc4fcf0 More repo work. 2016-07-05 10:54:07 -07:00
0e6065e3d5 another build number bump 2016-06-30 21:25:14 -07:00
a156fec25a put node ID into the main menu.
Clicking on the menu item copies the node ID into the clipboard.
2016-06-30 21:24:45 -07:00
fe725f9995 fix a case where the "Allow Default" checkbox would be enabled when a network wasn't connected. 2016-06-30 20:35:32 -07:00
58207b30d1 now that the network details list uses the default background color of the pane its embedded in, we don't have to force to the "Light" theme, even if the user has selected the "dark" theme for the top menu bar. 2016-06-30 20:28:04 -07:00
f4192d7b9e added separator between items in the network detail list 2016-06-30 20:17:33 -07:00
e747692727 remove background from network details view 2016-06-30 20:07:22 -07:00
d786c5265f bump version number 2016-06-30 19:46:59 -07:00
ba0a45365c Work around for several strange corner cases in Automatic Reference Counting in Apple's runtime 2016-06-30 19:42:23 -07:00
fc4ea57a9c debian-stretch 2016-06-30 18:03:06 -07:00
751497a748 aptly script 2016-06-30 16:44:22 -07:00
c714e8baa6 Get rid of broken test code for controller so selftest build works with controller enabled. 2016-06-30 08:30:45 -07:00
2331a00555 Fedora-22 32-bit fix. 2016-06-29 18:53:31 -07:00
4218cd13d5 VERSION 1.1.6: route management, default route override, new IPv6 mode for Docker, and more!
(Retagged due to silly one-line bug and left over debug line... doh!)

Version 1.1.6 contains several significant improvements for use in complex network
environments along with some minor bug fixes and improvements to path stability and
dead path detection.

ROUTE MANAGEMENT AND FULL TUNNEL SUPPORT

1.1.6 is the first version of ZeroTier One to permit "full tunnel" (default route
override) operation on Linux, Mac, and Windows. This allows all Internet traffic
to be tunneled through ZeroTier while allowing ZeroTier peer-to-peer traffic to
continue to use the physical interface. 1.1.6 also brings route management support
and permissions settings for local networks to control whether networks are allowed
to modify the routing table or override default routing.

This is currently considered a beta/experimental feature and must be enabled via
the command line interface.

Route management and default route override requires support at the network controller.
When my.zerotier.com is updated and ready, we will post more information and testing
instructions at: https://www.zerotier.com/community

HIGHLY SCALABLE CONTAINER NETWORKING

1.1.6 also brings a new multicast-free (NDP emulated) IPv6 private addressing scheme
called "6plane." 6plane provides each host with a private IPv6 /80 and routes *all*
IPv6 traffic for this subnet to the host via transparent NDP emulation. This /80 can
then be assigned to Docker or other container/VM managers to assign a network-wide
IPv6 /128 to every container. Since NDP is emulated and multicast isn't needed, this
system can scale to millions of containers or more on a single backplane network with
a high degree of efficiency and reliability.

6plane also requires controller support. Look for it at my.zerotier.com once we have
upgraded our core infrastructure and web UIs.

(All hosts must be running 1.1.6 for 6plane to work properly. Other IPv6 addresses
or addressing modes are not affected and normal IPv6 NDP will continue to work
alongside 6plane in the same network.)

OTHER CHANGES

 * Upgraded bundled miniupnpc, libnatpmp, and http-parser.
 * New Debian and RPM packaging that is closer to compliance with distribution
   guidelines, and a new Dockerized Linux package build system in linux-build-farm/
   that can build every package on actual images of the correct distribution.
 * Improvements to dead path detection.
 * IPv6 now uses keepalive because a significant number of stateful IPv6 edge
   routers have very short timeouts (30 seconds or less!).
 * Significant performance improvements to network controllers under high load.
 * Enable -fstack-protector-strong for better stack canary (security) support
   in binaries. Note that this may require newer gcc/g++ or clang.

COMING SOON

The next version of ZeroTier One should have a new Mac UI. It's a system tray app
that looks and behaves a lot like the Mac WiFi pulldown menu. We'll also be adding
GUI support for default route and route management options and other new features.

Shortly after that we plan on adding full OpenFlow-like SDN rules engine support
to the ZeroTier core, making our planetary Ethernet switch a fully manageable smart
switch and enabling sophisticated security and flow rule management.
2016-06-29 18:16:58 -07:00
030dfde38e Unused printf removal while we are at it. 2016-06-29 18:14:49 -07:00
901e2fd692 Fix silly one-liner bug... retag time. 2016-06-29 18:12:35 -07:00
c03ca3c278 VERSION 1.1.6: route management, default route override, new IPv6 mode for Docker, and more!
Version 1.1.6 contains several significant improvements for use in complex network
environments along with some minor bug fixes and improvements to path stability and
dead path detection.

ROUTE MANAGEMENT AND FULL TUNNEL SUPPORT

1.1.6 is the first version of ZeroTier One to permit "full tunnel" (default route
override) operation on Linux, Mac, and Windows. This allows all Internet traffic
to be tunneled through ZeroTier while allowing ZeroTier peer-to-peer traffic to
continue to use the physical interface. 1.1.6 also brings route management support
and permissions settings for local networks to control whether networks are allowed
to modify the routing table or override default routing.

This is currently considered a beta/experimental feature and must be enabled via
the command line interface.

Route management and default route override requires support at the network controller.
When my.zerotier.com is updated and ready, we will post more information and testing
instructions at: https://www.zerotier.com/community

HIGHLY SCALABLE CONTAINER NETWORKING

1.1.6 also brings a new multicast-free (NDP emulated) IPv6 private addressing scheme
called "6plane." 6plane provides each host with a private IPv6 /80 and routes *all*
IPv6 traffic for this subnet to the host via transparent NDP emulation. This /80 can
then be assigned to Docker or other container/VM managers to assign a network-wide
IPv6 /128 to every container. Since NDP is emulated and multicast isn't needed, this
system can scale to millions of containers or more on a single backplane network with
a high degree of efficiency and reliability.

6plane also requires controller support. Look for it at my.zerotier.com once we have
upgraded our core infrastructure and web UIs.

(All hosts must be running 1.1.6 for 6plane to work properly. Other IPv6 addresses
or addressing modes are not affected and normal IPv6 NDP will continue to work
alongside 6plane in the same network.)

OTHER CHANGES

 * Upgraded bundled miniupnpc, libnatpmp, and http-parser.
 * New Debian and RPM packaging that is closer to compliance with distribution
   guidelines, and a new Dockerized Linux package build system in linux-build-farm/
   that can build every package on actual images of the correct distribution.
 * Improvements to dead path detection.
 * IPv6 now uses keepalive because a significant number of stateful IPv6 edge
   routers have very short timeouts (30 seconds or less!).
 * Significant performance improvements to network controllers under high load.
 * Enable -fstack-protector-strong for better stack canary (security) support
   in binaries. Note that this may require newer gcc/g++ or clang.

COMING SOON

The next version of ZeroTier One should have a new Mac UI. It's a system tray app
that looks and behaves a lot like the Mac WiFi pulldown menu. We'll also be adding
GUI support for default route and route management options and other new features.

Shortly after that we plan on adding full OpenFlow-like SDN rules engine support
to the ZeroTier core, making our planetary Ethernet switch a fully manageable smart
switch and enabling sophisticated security and flow rule management.
2016-06-29 15:53:46 -07:00
af2268ebd7 docs 2016-06-29 15:33:18 -07:00
b9876d1809 docs 2016-06-29 15:30:49 -07:00
e64909cdcd docs 2016-06-29 15:24:45 -07:00
ce2ad69e5f Get rid of aptly script. 2016-06-29 14:44:29 -07:00
56fb08621e amazon-2016.03 docker image 2016-06-29 14:35:53 -07:00
4457c8218d Auto-detect miniupnpc 2.0 and use it on Linux if present. 2016-06-29 13:27:10 -07:00
c862f199e3 Windows: ship it! 2016-06-29 13:22:04 -07:00
7918b26f65 Hack settings into old CLI. 2016-06-29 12:22:37 -07:00
df00d3b046 Going to have to continue to use the old MAC web-container-based UI on Macs prior to 10.10 even when the new UI comes out, and the new UI is not ready yet anyway, so resurrect this. 2016-06-29 12:00:16 -07:00
19735e7050 Revert backgrounding of controller requests hack. Controller code is not really parallel anyway and we fixed the perf problem. 2016-06-29 11:43:22 -07:00
bb63646682 Fix broken SQL in controller. 2016-06-29 11:37:28 -07:00
b4fcf2ee60 Fix a valgrind warning. 2016-06-29 11:11:16 -07:00
d9eacd1616 Controller fixes... 2016-06-29 17:02:03 +00:00
5309c7e082 Merge branch 'dev' of https://github.com/zerotier/ZeroTierOne into dev 2016-06-29 16:47:57 +00:00
dbe57742e6 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-06-29 09:45:05 -07:00
928c625e2c docs 2016-06-29 09:45:02 -07:00
1e00603241 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-06-28 16:09:41 -07:00
f6442f2752 fedora-22 2016-06-28 16:09:36 -07:00
7b7ab823b0 Fix getPeer(self) bug if I am the controller. 2016-06-28 22:49:01 +00:00
0410fd4824 Refactor recent member request history to fix performance problem in controller. 2016-06-28 12:44:47 -07:00
02fa32422a Dockerfile ordering 2016-06-27 20:07:35 -07:00
decb4261d4 wire up control to launch at startup in preferences 2016-06-27 19:14:15 -07:00
b0971e3a01 setup launch at login on first start 2016-06-27 19:04:55 -07:00
12037961ff small perf improvement in sqlite db. 2016-06-27 18:48:02 -07:00
8c572dead1 Query optimization. 2016-06-27 18:28:18 -07:00
583cd25506 slightly resize icons 2016-06-27 18:05:17 -07:00
1beacc8c32 wire up network delete again 2016-06-27 17:54:54 -07:00
3ddfebe742 dead code removal 2016-06-27 17:15:39 -07:00
972bbb7e06 Allow further concurrency on network controller. 2016-06-27 17:14:47 -07:00
45f315e603 Defer NETWORK_CONFIG_REQUEST packets and allow multithreaded processing. 2016-06-27 17:09:04 -07:00
b9e86103cf Docker build farm seems to work! 2016-06-27 16:38:08 -07:00
0588589d57 . 2016-06-27 16:21:55 -07:00
4d30f60bbe . 2016-06-27 16:12:17 -07:00
d58dcf29cc For now go back to bundling http-parser etc. in our official RPM builds since this introduces an EPEL dependency for CentOS which would only make sense if we are actually in EPEL. Probably will eventually have two spec files: one for official and one for our own. 2016-06-27 15:46:54 -07:00
809457599a CentOS7 fixes. 2016-06-27 15:21:24 -07:00
2d19fb7f8c More RPM fixes. 2016-06-27 15:08:51 -07:00
2c9401ed74 CentOS6 fix. 2016-06-27 14:56:40 -07:00
af23596c34 Put everything in /usr/sbin on Linux. 2016-06-27 14:45:38 -07:00
233945e60f More Dockerfile fixes, and do not use "ln -r" since it is not supported on older Linux distributions. 2016-06-27 14:36:58 -07:00
147f735333 More build fixes. 2016-06-27 14:21:54 -07:00
8de5b2beda RPM build fixes -- use RPM cflags, spec fixes, etc. 2016-06-27 09:25:34 -07:00
b02c3dfe8d Debian dependency for iproute2 2016-06-27 08:48:09 -07:00
c5d3895313 ZeroTier One requires /sbin/ip (RPM-based distros) 2016-06-27 08:47:09 -07:00
9f880d07ab build number change 2016-06-26 18:21:26 -07:00
3fc11e2278 misc bug fixes related to default routes 2016-06-26 18:18:59 -07:00
1756e8b0f2 Wire up checkboxes for allowGlobal, allowDefault, allowManaged to set the proper state in zerotier daemon
checkboxes are disabled if the network is not currently connected.
2016-06-26 17:33:46 -07:00
d57e343245 add UI elements in network details for allowDefault, allowGlobal, allowManaged 2016-06-26 17:21:45 -07:00
7e17a2072c add allowManaged, allowGlobal, allowDefault to Network object 2016-06-26 16:41:52 -07:00
9c94d6527a add allowGlobal, allowDefault, allowManaged options to joining a network 2016-06-26 16:11:30 -07:00
d20bcdae12 CentOS 6 Docker build. 2016-06-25 16:27:28 -07:00
81cd68b60d . 2016-06-25 14:07:02 -07:00
0582b3daba . 2016-06-25 14:06:40 -07:00
af0a205594 Build and spec file updates for CentOS6 2016-06-25 14:04:08 -07:00
06e2e8119e Script to create Debian repos (requires aptly) 2016-06-24 16:23:10 -07:00
5da4fd2aef Added "..." to menu items to signify it pops up in a window 2016-06-24 15:24:29 -07:00
e621058cfd build number 5 2016-06-24 15:24:03 -07:00
8b78f19335 More build targets. 2016-06-24 14:57:20 -07:00
9784393b15 More Linux Docker build farm targets. 2016-06-24 14:45:09 -07:00
65da797112 Merge branch 'dev' of http://10.6.6.2/zerotier/ZeroTierOne into dev 2016-06-24 14:19:01 -07:00
75fe981b9d Bump version. 2016-06-24 14:18:28 -07:00
caaf33e4cf Bump version. 2016-06-24 10:20:35 -07:00
d642db6f66 Changes for Debian packaging to prep for 1.1.6 interim. 2016-06-24 10:19:41 -07:00
3740b83f63 Don't back up sqlite db if it hasn't changed to prevent constant thrashing on inactive controllers. 2016-06-24 06:53:23 -07:00
90cdef8400 Forgot NDP emulation flag. 2016-06-24 06:43:23 -07:00
ee649ae69a Add 6plane assignment support to network controller, and cleanup. 2016-06-24 06:40:50 -07:00
20d155e630 . 2016-06-24 05:21:25 -07:00
be5996daca Cleanup of 6plane stuff. 2016-06-24 04:54:05 -07:00
38dfebad8c IPv6 NDP emulation flag in NetworkConfig, and implement Docker-friendly
(and other host friendly) IPv6 /80 magic subnetting to allow massive
multicast-free NDP emulated IPv6 networks where each host can have a
/48 worth of IPv6 IPs for internal containers, VMs, etc.

Alan Kay, thou art avenged.

https://ivanovivan.wordpress.com/2010/09/13/alan-kay-quotes/
2016-06-23 22:41:14 -07:00
f2e2632ae7 Added About view
also not yet populated
2016-06-23 20:22:03 -07:00
35d1736c97 add preferences view
not populated yet
2016-06-23 20:04:57 -07:00
3c534abc99 "Show Networks" -> "Network Details" 2016-06-23 19:48:48 -07:00
c3deedd6fd Fix menu bar icon. Add app icon. 2016-06-23 19:44:00 -07:00
a5a05e454e cli work... 2016-06-23 17:00:33 -07:00
32d9850263 More new CLI work. 2016-06-23 12:37:15 -07:00
a5ea8cc5cb . 2016-06-22 17:56:36 -07:00
0ad6b4105a Outline of new CLI with ability to control controllers/central as well as service. 2016-06-22 17:54:07 -07:00
b256111a17 misc cleanup 2016-06-21 20:02:18 -07:00
b5a90a437b update build number 2016-06-21 19:45:08 -07:00
6d114b7480 dynamically generate the menu so that networks are listed
can join/leave networks directly from the menu
2016-06-21 19:44:59 -07:00
f765597526 Add network local.conf stuff to save network permission settings and wire it all through via the JSON API. Default route and route management stuff just about done. 2016-06-21 16:52:49 -07:00
8ca4f22f1d cleanup 2016-06-21 15:53:38 -07:00
674b84d908 Plumbing for network setting control, and GitHub issue #330 2016-06-21 14:58:30 -07:00
e2ca239be0 Comment cleanup. 2016-06-21 14:38:15 -07:00
4f237687ce Route management now works on Windows, including default route override! 1.1.6 very close! 2016-06-21 13:54:03 -07:00
5b2d2efb45 Windows builds again. And there was much rejoicing. 2016-06-21 12:55:43 -07:00
82473c85e0 Default route override and route management in general now works in Linux. 2016-06-21 12:32:58 -07:00
51ced0cf41 GitHub issue #338 2016-06-21 09:41:55 -07:00
6c4a444f29 GitHub issue #339 2016-06-21 09:40:53 -07:00
330c80f3f5 Add rule type to match a COM field of the peer by ID and value because this will be powerful. 2016-06-21 08:09:20 -07:00
eee59ec9ce Fix Buffer<> version of Dictionary.get(). 2016-06-21 08:00:40 -07:00
0959d33ba0 Add a few technically unnecessary but feel-good paranoia bounds checks in Dictionary.get(). 2016-06-21 07:59:42 -07:00
ca82715bfa Another fuzzing code fix. 2016-06-21 07:52:32 -07:00
0c05b2cb50 Comment cleanup and fuzzing improvements. 2016-06-21 07:49:46 -07:00
b2d048aa0e Make Dictionary templatable so it can be used where we want a higher capacity. 2016-06-21 07:32:58 -07:00
3ee15e65aa Tying up default route and route mgmt loose ends. It now periodically updates shadow routes so hopefully your link will stay up as you move around. 2016-06-17 13:14:48 -07:00
c8f85ffec9 Factored network updates into its own class. Delivered via notification 2016-06-16 20:53:55 -07:00
1bf1c38b30 Default route population works on Mac! 2016-06-16 18:23:33 -07:00
eb4a78bcc3 Report routes in locally joined network JSON. 2016-06-16 17:40:32 -07:00
37afa876a7 Linux bug fixes, small controller fix. 2016-06-17 00:21:58 +00:00
601c51b351 Bug fix. 2016-06-16 23:18:20 +00:00
20d4dada40 Refactor controller for new merged format. 2016-06-16 16:05:57 -07:00
901b75e756 New format now integrated, and it works. 2016-06-16 15:48:58 -07:00
bc3d7d11fe Remove netcon from dev branch. This is moving to its own new ZeroTierSDK repo for future release under the SDK name. 2016-06-16 14:50:08 -07:00
490d20e8fb Self test for dictionary, and fixes. 2016-06-16 14:45:36 -07:00
2113c21fdc devicemap now works again in OSXEthernetTap 2016-06-16 14:09:09 -07:00
e09c1a1c11 Big refactor mostly builds. We now have a uniform backward compatible netconf. 2016-06-16 12:28:43 -07:00
b104bb4762 New super-packed dictionary -- we are going back to a backward compatibile format with the old netconf but in an embedded-friendly way. This is simpler. 2016-06-15 18:47:35 -07:00
f41ea24e97 Build fixes. 2016-06-16 00:11:46 +00:00
3c655a4b84 Default route ready to test on Mac. 2016-06-15 15:46:57 -07:00
b90e66f7c7 ManagedRoute, which applies C++ RAII to injected routes. Move RoutingTable to attic. 2016-06-15 15:02:40 -07:00
bae0060552 add a timer to retrieve the network list every second. 2016-06-14 19:59:45 -07:00
c8750e5812 more error checking when parsing JSON for network list
remove "multicastSubscriptions" field as it isn't used anyway
2016-06-14 18:09:30 -07:00
4446dbde5e Big refactor in service code to prep for plumbing through route management. 2016-06-14 10:09:26 -07:00
89cb0e260a Set deployment target to 10.10 for the minimum OS X version for this app
I'm currently using features only available in 10.10 or above.  We'll have to discuss this and see what can be done for OS X 10.7 through 10.9.
2016-06-13 19:58:21 -07:00
2c1a8524f0 remove unused variables 2016-06-13 19:56:43 -07:00
b085329bca Base functionality complete. Can join/leave/list networks. Can disconnect from networks without removing them from the network list. 2016-06-13 19:46:54 -07:00
769351b30f Fix to routes config in controller API. 2016-06-13 15:58:00 -07:00
734cbb2f1e Controller modifications for default route are ready to test. Will require slight changes in ZeroTier Central when it goes live. 2016-06-10 15:58:35 -07:00
acbe8ad398 More controller work, and some RedHat fixes. 2016-06-10 08:26:27 -07:00
188f8021f8 Joining/Deleting networks now implemented.
Still need to implement known networks cache so we can join/leave networks without deleting them from the UI
2016-06-09 19:59:05 -07:00
9898066b47 Remove some deprecated stuff in controller -- not done yet. 2016-06-09 11:02:42 -07:00
82635ce606 Add flags and metric to ZT-managed routes. 2016-06-09 09:43:09 -07:00
8c7433a525 . 2016-06-08 17:45:25 -07:00
56ef9e0643 Add rpm target. 2016-06-08 16:29:30 -07:00
e6328dfe82 Add RPM spec conditionals to include json-parser or bundle it depending on whether we are fedora or rhel/centos/epel. 2016-06-08 16:19:38 -07:00
3a48e3781b bundle miniupnpc for now... might change later. 2016-06-08 15:37:37 -07:00
f9056da6be rpmbuild -ba zerotier-one.spec basically works 2016-06-08 15:33:59 -07:00
536feb632c Support yet another old version of http-parser for CentOS/EPEL. 2016-06-08 15:09:09 -07:00
cafa41ba4d RedHat stuff and cleanup. 2016-06-08 14:46:42 -07:00
196d96cfa7 Fix ronn convert problem in man page. 2016-06-08 14:08:56 -07:00
4e6f95e152 Build man pages with ruby-ronn on Debian. 2016-06-08 14:06:19 -07:00
de9fa6a334 All three init systems now covered in debian. 2016-06-08 13:30:29 -07:00
abd7071eaa systemd stuff for debian 2016-06-08 13:19:08 -07:00
7e68791bee Fix include for system json-parser. 2016-06-08 12:57:22 -07:00
6c6b18d003 Fix include for system lz4. 2016-06-08 12:50:56 -07:00
4da9d4e53a Fix build against Debian version of libhttp-parser -- its old but it will work. 2016-06-08 12:49:07 -07:00
0ca764968a Remove warnings, more Debian stuff, remove obsolete ui/ stuff. 2016-06-08 11:21:01 -07:00
62b64d39ab Minimal debian is working. 2016-06-08 10:30:54 -07:00
ae87fbf8e3 make install installs man pages 2016-06-08 10:19:46 -07:00
2e890580fc Stop shipping pre-build man pages since it violates Debian arcane rule #134931e+26 and add manpages build target. 2016-06-08 10:13:31 -07:00
afda5e684b Make install/uninstall for Linux 2016-06-07 17:11:09 -07:00
9161eebc68 Carry virtual network routes through to API. 2016-06-07 12:15:19 -07:00
683254a0db Don't bother signing if we are not using the legacy netconf. 2016-06-07 11:17:38 -07:00
2885aea65c Only send new format netconf for PV>=6 2016-06-07 11:13:18 -07:00
523ea68ae2 Increment protocol version to indicate support for binary network config and config request meta-data. 2016-06-07 11:08:36 -07:00
ca88e1f1cf fix size 2016-06-07 10:47:22 -07:00
be37d025b8 Make flags 64-bit in both network request and config. 2016-06-07 10:46:29 -07:00
4342b71d7a Upgrade miniupnpc to 2.0 2016-06-02 17:04:15 -07:00
f20602a7b1 docs 2016-06-02 15:57:18 -07:00
f311b4111b docs 2016-06-02 15:56:58 -07:00
61d6ada88d . 2016-06-02 15:26:00 -07:00
506c74270c Stash old Linux binary installer stuff in attic. This is going away. 2016-06-02 15:20:43 -07:00
4d13ddd48c GPG public key for signing GitHub releases, etc. 2016-06-02 15:04:56 -07:00
cc89290eb6 last man page! 2016-06-02 14:50:38 -07:00
5bce3e37ee clean doc node_modules on clean 2016-06-02 13:58:34 -07:00
6671d5553b More man pages. 2016-06-02 13:56:24 -07:00
41b3b54bf8 man stuff 2016-06-02 13:04:46 -07:00
096db53822 Switch manual pages to "ronn," a program that converts MarkDown to roff man pages, and pre-build them. Also have the zerotier-cli(1) man page ready to go! 2016-06-02 12:33:28 -07:00
f9148bf9cb Finally json-parser. Skip miniupnpc since some Linux distros (even newer ones) ship with an old unsafe crummy version. 2016-06-01 22:26:58 -07:00
a880f93166 also libnatpmp 2016-06-01 22:06:43 -07:00
fd81a7fe63 On Linux auto-detect presence of http-parser and lz4 and link against system libs instead of ext/ builtins (for RPM and DEB packaging effort) 2016-06-01 21:55:48 -07:00
65b7893a8a add full docs to ext/json-parser (no upgrade available) 2016-06-01 18:51:22 -07:00
597dee40fd upgrade ext/http-parser 2016-06-01 18:49:36 -07:00
975bcb8aff some OS X Authentication Services wizardry to get /Library/Application Support/ZeroTier/One/authtoken.secret and copy it to ~/Library/Application Support/ZeroTier/One/authtoken.secret 2016-05-31 17:23:11 -07:00
51e74f8d4f remove some extra logging 2016-05-31 15:01:42 -07:00
b4f3dfc347 look up authtoken in user's app support directory 2016-05-31 13:50:43 -07:00
2c995f1f91 IPv6 links are unfortunately not "reliable." Many IPv6 gateways, while not
implementing NAT, do implement stateful firewalling with absurdly short
timeouts (<60s). Keepalives are still required in IPv6.

Network engineers continue to mindlessly carry forward cruft and baggage
from IPv4 to IPv6.
2016-05-31 10:30:00 -07:00
41328eef94 . 2016-05-27 15:25:32 -07:00
59cf2ea341 add proper border around the network list 2016-05-27 15:21:23 -07:00
67d472424d make the view show up light instead of dark 2016-05-27 15:07:20 -07:00
1d27adb102 Finished wiring up the view 2016-05-27 13:48:22 -07:00
940c0f2b93 WIP. Mac UI 2016-05-27 13:28:32 -07:00
68d950c344 Hack in zerotier-idtool to allow generation of vanity addresses. 2016-05-26 09:26:03 -07:00
d5620288d5 Parse JSON network list into Network objects for the view 2016-05-17 19:41:54 -07:00
da30d2898e beginning of communicating with the zero tier service 2016-05-16 19:58:24 -07:00
40198d6c13 call super functions on a few overrides 2016-05-16 19:25:20 -07:00
4653ebc97f add table view to show networks view 2016-05-16 19:08:00 -07:00
0bcc7d46a3 Disable debug code. 2016-05-16 18:39:34 -07:00
93b673043c Fix new binary meta-data deserialization and add some debug code (will disable later). 2016-05-16 18:37:37 -07:00
acd6978a30 set the combo box to use a data source and remember the last 20 networks input 2016-05-16 18:26:33 -07:00
ccbd6f97cd remove some mistakenly committed files and add .gitignore for Xcode projects 2016-05-16 18:02:26 -07:00
b4a8057994 limit the join network combobox to hex characters.
Join only clickable when a valid network is entered
2016-05-16 17:51:14 -07:00
225c2b095b Initial start of the menu bar app.
Has menu items to join/leave networks which currently displays an empty popover from the icon (icon needs to be made still)
2016-05-14 15:42:45 -07:00
0582338015 Initial Commit 2016-05-14 13:54:49 -07:00
de1b745988 comment out a few TRACE messages that don't compile 2016-05-14 13:29:31 -07:00
efdbd6326f compiling with C++11 requires a space between string literals 2016-05-14 13:25:40 -07:00
25c3d3a452 cleanup 2016-05-11 13:24:55 -07:00
548730660b Ready to test whole new netconf refactor. 2016-05-11 10:19:14 -07:00
7ee3743c3d Refactor controller to send both old and new format netconf. 2016-05-11 08:49:15 -07:00
37b89b3944 Add TCP relative sequence number criterion for documentation/posterity. 2016-05-09 17:00:17 -07:00
8b9519f0af Simplify a bunch of NetworkConfig stuff by eliminating accessors, also makes network controller easier to refactor. 2016-05-06 16:13:11 -07:00
529515d1d1 Changes to how new-style binary network configs are detected, and a new-style binary serialized meta-data representation. 2016-05-06 13:29:10 -07:00
69d0562e2c docs 2016-05-06 11:41:11 -07:00
7913fa7bbd Dead code removal. 2016-05-06 11:13:34 -07:00
b543868351 Missing deserialize stuff. 2016-05-06 11:00:19 -07:00
0f17077b3d Merge gateways and routes in netconf since they are the same thing. 2016-05-06 10:57:53 -07:00
9da8bf37d7 docs 2016-04-28 21:31:10 +02:00
e5cc487b95 Beginning of security doc and kill some obsolete defines in main include file. 2016-04-28 14:58:16 +02:00
726136beda Ifdef fix. 2016-04-27 09:30:34 +02:00
59eb09d063 Deserialize new style netconf. 2016-04-26 17:20:31 -07:00
b9dba97fdb Bunch more refactoring for an even more compact NetworkConfig representation, especially rules. 2016-04-26 17:11:25 -07:00
25a5275921 . 2016-04-26 08:53:49 -07:00
e731fc1a3a Replace two bools in NetworkConfig with a flags field. 2016-04-26 08:40:26 -07:00
90e1262a8b More refactoring to remove old Dictionary dependencies. 2016-04-26 08:20:03 -07:00
246f86dad3 Define an "anchor" as a statically defined device that serves as a network lookup point. 2016-04-26 07:56:41 -07:00
d736074301 Refactor rules table in-memory structure in new NetworkConfig to permit far more rules with better space efficiency. 2016-04-22 15:40:53 -07:00
368efaa2ba Kill some old debug code. 2016-04-19 12:55:48 -07:00
2f18a92e20 Cleanup in numerous places, reduce network chattiness around MULTICAST_LIKE, and fix a "how was that working" latent bug causing some control traffic to take the scenic route. 2016-04-19 12:09:35 -07:00
affbca74b4 Clean up Linux makefile and remove doc target from default since it requires rst2man. Add doc target to official instead. 2016-04-19 09:35:32 -07:00
4c455876f9 Revise peer path weighting to always prioritize cluster-optimal paths. 2016-04-19 09:22:51 -07:00
cecfa99b7b (1) cluster members send a flag indicating that a PUSH_DIRECT_PATHS is a cluster redirect, (2) 1.1.5 uses this to avoid a bug (this bug does not exist in 1.1.4) 2016-04-18 16:44:23 -07:00
b3cac538cc Store lat/lon too for testing and future display use. 2016-04-18 15:48:33 -07:00
587b1e05d1 Replace cluster-geo subprocess with in-memory loaded CSV of GeoIP data. This is faster, cheaper, more reliable. We use https://db-ip.com/ but others would work too. 2016-04-18 11:33:54 -07:00
02c3727ccd . 2016-04-18 10:21:38 -07:00
af471af8ef Shrink NetworkConfig slightly. 2016-04-12 13:32:41 -07:00
e28838805f Brace fix... 2016-04-12 13:17:16 -07:00
8a9762331f Fix one more old NetworkConfig bit of code. 2016-04-12 12:54:14 -07:00
31db6f8f36 NetworkConfig refactor almost done. 2016-04-12 12:49:46 -07:00
ad1e83d8b9 Refactor IncomingPacket for new NetworkConfig 2016-04-12 12:32:33 -07:00
bbd9915056 Refactor Node for new NetworkConfig 2016-04-12 12:26:10 -07:00
51fecc0be9 Refactor Network for new NetworkConfig. 2016-04-12 12:16:29 -07:00
6f854c8391 NetworkConfig refactor part 1 2016-04-12 12:11:34 -07:00
9b8444fff1 Merge of bignose/manual-pages (Linux man pages) 2016-04-07 12:28:43 -07:00
43e317f0b7 Authorship stuff. 2016-04-07 12:24:15 -07:00
0e40181d8f Merge branch 'license-clarification' into dev 2016-04-07 12:18:46 -07:00
63b62ebf4c Boost local interface check interval a bit to speed direct link provisioning on startup. 2016-04-07 12:13:18 -07:00
569de22481 Make port mapper names even more unique, and trial bind before binding TCP now which should work on Linux and others. 2016-04-07 09:51:14 -07:00
9085a04b16 Merge branch 'dev' of http://git.int.zerotier.com:/zerotier/ZeroTierOne into dev 2016-04-07 16:41:28 +00:00
c7df61a3c3 dev branch now works again on Linux 2016-04-07 16:41:07 +00:00
c278f05181 RoutingTable build fixes. 2016-04-06 17:29:38 -07:00
61a9c27af0 Consolidate routing table code. 2016-04-06 17:14:05 -07:00
e9b2613d5f Put routing table code back in osdep/ 2016-04-06 16:57:37 -07:00
24469a7f43 . 2016-04-06 16:47:11 -07:00
56096be8b6 Tweak new RX queue algorithm to "expire" old entries to prevent always needing to traverse the whole queue array. 2016-04-06 16:28:40 -07:00
8ef78e7e7d Preserve add local interface address add order and send in that order since this is a priority. 2016-04-06 11:50:00 -07:00
504738b183 Binder for Windows, and use Binder to get local interface addresses to advertise. 2016-04-05 15:53:19 -07:00
32cd2a02c9 OneService now binds all ports to specific local interfaces instead of wildcard and rebinds on changes. (default route) 2016-04-05 15:44:08 -07:00
4a109658ab More refactoring and prep for explicit interface bindings (for default route support). 2016-04-05 11:59:46 -07:00
52d9612301 Reduce symmetric prediction fuzz just a bit. 2016-04-05 10:49:14 -07:00
d8b89b0c86 Fix Cluster to send from a designated endpoint address instead of wildcard. 2016-04-05 10:47:13 -07:00
e0ad854d19 Beginning of local binding manager for default gateway support. 2016-04-04 18:46:41 -07:00
0e26917c72 Tweak metric and clean out attic a bit. 2016-04-01 11:07:44 -07:00
3df60995e1 nit pick... might this matter? 2016-03-30 16:49:21 -07:00
1a5e7cb0cb More tweaks to OS determination stuff. 2016-03-28 12:26:49 -07:00
8035afae87 Try to define ZT_NO_TYPE_PUNNING on iOS in case it wasn't. 2016-03-28 12:22:05 -07:00
284e5d83b5 Fix some broken TRACEs and a tiny reorder in a few ifs. 2016-03-28 12:15:24 -07:00
2b3e1d5c10 Ignore IP assignment pool ranges that begin with 0.0.0.0 or that contain no IPs. 2016-03-24 13:34:01 -07:00
2c328d61ad Do not auto-assign IP addresses on bridges. IPs can still be assigned manually. 2016-03-24 13:32:01 -07:00
76f9b4c582 A few other little formatting things. 2016-03-18 15:06:45 -07:00
c589bc4c57 Indentation 2016-03-18 14:32:48 -07:00
d6a1868d0a Refactor incoming packet (rxQueue/fragmentQueue) to eliminate variable length queues and merge queues. This is both faster and saves memory. 2016-03-18 14:16:07 -07:00
9f31cbd8b8 Make /network/???/active return more info. 2016-03-17 13:05:51 -07:00
c0262d8f76 Add “doc” to the dependencies for the “all” build target. 2016-03-04 17:01:31 +11:00
92702615a7 Add an overall “doc” build target. 2016-03-04 17:01:14 +11:00
c9d3f3ab96 Correct license grant to match “GPL v3 or later” grant in source. 2016-03-04 16:45:15 +11:00
72797c25d5 Update copyright notice. 2016-03-04 16:44:23 +11:00
ea6ce47345 Refactor the program name to a pre-processor directive. 2016-03-04 16:42:30 +11:00
10855b451d Refactor the copyright notice text to a pre-processor directive. 2016-03-04 16:40:09 +11:00
3265b3594b Refactor the license grant text to a pre-processor directive. 2016-03-04 16:37:36 +11:00
cafc46a8e9 Add Makefile module for building documentation. 2016-03-04 16:06:17 +11:00
5993b178c5 Ignore generated man page files. 2016-03-04 16:05:55 +11:00
24e286b5ec Add a stub for an encoding declaration on a man page. 2016-03-04 16:04:57 +11:00
c63de27633 Add references to other tools for ‘zerotier-one’. 2016-03-04 15:41:06 +11:00
a84a256df4 Add incomplete man pages for ‘zerotier-idtool’ and ‘zerotier-cli’. 2016-03-04 15:40:08 +11:00
88dfa860f4 Document how the home directory is used, and its default value. 2016-03-04 15:08:17 +11:00
83bc5d95aa Document remaining options explicitly. 2016-03-04 14:57:10 +11:00
09c61d5cb1 More explicit specification of how to use ‘-i’ and ‘-q’. 2016-03-04 14:53:50 +11:00
71c84aee60 Add “see also” section referring to ZeroTier documentation online. 2016-03-04 11:36:19 +11:00
cee09b0d2e Refine description of ZeroTier One. 2016-03-04 11:36:04 +11:00
fdb8ea93ef Add a reStructuredText document for a ‘zerotier-one(8)’ man page. 2016-03-04 11:35:16 +11:00
60ab565185 Fix cluster-geo code to cache IPv6 by first 64 bits to prevent cache fillup due to IPv6 privacy extensions. 2016-03-03 15:33:38 -08:00
1fe251d0a0 stupid bug is stupid 2016-03-03 14:50:47 -08:00
ff931e53b5 more makefile stuff 2016-03-03 14:31:43 -08:00
ef376a7919 Linux make clean fix. 2016-03-03 14:24:52 -08:00
09fc9e4d0c indent fix 2016-03-03 14:21:13 -08:00
fe3a84a422 Fix problems with previous commit. 2016-03-03 14:15:09 -08:00
ba56a5b9d1 Another NAT-t improvement:
Many NATs revert to symmetric behavior from friendlier modes if they cannot
preserve ports. This can occur if there is, for example, more than one ZT
device behind the NAT using port 9993.

Others (Airport Extreme?) seem to have bugs in which they completely freak
out if more than one device tries to do a lot of mappings using the same
internal local port.

Mostly to fix the latter case and somewhat to fix the former, we introduce
a secondary port. ZeroTier now binds 9993 (or whatever port you specify)
plus another port computed deterministically from your ZeroTier address.
This port is used for new links 1/4 of the time.

This mostly addresses the second problem above and partly helps to address
the first.

If uPnP/NAT-PMP is enabled we also still open a tertiary port because some
routers freak out if NAT-t is attempted using the same port as uPnP.

All of this is IPv4 only of course. IPv6 is sane.
2016-03-03 13:52:27 -08:00
a27d8b2910 Windows cleanup. 2016-03-02 19:20:04 -08:00
b6f6ed35fc More Windows tweaks and a compile fix. 2016-03-02 19:06:29 -08:00
d3cb063d13 Tweaks to WindowsEthernetTap to attempt to address GitHub issue #308 and/or GitHub issue #277 -- we can't reproduce yet but I found one area where a spin was possible under certain failure conditions. Maybe. 2016-03-02 18:37:24 -08:00
b9125e4256 Document myself as a contributor. 2016-03-02 10:38:30 +11:00
0aae86be2e Merge branch 'dev' of https://github.com/krisek/ZeroTierOne into dev 2016-03-01 12:29:29 -08:00
d9fa07399e Fix GitHub issue #311 2016-03-01 09:49:33 -08:00
d570adf021 State grant of license in each third-party component. 2016-02-29 18:11:54 +11:00
dcb91c043f State which exact files constitute third-party works. 2016-02-29 18:04:20 +11:00
f613930dee Explicitly mark home page URLs of third-party code. 2016-02-29 18:03:16 +11:00
667048310d Remove text that paraphrases GPLv3 conditions. 2016-02-29 17:44:47 +11:00
642aa3313d Explicitly grant GPLv3-or-later terms to the overall code base. 2016-02-29 17:44:47 +11:00
f6e98df8da Refer directly to the accompanying GPL-3 license document. 2016-02-29 17:44:47 +11:00
d37e44225f Add explicit copyright statement in same file as license grant. 2016-02-29 17:44:47 +11:00
5c172d1a15 Rename file that is not a license text. 2016-02-29 17:44:10 +11:00
0bf2060a7d Add verbatim text of GNU General Public License version 2. 2016-02-29 15:16:19 +11:00
22883b3eeb Add verbatim text of GNU General Public License version 3. 2016-02-29 15:13:37 +11:00
6d1dc47368 Typo fix. 2016-02-28 17:06:46 +01:00
f8d05eb625 Spec description rephrased. 2016-02-28 17:05:43 +01:00
45c233c0e7 Formatting change 2016-02-28 00:04:18 +01:00
b836228465 Formatting change 2016-02-28 00:02:48 +01:00
8118630861 Formatting change 2016-02-28 00:00:55 +01:00
bf3e31ece7 Initial commit of the standard zerotier RPM specification 2016-02-27 23:55:14 +01:00
f217ce7ff7 Upgrade http-parser. 2016-02-25 18:13:42 -08:00
039790cf26 Upgrade LZ4 to hopefully fix wacky sporadic crash when built with g++ 5.3.1 on Debian/testing. 2016-02-25 15:39:15 -08:00
e5f82f5457 cleanup 2016-02-25 10:08:30 -08:00
a5e4e3fcac Remove ui/ on Linux uninstall. 2016-02-24 17:24:36 -08:00
3fe60615df Make installers silent when run inside packages. 2016-02-24 15:23:49 -08:00
7b5c1696eb Fix a CIRCUIT_TEST bug in forwarding of tests along hop paths on private networks. Unfortunately this means full circuit testing for private nets will need an upgrade. :( 2016-02-23 14:56:51 -08:00
c7c61b4ac0 Fix checking of path address validity. 2016-02-22 16:01:35 -08:00
92f24d1988 Make maximum size of a circuit test structure sane. 2016-02-22 15:54:18 -08:00
9b59bcd995 Clean controller circuit test memory. 2016-02-22 15:48:27 -08:00
43fff1a87e Deprecate reporting of local clock in circuit tests since a small number of users might have security problems with this. 2016-02-22 12:59:26 -08:00
2aa7138373 Reduce direct ping delay back to 1m and make SelfAwareness aware of local received-on address to eliminate false symmetric classification. 2016-02-22 09:47:50 -08:00
69a438d64d Small tweak to active threshold. 2016-02-19 09:10:31 -08:00
772551c45d Try +1 and +2 existing surfaces for symmetric NATs. 2016-02-11 10:39:39 -08:00
0c951b6e56 More tweaks to new symmetric NAT buster, and stop using old iterative method since this supersedes it. 2016-02-10 18:41:39 -08:00
eadafd8de7 Little fix to NAT-t alg 2016-02-10 17:51:42 -08:00
f9230eb970 Widen max delta for TS/revision just a bit more for now. 2016-02-10 16:18:45 -08:00
82348e1537 Temporarily blacklist he.net IPv6 tunnel addresses for paths: these usually have a very low MTU which causes packet loss and other issues. 2016-02-10 11:06:26 -08:00
10bb9919f1 Tweak certificate of membership revision/time tolerance to eliminate boundary packet loss issues occasionally seen in the wild. 2016-02-10 09:32:42 -08:00
4769dacf61 Tweak needsOurMembershipCertificate timing to resolve a possible source of occasional dropped packets. 2016-02-09 16:54:47 -08:00
63ec7e58d4 Make activity no longer a function of ping frequency, since this causes compatibility bugs when the latter was modified due to timer interactions with other versions. 2016-02-08 10:03:01 -08:00
a963810e02 Tweak a few cluster params for higher perf / lower initial setup latency. 2016-02-08 09:57:46 -08:00
69b1da2e1d return 200 instead of 404 when test is fetched 2016-02-04 16:27:25 -08:00
dc3d899e70 Return test ID when we post a test. 2016-02-04 16:09:26 -08:00
78c1d9006a flood protection fix 2016-02-04 14:39:43 -08:00
5dad73647d Lengthen backup period again 2016-02-04 14:22:54 -08:00
13b39a0c3e SQLite perf tuning 2016-02-04 14:03:37 -08:00
90801a94d3 Track client version and tell whether active nodes support circuit test. 2016-02-04 13:38:42 -08:00
fab6f4450d /active subpath off networks 2016-02-04 12:17:55 -08:00
2e04dc03f2 Logging to NodeHistory, SQL queries. 2016-02-03 18:10:56 -08:00
f8eb6b0067 Add NodeHistory table on sqlite controller. 2016-02-03 13:56:35 -08:00
7a63fdc447 Fix for GitHub issue #298 and hopefully #297 2016-02-01 14:41:54 -08:00
4655a59912 typo 2016-01-28 17:59:31 -08:00
c0668dcdf2 Merge branch 'edge' into dev 2016-01-26 14:20:25 -08:00
9cb4bbe2b8 Save test results for circuit tests in memory and then cancel the test and send the results when the test is queried later. This way you can POST a test and then come GET the result at the appointed time. 2016-01-26 12:42:44 -08:00
95d28494f6 Mac OSX Port - Lightly tested 2016-01-25 12:55:29 -08:00
67f678d60a Merge branch 'master' into dev 2016-01-22 18:07:20 -08:00
3993dfa2a5 Fix JNI for API changes in 1.1.4 2016-01-22 18:06:58 -08:00
935f00ad4c Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2016-01-21 16:03:14 -08:00
bafdb54752 New dev version: 1.1.5 2016-01-21 16:02:16 -08:00
7526ed705c Check for /dev/tun as well as /dev/net/tun since some Linux devices put it there. 2016-01-21 16:01:24 -08:00
bccd60125b Added python, python3, darkhttpd unit tests 2016-01-21 15:52:54 -08:00
7127d2b811 Updated unit tests + README 2016-01-21 15:10:26 -08:00
9cc2733ed8 VERSION 1.1.4: Improved path detection, improved anti-recursion code, and Network Containers BETA
ZeroTier One version 1.1.4 has several improvements to path stability and
path learning logic. It also contains the BETA version of Network Containers!

See netcon/README.md and https://www.zerotier.com/product-netcon.shtml for more
information.

Improvements in 1.1.4:

 - Paths are now confirmed more aggressively on inactivity. This version can
   usually detect a dead direct path in under 10 seconds vs 1-2 minutes in
   previous versions.
 - Logic to prevent recursion has been overhauled. The old versions had code
   that explicitly checked packet contents (AntiRecursion.hpp). This is now
   gone in favor of a function that checks IP addresses of ZeroTier devices
   when paths are learned or probed. This is both more efficient and less
   prone to edge case failures. Testing in several complex environments has
   shown that this eliminates a few edge cases where inappropriate paths would
   be used.
2016-01-20 18:10:40 -08:00
3b10fd7557 Windows build fixes. 2016-01-20 18:06:20 -08:00
f782797dc7 readme 2016-01-20 17:44:17 -08:00
227b8bfbf6 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2016-01-20 16:59:59 -08:00
385770dcc8 1.1.4 bump 2016-01-20 16:59:54 -08:00
4f6ca14d4f typo 2016-01-20 16:52:46 -08:00
c3fc5340b6 Added check for identiy
Needed if you just copy & paste the whole block.
2016-01-20 16:43:37 -08:00
4f30b06930 Merge branch 'dev' into edge 2016-01-20 16:28:14 -08:00
398e0b7c63 Removed debug line 2016-01-20 15:04:02 -08:00
b7b014298b Bad connection reference fix + RX lock fix 2016-01-20 14:43:49 -08:00
bcaf42e075 Transfer speed increate + stability fixes 2016-01-20 13:38:14 -08:00
357cb92f2e Stability fix + introduction of connection probation 2016-01-18 23:41:28 -08:00
31ed86740c Added some safety + unregister callbacks on close 2016-01-18 16:04:29 -08:00
f2cc144811 Fixed nc_sent possible bad ptr on close issue 2016-01-18 12:26:40 -08:00
1783867f96 Print path for user. Removed unused stub Phy methods 2016-01-17 15:13:32 -08:00
a73638b214 Fixed memory leak 2016-01-17 14:32:34 -08:00
bd1884e48f yay more icons 2016-01-15 18:39:16 -08:00
5cd20c0009 Adding app icons for iOS 2016-01-15 18:22:53 -08:00
58ebfdffcb Debugs off by default 2016-01-15 13:03:37 -08:00
1e2c434ae8 nc_recved() connection closure change 2016-01-15 13:02:48 -08:00
7107297c25 Merge branch 'edge' of http://10.6.6.2/zerotier/zerotierone into edge 2016-01-15 11:19:25 -08:00
35fb602dff Fixed pcb->state == CLOSE_WAIT bug 2016-01-15 11:18:26 -08:00
8af3d35234 Merge branch 'dev' into edge 2016-01-15 11:18:23 -08:00
323d40a560 Small formatting changes 2016-01-15 10:27:27 -08:00
321bca4bf7 Adjusted formatting/conventions to conform to rest of ZT codebase 2016-01-15 10:09:31 -08:00
7cb08630d0 Fixed RX race condition 2016-01-14 18:59:08 -08:00
45f0737a00 Naming convention update 2016-01-14 14:15:50 -08:00
6cf478c1b2 RX buffer update 2016-01-14 14:03:03 -08:00
f52a82d9f2 Updated RX buffer code 2016-01-14 13:23:01 -08:00
6dac0c8c4f C doesn't support default arguments 2016-01-13 17:47:34 -08:00
5e30eabd30 Updated getsockopt/setsockopt, removed unused code 2016-01-13 15:52:15 -08:00
7bba867ce8 Fixed double-close bug 2016-01-13 13:55:11 -08:00
e8e6a4702b Merge branch 'dev' into edge 2016-01-13 13:15:47 -08:00
c3e2cb9b8e Modified PCB/state management logic 2016-01-13 12:19:48 -08:00
2e5caa335a Old SF root is dead. Now we are just on Alice and Bob. (world update for 1.1.4) 2016-01-13 10:18:41 -08:00
bdabe40c65 Updated error reporting for sock_fd_read() 2016-01-12 14:25:30 -08:00
7991a7c50a Merge branch 'dev' into edge 2016-01-12 14:05:40 -08:00
4e4fd51117 boring doc stuff 2016-01-12 14:04:55 -08:00
e91322bd10 README update and example server port change 2016-01-12 14:04:55 -08:00
23cdb3aed5 Removed ztnc network config file 2016-01-12 13:58:15 -08:00
bd3d9ee356 Removed terminology changes 2016-01-12 13:55:46 -08:00
76f1ab33f0 Make clean rm .depend 2016-01-12 13:44:59 -08:00
61fd8463f8 Merge branch 'dev' into edge 2016-01-12 13:19:53 -08:00
3883ac08c7 Docs and cleanup. 2016-01-12 13:17:30 -08:00
dd233fdb8d Updated terminology. No functional change 2016-01-12 13:00:31 -08:00
18aea2d3d3 Removed unused code 2016-01-12 12:56:51 -08:00
74e22368b5 Fixed sketchy memcpy logic, also added checks for service RPC ACK 2016-01-12 12:42:46 -08:00
d03a63e055 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2016-01-12 12:25:19 -08:00
93ab8d46b9 Merge branch 'dev' into edge 2016-01-12 12:25:15 -08:00
740eb6ebc4 Simplify Peer locking to eliminate deadlock with new path recursion check code (and also probably improve performance). 2016-01-12 12:12:25 -08:00
d6f0f1a82a Use network user ptr in lookup for Ethernet frame handling to eliminate map lookup. 2016-01-12 11:34:22 -08:00
83ef98a9dc Add a network-associated user ptr in API. 2016-01-12 11:04:35 -08:00
3edfbfec93 Merge branch 'master' into dev 2016-01-12 09:50:19 -08:00
68c004ef68 Merge pull request #291 from JackyRen/patch-1
Update controller README.md
2016-01-12 09:49:54 -08:00
e2ae9165c6 RPC update 2016-01-12 09:46:49 -08:00
704205c5f7 Dead code removal. 2016-01-12 09:33:14 -08:00
21656ba015 Update controller README.md
Sync make parameter with code.
2016-01-12 22:51:08 +08:00
bbcc3304a0 Check shouldUsePathForZeroTierTraffic in legacy beacon responder. 2016-01-11 15:57:58 -08:00
c6571073fe Get rid of constructor/destructor in libzerotierintercept, and simplify a few things. 2016-01-11 15:27:22 -08:00
ba9fcb31d0 Merge branch 'dev' into edge 2016-01-11 14:30:24 -08:00
78c0f0a443 RPC detection fix 2016-01-11 13:23:43 -08:00
7656e6b9f8 Transfer tune-up 2016-01-11 11:37:04 -08:00
39d79f34ab Added RPC ACK 2016-01-11 10:35:02 -08:00
b3e3d4cacc Instead of using binary packet comparison, add a callback to the API to explicitly check whether paths should be used. Check in with this callback (if present) when learning new paths or sending initial packets. 2016-01-11 10:17:44 -08:00
3e65ecb93d Stateless RPC rework 2016-01-11 10:12:59 -08:00
ba2a89c760 docs 2016-01-11 09:13:41 -08:00
eea634a432 Refactor to eliminate copypasta. 2016-01-11 09:11:35 -08:00
ab19e19f00 Fix a bug that we visually found in Windows code -- it was not advertising uPnP addresses?!? 2016-01-11 09:09:24 -08:00
1023ef23b7 Remove somewhat ugly and costly anti-recursion hack -- we will switch to more explicit methods. 2016-01-11 09:06:10 -08:00
a56fbc1929 Close another potential anti-recursion loophole. 2016-01-06 15:35:27 -08:00
47ce52228b Roots should probably not do this since it would likely be a waste of packets. 2016-01-06 12:54:51 -08:00
ff9317365a Merge branch 'dev' into edge 2016-01-06 11:38:11 -08:00
0a3ef38cad Put old test code in attic. 2016-01-06 11:06:47 -08:00
9aee72099e AntiRecursion cleanup and some other minor things. 2016-01-06 10:59:39 -08:00
05b2c0743f Tighten up dead path detection. Should now auto-detect dead paths in less than 10 seconds at a very small cost in ECHO requests (or HELLOs for older peers). GitHib issue #272 2016-01-06 10:00:03 -08:00
4d94ae77b4 simplify if 2016-01-05 16:48:35 -08:00
d8143a5e18 Implement first pass on rapid dead path detection, and increment version to 1.1.3 (dev) 2016-01-05 16:41:54 -08:00
cba739fd6b more dead code 2016-01-05 14:46:26 -08:00
fb5237d5b6 Outline dead path detection mechanism. 2016-01-05 14:42:56 -08:00
258f95b2cd dead code removal 2016-01-05 14:19:16 -08:00
b8059d5c87 typo 2015-12-23 22:54:36 +01:00
66894eb473 Merge branch 'dev' into edge 2015-12-21 16:56:13 -08:00
61becbb7e5 . 2015-12-21 16:56:11 -08:00
42e453872c VERSION 1.1.2: bug fixes and NAT-PMP support
ZeroTier One version 1.1.2 is mostly a bug fix release, but also includes support
for NAT-PMP as a method of mapping external ports from behind supported routers.

Bugs fixed include:

 - Refactored path selection code to eliminate a change that might have introduced
   a reliability regression from earlier versions.
 - Reworked UPnP code for improved reliability and also added NAT-PMP support.
 - Fixed a crash on network preferred relays. (Not exploitable or security critical
   since only network controllers can send that config option and there was no
   buffer overflow or other exploitable issue.)
 - Fix GUI problem on OSX where window could be larger than screen on some Macbooks.
 - Fix a potential rate limit problem on PUSH_DIRECT_PATHS that could negatively
   impact same-network connectivity.
 - Update zerotier-cli to show preferred vs. active paths and hide inactive ones.
 - Fix an issue on shutdown with thread delete order and thread synchronization.
2015-12-21 16:48:33 -08:00
2f42a7c010 Windows 1.1.2 build. 2015-12-21 16:36:56 -08:00
436c1fac1d Selectively move over changes from "edge" to "dev" excluding netcon. 2015-12-21 16:15:39 -08:00
16bc9533ed Fix a problem that made valgrind complain on shutdown (not otherwise an issue). 2015-12-21 15:23:14 -08:00
63a51e2890 Fix a small potential uninitialized variable issue. 2015-12-21 14:55:11 -08:00
23eaafc4eb Remove stray file that is instead found in netcon. 2015-12-21 14:01:48 -08:00
536b7000bc Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2015-12-21 13:15:09 -08:00
24cc0904fa 1.1.2 Windows build fixes, tweaks, etc. 2015-12-21 13:14:48 -08:00
5a65463b92 typo 2015-12-21 22:11:39 +01:00
c8056452b8 fix / workaround for ubuntu
Otherwise, if started with -d as daemon, the netcon service dies after
intercept listen registers.
2015-12-21 21:20:22 +01:00
64e273e9c0 updated netcon readme 2015-12-21 19:49:22 +01:00
6f62d6bb34 Removed straggler debug prints 2015-12-21 07:36:44 -08:00
d430457f1e Updated readme, removed test network keys 2015-12-21 07:26:45 -08:00
4267cc138e Readme changes, turned off debug 2015-12-21 07:17:37 -08:00
de2ba8d0f7 Fixed typo 2015-12-21 05:36:27 -08:00
c488fa8461 Tightening of RPC code 2015-12-21 05:03:26 -08:00
608e059b18 single updated test file 2015-12-18 15:19:34 -08:00
81203b20b8 Merge branch 'edge' of http://10.6.6.2/zerotier/zerotierone into edge 2015-12-18 15:09:18 -08:00
91bc32fe51 Re-added keys for testing 2015-12-18 15:09:08 -08:00
d3dacf5c2a Tiny bit of dead code cleanup. 2015-12-18 14:51:24 -08:00
13036a1085 . 2015-12-18 14:30:47 -08:00
942ab6fd95 . 2015-12-18 14:29:23 -08:00
fd9b2e931f Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2015-12-18 14:26:37 -08:00
6de67e828d Fix accept4() semantics. 2015-12-18 14:26:31 -08:00
2d9f1f7857 Added install script for debugging with strace 2015-12-18 13:13:47 -08:00
fde8af9483 getsockopt() tweak 2015-12-18 11:37:11 -08:00
c22c0a20f6 Merge branch 'edge' of http://10.6.6.2/zerotier/zerotierone into edge 2015-12-18 10:31:24 -08:00
9063209124 getsockname() fix 2015-12-18 10:31:11 -08:00
61dc13a6e1 Cache query in progress to reduce redundant GeoIP2 queries. 2015-12-18 09:38:34 -08:00
e3eea6fcbd RPC Reliability improvements and partial getsockname() fix 2015-12-16 18:05:47 -08:00
7d001458cb Update World to drop an old legacy root. 2015-12-17 11:52:05 -08:00
823c9979c0 Erase more debug junk. 2015-12-17 11:45:55 -08:00
9ebcbc94e4 Remove some stray debug stuff. 2015-12-17 11:44:48 -08:00
aa39b0dc24 Show paths as active or preferred in listpeers. 2015-12-17 11:03:39 -08:00
2160164e8c (1) Get rid of path sorting and just scan them, since sorting may have been a premature optimization that introduced a regression and path instability in a few edge cases, and (2) do not attempt to contact remote paths received via PUSH_DIRECT_PATH if we already have that path and it is already active (dumb, should have done this originally) 2015-12-17 10:53:07 -08:00
3137f43da9 Fix for getsockname() crash and other address size issues. 2015-12-16 10:30:02 -08:00
efc2a74df1 Some final README revs. 2015-12-16 10:07:04 -08:00
9638889614 Removed docker-test keys/config for netcon network 2015-12-16 08:33:39 -08:00
0df639f8f5 readme update 2015-12-15 16:20:31 -08:00
011ce35ede Merge branch 'edge' of http://10.6.6.2/zerotier/zerotierone into edge 2015-12-15 15:57:02 -08:00
a9802eff02 readme update 2015-12-15 15:56:47 -08:00
f9837163d3 docs 2015-12-15 15:43:07 -08:00
6bc93d2050 Docs, and change ZT_NC_NWID to ZT_NC_NETWORK and use full path in local ZT home dir to enable multiple instances. 2015-12-15 15:35:21 -08:00
37a7e9e275 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2015-12-15 15:00:05 -08:00
531e5f9923 . 2015-12-15 15:00:03 -08:00
617845a7da readme and makefile updates 2015-12-15 14:59:17 -08:00
9dc59eff76 Cleaned up, tests updated, readme updated 2015-12-15 14:50:54 -08:00
a6c5596782 Patch controller to not send relays to 1.1.0 to avoid triggering 1.1.0 network preferred relays bug. 2015-12-15 10:53:15 -08:00
022d3857cc Fix should use ECHO check. 2015-12-15 10:37:32 -08:00
82aa3f59d6 Fix bug in ECHO handling (OK was invalid!), and use ECHO on newer peers for path confirmation. Also get rid of path confirmation circuit breaker since this causes issues with some peers and should be done more intelligently anyway. 2015-12-15 10:30:40 -08:00
04d6b03733 Make auto backups slightly less frequent. 2015-12-15 09:22:10 -08:00
3b22ecc80c Make hex device address in UPnP name the right length. 2015-12-14 17:35:45 -08:00
53fe576028 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2015-12-14 17:04:36 -08:00
f6dc99f345 Old NYC is dead. 2015-12-14 17:04:27 -08:00
c0df1169ee Remove unimplemented SET_EPHEMERAL_KEY for now. 2015-12-14 14:53:43 -08:00
b92884a0ad Merge branch 'edge' of http://10.6.6.2/zerotier/zerotierone into edge 2015-12-14 14:45:40 -08:00
a421e31dd5 send_cmd() retrun value bugfix + minor debug changes 2015-12-14 14:45:25 -08:00
7b1c0c4013 Cache null results from Maxmind. 2015-12-14 14:40:00 -08:00
f558b088e6 Library functions are now static, RPC return value tuning, and cleanup 2015-12-14 09:06:58 -08:00
99afc74021 FDs transferred over listen socket + other fixes 2015-12-12 01:28:59 -08:00
761bb4fdd0 Stability fix 2015-12-11 12:19:54 -08:00
663a336b83 RPC cleanup + Temporary timing fix 2015-12-10 09:24:56 -08:00
e506fda3e4 Only set SO_NO_CHECK on IPv4 UDP sockets for now due to broken V6 stacks that drop zero checksum UDP packets. 2015-12-09 15:02:42 -08:00
42da36ba81 Fixed addrlen assignment in getsockname() 2015-12-09 12:22:08 -08:00
a730c86907 getsockname() implemented 2015-12-09 12:20:38 -08:00
b8cba90d85 . 2015-12-09 09:01:09 -08:00
9090edebb0 . 2015-12-08 18:17:03 -08:00
49d76c6311 Stub out getsockname() 2015-12-08 18:07:46 -08:00
5717dfe3b9 . 2015-12-08 17:45:51 -08:00
c576cd68cb . 2015-12-08 17:44:13 -08:00
f2078bf986 (WIP) more netcon work 2015-12-08 17:35:37 -08:00
c2c37f3a63 Merge with fixes of netcon to edge. 2015-12-08 15:15:44 -08:00
b1eb16d5fb Updated README, tests, and Intercept 2015-12-08 07:47:20 -08:00
f2db82940b Nginx patch. Verified to work in fc23 and ub14 2015-12-08 05:09:12 -08:00
a2837ccaa7 Fixed typo 2015-12-07 08:36:13 -08:00
284b37ccc0 Updated compatibility section 2015-12-07 08:35:26 -08:00
48d9708abe Combined make-linux.mk and make-intercept.mk's installer section 2015-12-07 06:54:13 -08:00
b141026fc7 Replaced darkhttpd with httpd since darkhttpd is not currently supported and does not work 2015-12-07 06:41:20 -08:00
c9bd0b3bf1 More concise unit test section 2015-12-07 06:30:54 -08:00
21b158cc48 Added unit test info to README.md 2015-12-07 06:21:40 -08:00
dab13f59e5 Test updates 2015-12-07 05:37:14 -08:00
036bbfaff9 Modified test scripts to match new naming conventions 2015-12-07 03:21:46 -08:00
afafde2571 Modified Nginx test scripts 2015-12-06 22:37:23 -08:00
1dec034f77 Added application-specific test arguments to test script 2015-12-06 17:55:48 -08:00
0df33485ca Merge remote-tracking branch 'origin/netcon' into edge 2015-12-04 15:41:56 -08:00
7ea53dd21b (WIP) Additional test script changes 2015-12-04 15:39:35 -08:00
3869d6257b Always Salsa20 encrypt the result of the system CSPRNG as a mitigation against various low-entropy bugs such as the recent Raspberry Pi one. 2015-12-04 14:50:24 -08:00
4e12899a8e docs 2015-12-04 14:17:33 -08:00
cebced259e docs 2015-12-04 13:48:53 -08:00
425d311ce8 Merge of netcon with edge and unification of make processes. 2015-12-04 13:19:31 -08:00
ac8918992b Merge dev. 2015-12-04 12:45:21 -08:00
cbf8d9c45b . 2015-12-04 12:43:48 -08:00
905253b4f5 First draft (unfinished) of new README for netcon (original in README.orig.md). 2015-12-04 12:43:21 -08:00
d9b12be697 ZT_NC_NWID patch + (WIP) test script modifications 2015-12-04 12:39:54 -08:00
2196d982c3 (fixed) nwid detection in test script 2015-12-03 18:50:20 -08:00
5c5943a00c (fixed) test script liblwip.so placement, also streamlined test logic 2015-12-03 07:11:33 -08:00
a4cfe4cd16 Fix Linux init script to properly specify runlevels. 2015-12-01 10:19:10 -08:00
ceaef19fb7 Fix for GitHub issue #260 -- fix for (non-exploitable) crash in network preferred relay code 2015-11-30 17:20:12 -08:00
944fdfb65e Low-impact sanity check against GitHub issue #247 -- will likely prevent other weird recursions too. 2015-11-30 16:44:32 -08:00
be44b15eac Fix for GitHub issue #252 2015-11-30 16:15:23 -08:00
d73edfea56 GitHub issue #257 2015-11-30 16:12:03 -08:00
c21882da9c Put selftest back and turn off tracing in PortMapper. 2015-11-30 16:07:02 -08:00
f260250580 Simplify IP assignment logic in OSXEthernetTap, also fix for GitHub issue #249 2015-11-30 15:39:34 -08:00
40a4ba6e39 indentation 2015-11-30 15:15:43 -08:00
d862d2868c ... and here. 2015-11-30 14:57:28 -08:00
1e213b4d4c Need to close on premature abort too or resources are leaked. 2015-11-30 14:56:36 -08:00
3d66492828 Also add a timeout for the actual NAT-PMP port mapping step. 2015-11-30 14:17:58 -08:00
838fdf4d11 ifdef naming fix. 2015-11-30 13:32:30 -08:00
685c5e9ad1 Fix for uPnP 2015-11-30 13:25:34 -08:00
66a29a00ee Merge miniupnpc/libnatpmp build into main build by just adding flags, defs, and objs. 2015-11-30 13:17:43 -08:00
6768521330 Ton of uPnP work and adding NAT-PMP support, still testing... 2015-11-30 13:10:22 -08:00
6c0de526e8 Merge pull request #261 from janjaapbos/synology
Fix for cross compiling
2015-11-30 11:07:20 -08:00
4c812e3796 Merge pull request #259 from janjaapbos/jb-dev
Increase maximum number of paths per IP scope to 4
2015-11-30 10:53:22 -08:00
e6808c69f8 Increase maximum number of paths per IP scope to 4
Otherwise, local discovered routes are ignored.
Don't know what the best value would be. Taking 4 for now.
2015-11-30 19:48:38 +01:00
75637f68b3 Merge branch 'dev' of github.com:zerotier/ZeroTierOne into dev 2015-11-24 14:11:31 -08:00
56cb2f43fa Merge pull request #254 from bonki/fix_iproute2_ip_handling
Fix for GitHub issue #253.
2015-11-24 14:11:14 -08:00
038476c412 Fix for GitHub issue #253.
Make 'ip' detection more robust (some distros don't ship the binary in /sbin or /usr/sbin).
Add error handling for cases where an ip add/remove fails.
2015-11-24 22:56:02 +01:00
201109a7a0 (fixed) make-linux.mk conflicts, updated clean logic 2015-11-23 16:02:39 -08:00
7e28161638 Merge dev 2015-11-30 15:17:31 -08:00
ef4472e185 Intercept now checks ZT_NC_NWID environment variable for 16-digit network ID and does not initialize if not present. 2015-11-23 13:59:38 -08:00
4acb3d81f3 Rename Common to common.inc.c to indicate that this is an included C file not a primary build C file. 2015-11-23 13:25:46 -08:00
bee44ae731 Merge Sendfd into Common.c 2015-11-23 13:24:28 -08:00
95106e2e30 Mare make-self-contained code cleanup. 2015-11-23 13:18:46 -08:00
2a6ea38718 More code cleanup, just moving some stuff into NetconEthernetTap that is not used elsewhere. 2015-11-23 13:02:50 -08:00
d8d4cfbf01 Eliminate a few warnings and some small code reorg. 2015-11-23 12:43:42 -08:00
34404eb300 Ignore more DLL patterns. 2015-11-23 12:34:46 -08:00
7a84805824 Uncommit binary... :P 2015-11-23 12:34:23 -08:00
1d4563ac31 A few very tiny bits of dead code removal, etc. 2015-11-23 12:32:20 -08:00
a18336fa18 MERGE current "dev" into "netcon" -- should not affect netcon itself but will retest -- brings ZeroTier core up to 1.1.0 2015-11-23 10:46:52 -08:00
1e4a40e772 Reformat table. 2015-11-23 10:11:46 -08:00
6e5feaba3a Updated test files 2015-11-23 07:08:07 -08:00
71b38a48ac Replaced README 2015-11-23 06:22:09 -08:00
6a3f230555 Unit test info added to README 2015-11-23 06:20:01 -08:00
a952ff2c61 Removed odd file 2015-11-23 06:11:19 -08:00
05e51f40b4 README formatting update. Removed odd files 2015-11-23 06:07:48 -08:00
b83aefcf8f Updated README, fixed node.js test bug 2015-11-23 05:59:05 -08:00
8b9b593256 Removed old READMEs and OS files 2015-11-23 05:21:20 -08:00
275a76ff5c Test update 2015-11-23 05:15:19 -08:00
3d163f7044 Patch for Node.js -- accept() bug 2015-11-23 01:14:17 -08:00
764dd1c3d9 ARP packets do need the source IP address in them, as well as the MAC address.
Packets wouldn't even show up in WireShark without the source IP in it.
2015-11-21 19:14:59 -08:00
ac09c3569a ARP packet lengths are 28 bytes. This condition required the packet to be 29 or more bytes. 2015-11-21 19:14:06 -08:00
ce5b7f0305 The World as of 2015-11-20 2015-11-20 12:49:23 -08:00
1fde17bacb Update World to reflect Alice and Bob in their final glory. Will hot-push this soon. 2015-11-20 11:46:10 -08:00
d472c59b8d Additional test files 2015-11-20 02:41:27 -08:00
126fc46dc4 Updated makefile, removed old results directory 2015-11-20 01:22:15 -08:00
d2e624f301 Updated makefile, removed old results directory 2015-11-20 01:19:16 -08:00
7173b0124b Removed old test directory 2015-11-20 01:13:04 -08:00
1f27022fa7 Test/Code Refactor in preparation for merge 2015-11-20 01:08:38 -08:00
9a25a627bb WIP: Unit tests -- more generalization 2015-11-19 17:34:56 -08:00
375aae44e4 . 2015-11-19 16:36:15 -08:00
31bc5e1559 WIP: Unit tests 2015-11-19 16:21:59 -08:00
b1100b3d13 WIP: Automated tests 2015-11-19 16:14:27 -08:00
399b2e9e26 forgot to submit this. Add DeferredPackets.cpp to the android makefile 2015-11-17 19:16:10 -08:00
6f16f44438 VERSION 1.1.0: Win/Mac UI improvements, improved NAT-t, CIRCUIT_TEST, and more!
ZeroTier 1.1.0 introduces a number of fixes and improvements in several areas.
We incremented the secondary version to indicate the significance of this release.

Version numbering has been a bit ad-hoc in the past. In future versions we will
adopt the following scheme: odd-numbered revision numbers like 1.1.1 will indicate
development versions, while even numbered ones like 1.1.2 will indicate tagged
releases. The public git repo branching has also been revised: master will always
be the latest tagged release, dev will be usually-working development, and edge
will host maybe-broken "bleeding edge" development. Pull requests on GitHub should
generally be made against dev, not master or edge. Other branches that may appear
from time to time may be feature or experimental branches. Only master is confirmed
good, with dev usually being okay but not guaranteed to be such. (To the extent
that any software is ever guaranteed to be anything.)

Change summary:

User-facing changes and improvements:

 - Windows now has a new .NET-based native UI, which replaces the old WebControl
   wrapper around the React UI. This just didn't work well on older Windows systems,
   and we did not want to bundle 40+ megabytes of web browser with our app just for
   its very simple UI.
 - The web UI (still used for Mac and usable in Linux as well) is updated with
   improved look and simplifications.
 - Both UIs no longer have the "Peers" tab, since several users reported that non-
   technical users found this confusing and even alarming (does this mean people
   can access my system?). This information is visibile with "listpeers" from the
   command line (zerotier-cli).

New features:

 - Virtual networks that use our RFC4193-based IPv6 numbering scheme now emulate
   IPv6 NDP for queries that target these addresses within the same network. This
   allows for faster multicast-free connection init and improved security since
   the address is now hard-wired to the device ID (which is a crypto token). This
   does not affect IPv6 NDP for other IPv6 addresses or link-local, which will
   continue to work normally. This also opens the potential for a reduced footprint
   multicast-free build for embedded applications.
 - This version includes beta support for a feature called CIRCUIT_TEST. Network
   controllers for networks you have joined can now send a special message called
   CIRCUIT_TEST which allows for ZeroTier-layer link testing and remote diagnosis
   of link issues. Any operator of a network controller can do this; more
   documentation will be forthcoming. The only information that may be gathered
   in this way is IP addressing info and very basic system info (OS, 32/64 bit,
   ZeroTier version). No personal information, hard drive data, location, or other
   private info is available. This can only be ordered by a controller of a network
   you have joined and is secured using cryptographic signatures.
 - This version includes an alpha version of clustering a.k.a. multi-homing! This
   powerful feature allows for a single ZeroTier device to be run from multiple
   endpoints, with connecting peers being handed off to endpoints that are closer
   via GeoIP lookup and/or are more lightly loaded. Currently this is only suitable
   for use in our soon-to-be-upgraded root server infrastructure (details will be
   blogged soon), but in the future it will be capable of hosting multi-homed
   devices on user networks. This will allow things like (for example) a geo-
   clustered Cassandra server that appears behind a single IP on a virtual LAN.
   This feature must be enabled with the ZT_ENABLE_CLUSTER=1 build option.

Bug fixes and other improvements (including performance!):

 - A faster version of the Poly1305 cryptographic MAC function was substituted
   for sometimes greatly improved performance.
 - C++ STL std::map was replaced throughout the entire core with a hand-rolled
   Hashtable implementation for improved performance and in some cases a reduced
   memory footprint. Some maps are still used in peripheral code that is not
   performance critical or where ordered keys are needed.
 - The zerotier-cli and zerotier-idtool symbolic links are now created in
   /usr/local/bin on OSX to comply with El Capitan file security restrictions.
 - The OSX tap device driver has been updated. This update may fix issues that
   some users have reported with bridging on OSX. This new tap device driver
   drops 32-bit support, but if you have a 32-bit system you can manually install
   the old driver from ext/bin/tap-mac.
 - Mac users could experience a problem with the UI if they installed ZeroTier,
   then uninstalled it, then installed again. This is now fixed.
 - UPnP port mappings should work better on some routers, and a different local
   port is now used for UPnP mapped traffic vs. NAT-t'd traffic to get around
   a bug in several popular mid-tier routers where using UPnP mapping alongside
   traditional NAT traversal made a port unreachable.
 - Debian package now builds with the right arch label on armv7l systems (Pi 2)
 - The old "root topology" has been replaced with a similar but better thought
   out concept called a World. The World defines the root servers and possibly
   in the future other things, and can be updated in-band from trusted peers
   allowing for software-upgrade-free network upgrades to keep up with growing
   demand. See node/World.hpp for details.
 - A fix was made to "self-awareness," which keeps track of your external IP
   info and adapts to changes, to eliminate a problem that could cause "link
   thrashing" behind some symmetric NATs.
 - Escalating UDP TTLs was re-introduced to better transit some port-restricted
   cone NATs such as Linux IP MASQ (used for Docker).
 - An otherwise harmless crash-on-exit bug in the network controller was fixed.
 - All new direct links are now confirmed in both directions. This adds a very
   small amount of initial HELLO/OK traffic but fixes some edge cases where an
   incomplete or unidirectional path might be used.
 - [SECURITY] Better rate limiting was put in place for VERB_PUSH_DIRECT_PATHS
   to prevent potential abuse for amplification attacks.
 - [SECURITY] Build flags were tweaked on OSX to ensure that all code including
   dependency libraries are built with full stack canary protection and ASLR
   support.

Visit https://www.zerotier.com/blog or follow @ZeroTier on Twitter for updates
and announcements!
2015-11-17 12:18:45 -08:00
1c0c3e62dc Just add a launch prerequisite for .NET 4.5 -- it's usually there, and if not it can be easily installed. This is mostly an issue on old Windows Server systems, and in that case the admin will likely want to decide how to proceed. 2015-11-17 11:13:44 -08:00
9169b6c999 Fix crash on exit in Windows (does not affect other OSes) and revert debugging tweak in Windows version that prevented service from starting after real install. 2015-11-17 09:56:19 -08:00
a660ec490e Started work on automated unit test scripts 2015-11-17 02:28:23 -08:00
f5c2600ca4 Added symbol checks in intercept. This seems wise after all 2015-11-16 23:57:19 -08:00
48745eca57 Fix ARM dpkg build. 2015-11-16 19:54:58 -08:00
b0f6dc43b4 Revised fd RX logic 2015-11-16 19:53:59 -08:00
456bfea58d Real World -- edge now talks to real net. 2015-11-16 19:27:36 -08:00
0f5fb48a0b Turns out it wasn't hard to add miniupnpc to the VS2012 project and just have it build with the rest of the code. 2015-11-16 19:04:04 -08:00
dc8edea0c6 Linux make rules to make libminiupnpc from source. 2015-11-16 18:33:52 -08:00
cf6164e847 Build libminiupnpc from source now, and update version. 2015-11-16 18:28:55 -08:00
a13a21377c Delete pre-build miniupnpc for Linux and Mac -- will add Make rules to build from source and include source in ext/ 2015-11-16 18:18:08 -08:00
37acd375d6 Fix 64-bit int warning. 2015-11-16 18:10:40 -08:00
f2289544b7 Check for fork/clone and re-initialize in close() -- for nginx 2015-11-16 17:44:11 -08:00
7a53ecac86 UI stuff. 2015-11-16 17:18:44 -08:00
906e49ff72 Add make option ZT_ENABLE_CLUSTER and disable it in default Linux build. 2015-11-16 16:22:41 -08:00
e4d1aba3f8 Use new OSX tap version, and update OSX install scripts. 2015-11-16 16:19:24 -08:00
38fe77ecf2 WebUIWrapper is dead. 2015-11-16 15:44:07 -08:00
8fde33d87c . 2015-11-16 14:45:17 -08:00
220552af62 GitHub issue #241 -- and also some appearance updates. Eventually this might get replaced by a native Mac app. 2015-11-16 14:30:25 -08:00
637d50a9de Write binary of world too. 2015-11-16 13:11:16 -08:00
f5b465c0e1 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2015-11-16 11:13:02 -08:00
6ac70ba808 . 2015-11-16 11:01:19 -08:00
08cd603623 Code to generate real World for edge. 2015-11-16 10:58:40 -08:00
ddf0cb0278 Docs and tweak some caching values. 2015-11-16 09:54:08 -08:00
75f8ee1b9c get the compiler to stop complaining about two string literals (one a macro) next to each other without an intervening space 2015-11-14 18:19:33 -08:00
0508a41afd added ttl parameter to WirePacketSendFunction 2015-11-14 17:40:17 -08:00
0d9f33dc4f Fix: (1) Windows stack overflow due to buffer too large in peer deserialize, (2) clean up some other stuff seen during debugging and reduce the sizes of some buffers due to Windows small stack size, (3) remove a redundant try/catch. 2015-11-13 12:14:28 -08:00
90f9415107 Update installer to drag along a net-install binary for .NET 4.5 that it runs if .NET 4.5 is not present... because yes we have to install Microsoft's own flagship runtime under some conditions. (Rare, but present.) 2015-11-13 09:11:12 -08:00
2ec638a23d New Windows UI tweaks: get rid of networks tab (only one tab!), make networks full width and make window narrower and a bit taller, colors, fixed-width fonts in several places, make network IDs selectable. 2015-11-12 17:38:30 -08:00
a6cffefa6d Updated compatibility 2015-11-12 17:15:44 -08:00
a818c622d9 Updated throughput_httpd docker test files 2015-11-12 16:57:45 -08:00
ccae473783 Eliminate Windows warnings. 2015-11-12 16:51:33 -08:00
54f68280bd Minor Windows build fixes. Builds on VS2012 again. 2015-11-12 16:48:42 -08:00
7d8084262a Fixed rpc_st command alignment bug for RPC_SOCKET 2015-11-12 16:48:08 -08:00
bacb53fe8f Remove old Windows NDIS5 tap driver -- I think this is dead. 2015-11-12 16:40:50 -08:00
33c132968e GitHub issue #219 -- make Linux makefile cross-compiler aware. 2015-11-12 15:37:32 -08:00
73e314cc1a Shelve pcap-with-bridge OSX experiment -- apparently pcap_inject does not work with bridge devices. Still have to use a kext. 2015-11-12 15:28:55 -08:00
6af54c5943 Minor debug updates 2015-11-12 14:49:20 -08:00
fa7220ec0e Removed old Common.h 2015-11-12 14:35:58 -08:00
d1a22a0878 Streamlined debug output code 2015-11-12 14:32:27 -08:00
8ac411a9e4 Stashing utun work for OSX -- abandoning for now since utun excludes mDNS among other issues. 2015-11-12 10:47:50 -08:00
e5fad005a9 Updated RPC handling 2015-11-12 08:21:05 -08:00
0940d673db Always advertise to the cluster when we have a peer even if we have also initiated handoff. This might be the cause of the warmup problem -- will test later. At the very least it should not hurt anything due to pick-latest logic and the fact that cluster members with only suboptimal paths do not respond to WANT_PEER. 2015-11-11 14:36:22 -08:00
b94335f115 Increase WHOIS retry delay slightly to allow for global cluster latency (e.g. 300+ms from New York to Johhannesburg) 2015-11-11 11:07:08 -08:00
a13ba7102a GitHub issue #242 -- crappy uPnP protocol demands infinite lease time or else 2015-11-10 17:45:05 -08:00
451b8aa7b2 Query both root and network controller for multicast last resort GATHER. 2015-11-10 17:37:38 -08:00
53731acf51 Bracket by time in result cruncher script. 2015-11-10 17:15:06 -08:00
3b9411044f Patch tap-mac to latest tuntaposx upstream changes, and add updated build for 10.8 or later (keep old one for 10.7). 2015-11-10 16:00:21 -08:00
141e2db38c More results. 2015-11-10 15:47:18 -08:00
0cf4ddda4a Some more test results, and fix OSX installer to put symlinks in /usr/local as per El Capitan requirements. 2015-11-10 15:11:15 -08:00
0e4a2c378f Fix a sporadic warning in cluster-geo, and fix test to not overload the test-watcher. 2015-11-10 13:09:58 -08:00
2854f14966 Some cluster parameter tweaks, and change the test code in tests/http to dramatically reduce the amount of data transfer to/from the test master. Also add results of first successful 50k test. 2015-11-10 11:59:03 -08:00
4328c6c3bc Fix delete oldest logic. 2015-11-10 09:46:14 -08:00
b171c9a0db Replace slow std::list<> with an O(log(N)) data structure for the cluster relaying send queue. 2015-11-10 09:05:01 -08:00
82a60b1e28 Fixed throughput build script 2015-11-09 20:16:27 -08:00
19f09e46fa Moved/Renamed Docker test dirs 2015-11-09 19:37:19 -08:00
134ad8ac21 Changed httpd version in throughput-test Dockerfile 2015-11-09 19:13:53 -08:00
32ec378e3b Announce that we have peers on the cluster when we first see them to improve startup times, and add a result crunching script to tests/http. 2015-11-09 18:01:23 -08:00
2cc50bdb10 Try bringing back TTL escalation -- may help with Docker (IP-MASQ) type NAT 2015-11-09 15:44:13 -08:00
94f4316a0e Fix for possible high CPU usage on multicast queries. 2015-11-09 14:54:05 -08:00
35c4e28f31 Mark geo-redirected paths as suboptimal and do not report that we have a peer if all we have is one of these. Also a few other small fixes. 2015-11-09 14:25:28 -08:00
47424df417 Fix (1) a deadlock bug and (2) a bug that prevented distributed rendezvous messages from being sent. 2015-11-09 13:39:06 -08:00
73e2c6e511 How did that ever work? 2015-11-09 12:24:49 -08:00
12cd9df059 . 2015-11-09 11:30:17 -08:00
4ad2ff2f71 . 2015-11-09 11:08:52 -08:00
b57c855a8c PROXY_SEND fix. 2015-11-09 10:25:20 -08:00
ed954c5ca2 . 2015-11-09 10:09:16 -08:00
21341ab15c Ready to test. 2015-11-09 09:45:43 -08:00
f4d12603e0 Tweak how Switch passes off to Cluster on relay to fit new paradigm. 2015-11-09 09:19:03 -08:00
ff81415ffe Build fixes... 2015-11-09 09:14:26 -08:00
5371195c80 Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2015-11-09 09:01:58 -08:00
473ce82040 Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge 2015-11-09 09:01:41 -08:00
ab013d831c . 2015-11-09 09:01:38 -08:00
57b71bfff0 Cluster simplification and refactor work in progress... 2015-11-08 13:57:02 -08:00
6bc8c9d8ef Clustering cleanup, still a work in progress. 2015-11-06 16:12:41 -08:00
5f39d5b7ea Further pare down Cluster messaging and rename some stuff. 2015-11-06 14:37:17 -08:00
9490b1f136 Try prioritizing cluster-send over direct send in cluster mode -- may improve cluster relaying reliability. 2015-11-06 13:38:56 -08:00
badec136fc New agent master IP. 2015-11-06 11:55:06 -08:00
8ea5f424fd Small amount of cleanup. 2015-11-06 11:15:06 -08:00
3cafa60284 fix up some borders & colors 2015-11-05 19:44:19 -08:00
2415ae45c1 remove the peers page 2015-11-05 19:44:19 -08:00
aa169b54de Add conntrack tweak to nf for testing. 2015-11-05 18:06:04 -08:00
83c6b7ab3d Use bigger UDP buffer on bigger x64 machines. Keep old value elsewhere since these are likely to be smaller boxes. 2015-11-05 17:41:07 -08:00
ba5008c370 Now make cluster announcements slightly more frequent. 2015-11-05 17:28:55 -08:00
3fa1b5a89d Make cluster HAVE_PEER a little lighter by removing full identity. Technically this is not necessary and they will propagate over time in any case. Might restore it in some form in the future. 2015-11-05 17:22:22 -08:00
7603d8cee8 Merge branch 'edge' of http://git.int.zerotier.com/zerotier/ZeroTierOne into edge 2015-11-05 16:46:42 -08:00
869eff49bc . 2015-11-05 16:46:33 -08:00
d9abc28fe3 . 2015-11-05 14:54:54 -08:00
3e22fee842 Integrate deferred background processing into main OneService implementation. 2015-11-05 12:41:14 -08:00
5ec5911e1b Merge branch 'edge' of http://10.6.6.2/zerotier/ZeroTierOne into edge 2015-11-05 12:23:06 -08:00
8ef4edebbf Deferred decode for HELLO to prevent HELLOcalypse under high load of new peers. 2015-11-05 12:22:58 -08:00
86c74d8a65 set manifest to require administrator privileges and read the authtoken and port from disk 2015-11-04 20:34:49 -08:00
49086e4556 just a little xaml cleanup 2015-11-04 20:31:41 -08:00
4c7bb06894 make the main window width a bit smaller 2015-11-04 20:19:14 -08:00
f3e527e130 update the peer list in place rather than replacing it 2015-11-04 20:17:58 -08:00
df74dd6e41 make the peers page prettier 2015-11-04 20:03:25 -08:00
5e9166cec7 setting width/height isn't necessary 2015-11-04 19:30:26 -08:00
d2c288b13f Fix vertical scrolllbar on networks view 2015-11-04 19:12:12 -08:00
fc32dc11a6 make the networks view a bit prettier 2015-11-04 19:08:13 -08:00
2721804ebf make the tabs a little prettier 2015-11-04 18:41:08 -08:00
7b86176d0e Don't go kaboom when the ZeroTier service isn't running. 2015-11-04 18:28:07 -08:00
a95ff21aaf test stuff 2015-11-04 15:09:19 -08:00
3e84e8b8c3 Performance tweaks to lwipopts.h (TX=12MB/s) 2015-11-04 14:45:26 -08:00
9ec32e7926 Agent settings for big test. 2015-11-04 13:28:43 -08:00
7756b5bf1c Merge branch 'android-jni-dev' into edge 2015-11-03 19:15:00 -08:00
eadeac0a42 logging of events 2015-11-03 19:14:11 -08:00
4b07987210 Added throughput-test Docker files 2015-11-03 18:10:39 -08:00
172fc1052b Merge windows-ui into edge. 2015-11-03 17:38:36 -08:00
523412edfb Abort backup in progress if thread is told to shut down. 2015-11-03 16:03:00 -08:00
f7a407ffa0 Tweak timings and use lock in backup to make it a bit faster and still permit main thread to work. 2015-11-03 15:56:24 -08:00
7903f24a8f Create periodic backup copies of controller.db in network controller from the main process itself to facilitate easier and safer backups of controller.db. 2015-11-03 15:52:10 -08:00
4b655ab22c tests 2015-11-03 14:39:44 -08:00
d9d11042ca . 2015-11-03 12:56:34 -08:00
0b245b031e Allow ZT_TRACE without debug. 2015-11-03 11:20:12 -08:00
a42d714a87 . 2015-11-03 11:18:45 -08:00
c9e6e60c09 Handle ZeroTier-RFC4193 IPv6 address NDP queries inline by spoofing responses if the addressing scheme matches -- this allows multicast-free instant lookup of local IPv6 for better performance and reliability. 2015-11-03 10:46:41 -08:00
df391c8413 Added debug statements for transfer test 2015-11-03 10:30:18 -08:00
4c20fa4874 Added debug statements for transfer test 2015-11-03 10:26:10 -08:00
b7df177f33 updates for origin/edge 2015-11-02 19:18:55 -08:00
179b064b05 Merge branch 'edge' into android-jni-dev 2015-11-02 18:32:21 -08:00
a19e82fcbc Merge branch 'edge' into windows-ui 2015-11-02 18:30:54 -08:00
ccbdb1a3a1 RPC command index fix 2015-11-02 16:09:28 -08:00
4e9d430476 Make root and relay selection somewhat more robust. 2015-11-02 16:03:28 -08:00
8d7b2cd486 Removed serv. conn. checks. 2015-11-02 15:52:12 -08:00
00dcb0f22c . 2015-11-02 15:39:09 -08:00
7fbe2f7adf Tweak some more timings for better reliability. 2015-11-02 15:38:53 -08:00
fd33e0812c Added checks for bad service connection. 2015-11-02 15:31:57 -08:00
60ce886605 Tweak some timings for better reliability. 2015-11-02 15:15:20 -08:00
ab27a91b07 . 2015-11-02 13:53:27 -08:00
24ffb22fa6 Changed default debug level 2015-11-02 13:26:59 -08:00
da462bbd55 Removed curses dependency 2015-11-02 13:21:40 -08:00
fd3916a49e More test stuff... make it more granular and less batch based. 2015-11-02 13:17:11 -08:00
bb912cff30 More appropriate phyOnUnixClose handling 2015-11-02 12:50:32 -08:00
e53ef9642e test stuff. 2015-11-02 12:31:34 -08:00
6338a4933b Fixed another closure bug. Updated debug levels 2015-11-02 12:30:18 -08:00
29249db5d2 Big test stuff. 2015-11-02 11:37:32 -08:00
4dbb84cea1 Fixed connection closure bug (ERR_ABRT from nc_recved) 2015-11-02 10:59:46 -08:00
f1b6427e63 Decided to make this 1.1.0 (semantic versioning increment is warranted), and add a legacy hack for older clients working with clusters. 2015-11-02 09:32:56 -08:00
db473beb48 Fixed accept return value / errno bug, also fdret_sock return bug 2015-10-30 17:00:30 -07:00
1b4cc4af5c Fix evil bug, and instrument/assert on some other stuff, and a bit of cleanup. 2015-10-30 15:54:40 -07:00
7382c328da Null pointer bug appears fixed... testing again at large scale. 2015-10-30 14:23:28 -07:00
641b0dec44 . 2015-10-30 14:12:20 -07:00
2fbb5d0bbf . 2015-10-30 14:11:45 -07:00
d8dbbf7484 Add some debug code in TRACE mode to catch a bug. 2015-10-30 14:11:10 -07:00
377ccff600 getPeer() had a small potential to be unsafe. 2015-10-30 13:39:28 -07:00
f974517f64 Save zerotier output in containers. 2015-10-30 13:06:30 -07:00
f808138a94 docs and stuff 2015-10-30 13:05:34 -07:00
b845dd1b88 Set contact IP for real test. 2015-10-30 12:38:12 -07:00
b6725c4415 Optimize AntiRecursion. 2015-10-30 11:48:33 -07:00
5bfa29dded Make antirec tail len slightly shorter, better performance and still plenty long enough. 2015-10-30 11:09:40 -07:00
80e62ad291 docs 2015-10-30 10:55:05 -07:00
e2fc20876d docs 2015-10-29 18:23:41 -07:00
96eb0ce492 Added state dump, fixed numerous RPC related bugs 2015-10-29 17:57:59 -07:00
d6c0d176ee Periodically re-announce peers that we have. 2015-10-29 10:10:09 -07:00
9f0f0197fe More dead code removal. 2015-10-29 09:44:25 -07:00
a994573a43 Eliminate some more dead code. We may do path trust, but not like that. 2015-10-29 09:42:15 -07:00
883c84bdb9 Tweak some timings, and remove some dead code. 2015-10-29 09:39:36 -07:00
f6e0bdb2f2 Fixed PCB state issue when closing connection 2015-10-28 16:18:08 -07:00
e3d811b04b docs 2015-10-28 15:55:40 -07:00
cabb8752cb docs 2015-10-28 15:28:05 -07:00
1f5ef968cf Test need a more recent version of NodeJS so update Dockerfile. 2015-10-28 15:08:00 -07:00
c8f27da294 Added support for MongoDB (server side) 2015-10-28 14:37:46 -07:00
68d6d3c4ff Fix bug in peer count. 2015-10-28 14:29:08 -07:00
4c24e0cfb0 More tweaks to tests... just about ready to run at scale. 2015-10-28 14:24:54 -07:00
9653531242 . 2015-10-28 14:18:58 -07:00
07c1b4ddee test stuff 2015-10-28 14:16:58 -07:00
1cae7327ae Basic Dockerfile for building test agents. 2015-10-28 13:35:52 -07:00
c03550de35 HTTP test works! 2015-10-28 13:14:53 -07:00
c6a918d996 HTTP test code. 2015-10-28 12:50:48 -07:00
0034efafe4 On semi-undocumented test net, assign a RFC4193 IPv6 address too. Will be useful for our at-scale tests. 2015-10-28 11:08:15 -07:00
0fd15d9cf3 Fix inverted sense bug. 2015-10-28 10:38:37 -07:00
938d0a970b TRACE build fixes. 2015-10-28 10:01:32 -07:00
fdc3e103cc Cleanup and docs. 2015-10-28 09:38:33 -07:00
c1b0329969 Only check IP equality to detect external surface changes (should prevent some spurious resets under symmetric NATs), and simplify some logic. 2015-10-28 09:32:07 -07:00
da93712846 Clean up PUSH_DIRECT_PATH limits a bit more and make them a bit smarter. 2015-10-28 09:11:30 -07:00
cdc99bfee1 Add a circuit breaker for VERB_PUSH_DIRECT_PATHS. 2015-10-27 18:18:26 -07:00
88b100e5d0 More cleanup. 2015-10-27 17:59:17 -07:00
21889305e0 Updated README.md 2015-10-27 17:41:51 -07:00
18db95d0e9 Updated README.md 2015-10-27 17:38:56 -07:00
51fcc75354 Some cleanup, and use getPeerNoCache() exclusively in Cluster. 2015-10-27 17:36:47 -07:00
721d58b464 Added support for Redis 2015-10-27 17:12:32 -07:00
4221552c0b Use getPeerNoCache() in Cluster to avoid keeping all peers cached everywhere. 2015-10-27 16:52:44 -07:00
cc1b275ad9 Replicate peer endpoints and forget paths if we have them -- this allows two clusters to talk to each other, whereas forgetting all paths does not. 2015-10-27 16:47:13 -07:00
cc6080fe38 (1) No need to confirm if we are a root (small optimization), (2) Refactor peer affinity tracking. 2015-10-27 15:57:26 -07:00
6399f6f094 This no longer has to be quite so fast. 2015-10-27 15:02:15 -07:00
218ef07d8e Build fix in TRACE mode. 2015-10-27 15:01:11 -07:00
16bc3e0398 Factor out RemotePath subclass of Path -- no longer needed, just cruft. 2015-10-27 15:00:16 -07:00
40976c02a4 Forget paths to peers if we are handing them off. 2015-10-27 14:37:38 -07:00
f692cec763 Change how cluster relays packets -- just PROXY_UNITE and then send packet via normal ZeroTier front plane -- more efficient and eliminates fragmentation issues. 2015-10-27 14:04:12 -07:00
40e0a34a5c Add set buffer sizes code to Phy<> 2015-10-27 13:04:08 -07:00
7295fcfa86 Merge Phy<> from netcon. 2015-10-27 12:50:23 -07:00
cfe166ef35 Tweak some size limits. 2015-10-27 12:29:01 -07:00
0ffbd05c0e --wtf; prevent roots from TCP fallback 2015-10-27 12:21:57 -07:00
a1a0ee4edb Fix infinite loop in Cluster, clean up some stuff elsewhere, and back out rate limiting in PUSH_DIRECT_PATHS for now (but we will do something else to mitigate amplification attacks) 2015-10-27 12:01:00 -07:00
54a99d8e32 Well that was broken. 2015-10-27 11:14:07 -07:00
62db18b6dd Lessen this limit just a bit to make cluster settle faster. 2015-10-27 11:01:58 -07:00
f32e9d07dd Don't include COM if not necessary (fix). 2015-10-27 10:58:01 -07:00
700c3166b7 Fix inverted sense bug. 2015-10-27 10:51:11 -07:00
17e7528e2c More root cleanup. 2015-10-27 10:40:31 -07:00
8a7a0b6b88 Cleanup, including simplification of root server picking algorithm since we no longer need all that craziness. 2015-10-27 10:37:39 -07:00
9617208e40 Some cleanup, and use VERB_PUSH_DIRECT_PATHS to redirect newer peers. 2015-10-27 09:53:43 -07:00
fb3b7a3baa Take -DZT_ENABLE_CLUSTER out of Mac defaults. 2015-10-27 09:41:12 -07:00
69857b4ba8 Refactor cluster redirects to move code to push peers out of the actual Cluster function that checks for redirect, and clean up Peer::received() to be a bit more logical. 2015-10-27 09:36:48 -07:00
0ffcfa307e another build setting 2015-10-26 20:26:19 -07:00
16c812ec80 set the app icon for release 2015-10-26 20:24:08 -07:00
268fbdabce disable sorting of peers 2015-10-26 20:06:53 -07:00
87496e9f4a can now leave networks 2015-10-26 19:53:03 -07:00
300a951730 Figured out how to expand controls to fill parent. yay 2015-10-26 19:39:54 -07:00
095539de29 Initial peers page 2015-10-26 19:21:21 -07:00
c4c67e591b add error handling for JSON serialization 2015-10-26 19:02:19 -07:00
502aa68bb7 change int to UInt64 for these properties 2015-10-26 19:01:59 -07:00
81cb4bc8d6 set up a timer to update the UI from a background thread 2015-10-26 18:31:10 -07:00
e713f7a54c Can redirect in response to a few more verbs, just not these. 2015-10-26 18:20:40 -07:00
352b83252f Merge branch 'adamierymenko-dev' into windows-ui 2015-10-26 18:10:27 -07:00
a0c3083af0 disallow paste of non hex characters 2015-10-26 18:08:44 -07:00
98d856daa2 Only send redirects to the sending InetAddress and only in response to a set of certain frame types to avoid potential race conditions. 2015-10-26 17:58:51 -07:00
8bfb02ba3c Only send redirects for the same address class, and elminiate some TRACE noise. 2015-10-26 16:55:55 -07:00
0b82c9ebad Fix infinite loop if there are no live roots (never happened before?!? wow!) 2015-10-26 16:09:56 -07:00
de761c5a82 Fix test world def. 2015-10-26 15:47:32 -07:00
6cf1da166f Add the whole new World, though with test identities at this point. 2015-10-26 15:12:28 -07:00
6625d79296 Fix if cluster compiled in but not enabled. 2015-10-26 13:07:00 -07:00
debed1ac2d Expose cluster status in /status JSON response. 2015-10-26 13:06:10 -07:00
5ff7733f84 More plumbing of cluster status. 2015-10-26 12:49:17 -07:00
865acfa40f Cluster status plumbing. 2015-10-26 12:41:08 -07:00
3ce5ad9e2c For forward compatibility, add minimal parse for some future physical address types. 2015-10-26 10:42:30 -07:00
d2b1dfe424 Fully specify new network in alice-test, this will (with different identities) eventually become the World. 2015-10-23 15:51:50 -07:00
55dcf4c65f wire up the join network button 2015-10-23 15:50:49 -07:00
7e635d37ad only accept hex characters for network id 2015-10-23 15:49:04 -07:00
b7b973624a add methods for joining/leaving networks, and getting peers 2015-10-23 15:37:36 -07:00
62059a91aa C#-ifying stuff 2015-10-23 15:36:42 -07:00
35676217e8 Refactor multicast group announcement to work directly or indirectly. 2015-10-23 14:50:07 -07:00
8cfee8a38c Changed to more appropriate APP_POLL_FREQ 2015-10-23 14:31:06 -07:00
80a73cb14b Minor cleanup 2015-10-23 14:23:04 -07:00
e9648a6cdf Clarify logic in pinging, and prevent roots from pinging "down." 2015-10-23 14:05:12 -07:00
e6a63f5547 Fix bug in setWorld that might have caused a peer entry for myself (which would never be used) 2015-10-23 13:57:02 -07:00
b48ed824e6 Improved RPC connection closure logic 2015-10-23 13:37:41 -07:00
29b966894c (1) Fix bug in geo-ip service that prevented cache lookup, (2) fix problem in SelfAwareness (will need to test ALL versions in the wild with this), and (3) add more TRACE instrumentation to Cluster. 2015-10-23 13:03:34 -07:00
f0160635a2 Add --harmony for older nodeJS. 2015-10-23 12:05:17 -07:00
964b30902a Cluster fix: was accumulating remote endpoints endlessly. 2015-10-23 11:51:18 -07:00
2a3dd53952 . 2015-10-22 17:50:00 -07:00
236e474553 Unload lwipstack->_libref upon exit 2015-10-22 16:26:29 -07:00
dee6e7e3c1 . 2015-10-22 16:11:48 -07:00
7711eba297 More cluster wiring... 2015-10-22 16:02:01 -07:00
2f4628520b Improved RPC connection cleanup logic 2015-10-22 13:20:50 -07:00
b203d25656 PhySocket NULL check added to handle_write. Fixed after-close handle_write segfault 2015-10-22 12:40:01 -07:00
1bc451ed10 GeoIP cluster service works. 2015-10-22 10:41:15 -07:00
e07bae2525 Run geoip cluster service sub-process. 2015-10-22 10:18:05 -07:00
5304b0d8d1 Rename index.js so process is distinguishable. 2015-10-22 09:09:15 -07:00
fe6960888a add a scroll bar to the network info view 2015-10-21 20:40:43 -07:00
5b6ddaa2d7 Base windows UI is working.
* No joining/leaving networks yet, but they do display.
* Nothing is updated yet after first load of the app.  Need to set up a background task to run updates.
2015-10-21 20:29:03 -07:00
6471c1f4e2 Merge branch 'adamierymenko-dev' into windows-ui 2015-10-21 17:35:38 -07:00
8e7e409fce Updated netcon README 2015-10-21 16:56:39 -07:00
1458dc8347 set O_NONBLOCK default in accept() 2015-10-21 16:32:27 -07:00
303579cb42 Added Node.js support 2015-10-21 16:27:17 -07:00
a46514b397 Cluster-geo launcher. 2015-10-21 12:47:02 -07:00
25a84e30fc Code for cluster-geo service. 2015-10-21 12:41:46 -07:00
978b056a01 Wire in redirectPeer(), now about ready to test clustering! 2015-10-20 17:36:10 -07:00
6a7b47e5e1 Forgot a return true. 2015-10-20 17:27:57 -07:00
d6dee7bb5c Clustered handling of relaying. 2015-10-20 17:22:53 -07:00
35a12b94ea Outfit Cluster with TRACE for debugging. 2015-10-20 16:48:49 -07:00
2258e36a59 Move replication of COMs to avoid race condition. 2015-10-20 16:34:21 -07:00
59e1444b27 Finish wiring up Cluster, fix some issues with other recent changes. 2015-10-20 16:31:41 -07:00
eb79d4a2f3 Wire up peer announcement in cluster. 2015-10-20 16:24:21 -07:00
57e29857cf Cluster work -- integrating with the rest of the code. 2015-10-20 15:27:53 -07:00
21ae423feb . 2015-10-19 21:19:23 -07:00
9ba5c91d4a initial layout for network info 2015-10-19 21:17:18 -07:00
80d02d189a set the main window icon 2015-10-19 20:30:21 -07:00
56267b2aed setting icon and a few other settings 2015-10-19 20:29:06 -07:00
6040574d8d set up project and base UI for a native windows UI for ZeroTier 2015-10-19 20:20:42 -07:00
5e6eae620b Make _members dynamically allocated due to static array limit on ARM. 2015-10-19 16:18:57 -07:00
69dad37d8f Restore default World for commit to upstream 2015-10-19 15:23:43 -07:00
cfdcce6d12 Fix very obscure IP scope classification logic bug. 2015-10-19 15:19:04 -07:00
0b2e5ed499 Fix some broken logic in Path::reliable() 2015-10-19 15:11:43 -07:00
9150778757 . 2015-10-19 15:04:26 -07:00
50f3ccd3c9 . 2015-10-19 15:03:58 -07:00
584072fa6a Fix for V4/V6 stable addressing. 2015-10-19 14:04:36 -07:00
3adb183c5f Fix bad COM attachment bug and eliminate an unnecessary redundant check. 2015-10-19 13:38:27 -07:00
95953b48f9 Do not allow VERB_RENDEZVOUS from non-upstream peers to block potential DOS vector. 2015-10-19 12:56:29 -07:00
aa6e3c79a0 Some test stuff that will not be pushed elsewhere. 2015-10-19 10:49:31 -07:00
0c43d34ce3 World test stuff... some of this will be yanked before release. 2015-10-19 10:00:35 -07:00
8b03965912 Added status debugs 2015-10-16 19:30:01 -04:00
82e0abc4be Fix for cross compiling 2015-10-17 00:15:10 +02:00
0405ba1ccf Misc changes 2015-10-16 18:02:07 -04:00
738fa5a5e5 . 2015-10-16 12:10:57 -07:00
b96c08f35c Fixed nginx listen() bug 2015-10-16 14:43:38 -04:00
cc4d0199e7 Fix vProto init. 2015-10-16 10:58:59 -07:00
781f06ef82 Accept OK for confirm of HELLO or ECHO. 2015-10-16 10:48:38 -07:00
f9f60f89d9 Peer save/restore fix. 2015-10-16 10:45:58 -07:00
5ce3aac929 Add rate limit on receive of DIRECT_PATH_PUSH to prevent DOS exploitation. 2015-10-16 10:28:09 -07:00
2229e91b57 IPv6 support fixes. 2015-10-16 10:10:12 -07:00
2debde3451 GitHub issue #235, and I also see no reason not to communicate with people from other Worlds. 2015-10-15 07:22:17 -07:00
3e8e025704 Minor cleanup items 2015-10-14 19:55:21 -04:00
a775ee7d31 . 2015-10-14 16:21:39 -07:00
9ece8c465e decrypt fix 2015-10-14 15:49:41 -07:00
499d1628c7 Improved error coverage 2015-10-14 17:59:11 -04:00
59389b3dce Untested cluster code, not enabled. 2015-10-14 14:17:55 -07:00
619e113748 Work in progress on Cluster for new root infrastructure, multi-homing. 2015-10-14 14:12:12 -07:00
e722eab892 Disabled TCP listen backlog, must be enabled in lwipopts.h 2015-10-14 17:03:32 -04:00
9ca699c86d Added support for listen backlogs 2015-10-14 16:04:26 -04:00
d45db0f5af Fixed premature connection close bug 2015-10-14 15:46:22 -04:00
0b5a2a7594 Removed character from NEtconEthernetTap.cpp 2015-10-14 13:49:13 -04:00
831a513b2d Normalized cases 2015-10-14 13:47:35 -04:00
c312ae221f Fix for world size in OK(HELLO) 2015-10-14 10:45:33 -07:00
a35b6589d2 Removed lowercase intercept.h conflicting file 2015-10-14 13:43:12 -04:00
719233617c Add uint16_t key to Hashtable, and make Salsa20 zero its keyspace on destruction. 2015-10-14 10:14:07 -07:00
3c8e74023f Inconsequential. Updated commends, added debug statements 2015-10-13 20:20:45 -04:00
71c6ec71e5 connect() now checks socket family 2015-10-13 19:27:19 -04:00
1fd04557c7 Refactored connect(), added checks to socket(), updated checklists 2015-10-13 19:12:12 -04:00
aa6ff039c4 Improved bind() logic, added more error handling to accept() 2015-10-13 18:33:56 -04:00
8a05efa365 EBADF, EOPNOTSUPP, EMFILE error repoarting for accept() 2015-10-13 17:57:17 -04:00
da536cc311 Improved error reporting 2015-10-13 17:37:54 -04:00
0912d4be59 Fixed socket protocol check logic in socket() 2015-10-13 17:05:11 -04:00
489e1a5b83 Don't keep connections up longer than the alive timeout (unless they are relays or roots) 2015-10-13 13:51:54 -07:00
824ed99160 . 2015-10-13 12:42:54 -07:00
385f1410d2 Expose world info in JSON. 2015-10-13 12:33:15 -07:00
70d8e3ad94 Expose world ID and world timestamp in ZT_NodeStatus 2015-10-13 12:31:38 -07:00
71348f3ebb docs 2015-10-13 12:29:01 -07:00
e268d9492a cleanup 2015-10-13 12:18:47 -07:00
123c466843 Full integration of World and World updates. 2015-10-13 12:17:47 -07:00
5d2f523e81 World stuff... 2015-10-13 12:10:44 -07:00
73145de618 Added some parameter checks from linux kernel syscall source 2015-10-13 14:27:30 -04:00
05677f57e2 Add C output to mkworld. 2015-10-13 08:55:21 -07:00
cae58f43f1 More World stuff, and mkworld. 2015-10-13 08:49:36 -07:00
82052459a2 Odds and ends 2015-10-12 21:50:41 -04:00
4e1e857949 Minor bug fixes 2015-10-12 21:26:32 -04:00
1b1945c63e Work in progress on refactoring root-topology into World and adding in-band updates. 2015-10-12 18:25:29 -07:00
8d1b01cb5b Bug fix: Connection fd lookup in service 2015-10-12 20:46:59 -04:00
70fe7dd1fd cleanup 2015-10-12 16:40:57 -07:00
5dffa43201 Additional retval+errno handling 2015-10-12 19:29:27 -04:00
6b1a38f14c Better retval+errno handling 2015-10-12 16:38:08 -04:00
fe8e7ded8c retval+errno return test 2015-10-09 20:27:38 -04:00
eff1fe3c61 Create files for each hop (more convenient) and fix a packet parse bug. 2015-10-09 16:22:34 -07:00
7d01fab132 Reorg fields to be in same order as FS scheme. 2015-10-09 15:18:01 -07:00
c9295a5883 . 2015-10-09 15:12:05 -07:00
aec13b50fd Be a bit more verbose in circuit test reports to more clearly track current and upstream hop in graph traversal history. 2015-10-09 15:05:26 -07:00
a95fa379cc Circuit tests basically work but need some tweaks, and fix some issues found with valgrind. 2015-10-09 14:51:38 -07:00
07536216c2 Removed netcon/.depend 2015-10-09 17:36:27 -04:00
3bcb6bf321 Minor cleanup 2015-10-09 17:31:22 -04:00
7f56678d84 Added liblwip.so and libintercept build files 2015-10-09 17:06:09 -04:00
97dee9de36 Add more helpful example stuff. 2015-10-09 12:50:52 -07:00
e3ec000e93 Added intercept build file and sources 2015-10-09 15:41:16 -04:00
6b5bb0b278 Eliminate format string warnings. 2015-10-09 12:22:13 -07:00
e33adad8f5 Script to quickly generate test docker env files. 2015-10-09 12:15:42 -07:00
769bad3320 Test: Added handle_write call to nc_poll 2015-10-09 15:05:45 -04:00
9a25651151 . 2015-10-09 10:14:45 -07:00
c2bbec2f05 Docker example (and useful for testing) 2015-10-09 10:14:20 -07:00
0c498556d5 Unroll Salsa20 fully for a little more speed (non-SSE now almost as fast as SSE) 2015-10-09 09:39:27 -07:00
3fa6dd377f docs 2015-10-09 08:51:57 -07:00
6600b005b6 No Whack! 2015-10-08 21:24:51 -04:00
b5b57aca02 Whack! 2015-10-08 21:04:47 -04:00
160278c489 Little bit of reorg in Salsa20 which seems to speed things up very slightly. 2015-10-08 17:42:53 -07:00
d868a234da Refactored write logic 2015-10-08 19:38:29 -04:00
59da8b2a4b Logging of circuit test results to disk. 2015-10-08 15:44:06 -07:00
41dfbe544f Removed exit(0) for debugging 2015-10-08 18:10:10 -04:00
bbfc9359e9 Minor timer changes (~21 Mb/s local) 2015-10-08 17:55:58 -04:00
558775d544 Merge branch 'adamierymenko-dev' of http://10.6.6.2/zerotier/ZeroTierOne into adamierymenko-dev 2015-10-08 13:26:43 -07:00
a3876353ca Abiltiy to post a test via the controller web API, and parsing of CIRCUIT_TEST_REPORT messages. 2015-10-08 13:25:38 -07:00
273f0d18b0 docs 2015-10-08 09:05:25 -07:00
9347d6c866 Make it so ZeroTierOne.h can be used with a C compiler again. 2015-10-07 18:04:40 -07:00
fea1b6b2c3 docs 2015-10-07 16:25:08 -07:00
0ce0bc00d2 Make sure received() gets called for some new messages, and docs. 2015-10-07 16:20:54 -07:00
69b44bf9a5 Finally add an ECHO. 2015-10-07 16:11:50 -07:00
73cafbe0ec Limit proof of work difficulty to something sane. 2015-10-07 13:46:44 -07:00
e5f168f599 Add proof of work request for future DDOS mitigation use. 2015-10-07 13:35:46 -07:00
7d62dbe9f7 Tune NAT-t keepalives so that timing is better obeyed, clean up a build warning, and fix a potential source of network recursion (though harmless). 2015-10-07 11:57:59 -07:00
13f14c2f4c Kill debug line. 2015-10-07 10:56:47 -07:00
c952fbbd8d Only enable 128-bit Poly1305 on X86_64 right now. Has compilation issues on ARM, but the 64-bit version should be fine. 2015-10-07 10:40:59 -07:00
ab0228f626 More cleanup and simple refactoring, consolidate InetAddres serialize/deserialize into the class. 2015-10-07 10:30:47 -07:00
6c7ce79c89 Be consistent in how enums are defined in the main .h file. 2015-10-07 09:51:35 -07:00
1b2cac0cc5 Trim some cruft that is not used and probably never would be. 2015-10-07 09:38:33 -07:00
1bc33ae8d7 Minor debug output changes 2015-10-06 21:22:08 -04:00
598a1d8dd7 Try reopening /dev/urandom if there is a problem. 2015-10-06 18:10:40 -07:00
64aaea3978 Cleanup, and add an even faster Poly1305 on systems that support it. 2015-10-06 18:04:53 -07:00
876aa0883d Merge branch 'adamierymenko-dev' into netcon 2015-10-06 17:56:47 -07:00
477feee8a3 Some work on CIRCUIT_TEST, and a significant speedup to Poly1305. 2015-10-06 17:55:57 -07:00
36db5865e7 Refactored tcp_write code - Reduced CPU usage to respectable levels 2015-10-06 20:32:48 -04:00
7394ec6f6a Prep in controller code to run tests. 2015-10-06 15:56:18 -07:00
3593fb3462 Send initial CIRCUIT_TEST packet. 2015-10-06 15:16:41 -07:00
d3f29d09e8 Plumbing through circuit test stuff. 2015-10-06 14:42:51 -07:00
5341afcdcd Handling of CIRCUIT_TEST, should be ready to test. 2015-10-06 11:47:16 -07:00
57c857e89a Fix TRACE output. 2015-10-06 06:57:00 -07:00
c16ad053b6 no toString() method on peer. Commenting out for now. 2015-10-02 19:39:46 -07:00
6080a45c9c change cert to com. no variable named cert. 2015-10-02 19:39:13 -07:00
5384f185ae Simplify Dictionary and reduce memory usage, now no more std::maps in core. 2015-10-01 18:12:16 -07:00
76a95dc58f The return of peer peristence. 2015-10-01 17:09:01 -07:00
5076c49210 Peer serialization and related changes. 2015-10-01 15:40:54 -07:00
72e7e36a5b No reason to randomly pick uPnP secondary port. In fact it would likely cause problems on restarts and uPnP rule bloat. 2015-10-01 14:40:28 -07:00
2fa21aa676 . 2015-10-01 13:43:57 -07:00
3999e468b7 Need to hold nconf so *com does not die while being used. 2015-10-01 13:43:15 -07:00
6693149f3e Send COM with MULTICAST_GATHER for future use. 2015-10-01 13:34:12 -07:00
2c196307ee --bugs; 2015-10-01 13:01:18 -07:00
d6676a9d6c Always announce multicast groups, not just to peers with direct links, and push network COMs to any MULTICAST_LIKE recipient for future use. 2015-10-01 12:50:19 -07:00
a7409850d6 Get trim() out of core where it is not needed. 2015-10-01 12:37:18 -07:00
53e5f94b99 . 2015-10-01 12:25:43 -07:00
64bf3ffe6c Mutex cleanup. 2015-10-01 11:44:09 -07:00
9405150b11 Restore group announcement on Peer::receive() but centralize packet composition in one place. 2015-10-01 11:37:02 -07:00
a3db7d0728 Refactor: move network COMs out of Network and into Peer in prep for tightening up multicast lookup and other things. 2015-10-01 11:11:52 -07:00
11ff96ba1d Consider IPv6 paths reliable (no constant keepalives needed) 2015-09-30 15:20:08 -07:00
0d0039674f Add new verb names, and fix some Mac compiler flags. 2015-09-30 14:48:07 -07:00
789046ca57 Speed up Salsa20 just a bit. 2015-09-30 14:35:05 -07:00
1a4f16e0ed More work on circuit testing... 2015-09-30 13:59:05 -07:00
4983fd3776 Recompiled ZTO binary with fix + moves index.html to var/www 2015-09-29 14:32:07 -04:00
cc10d4f310 Speed up multicast group checking/registration. 2015-09-29 10:31:41 -07:00
167a5039d0 . 2015-09-28 23:40:20 -07:00
4b82171a95 . 2015-09-28 22:16:58 -07:00
b4624237af . 2015-09-28 22:14:32 -07:00
49f93a57bf . 2015-09-28 17:07:46 -07:00
ea71738c72 Entry point stuff... 2015-09-28 16:36:20 -07:00
49956ed63d Updated intercept library for Earth 2015-09-28 19:31:32 -04:00
280fcc3771 add cr after identity in demo script. 2015-09-28 16:15:17 -07:00
3a6346f560 More entry point work, and change network to 8056c2e21c000001 for demo. 2015-09-28 16:14:32 -07:00
980d145f48 Entry point changes to wait for ZT startup, print banners, log output debug messages and trace to files. 2015-09-28 15:31:47 -07:00
a7bd1eaa40 Never assign v4 IPs ending in .255 even within range. 2015-09-28 15:28:30 -07:00
1773dca9dc Optimized Dockerfile arrangement 2015-09-28 17:59:54 -04:00
8e3e830e89 Working intercepted Apache 2015-09-28 17:47:38 -04:00
77b385fb12 Re-added Apache to Dockerfile 2015-09-28 17:30:18 -04:00
0b34d8e75e New Dockerfile 2015-09-28 16:56:14 -04:00
0c3dd2be96 Fixed apache script 2015-09-27 21:48:38 -04:00
444481f6d9 Modified Dockerfile 2015-09-27 21:26:57 -04:00
299ec12b39 Added docker-test folder 2015-09-27 21:16:02 -04:00
b21c5d8e51 Added dockerfile 2015-09-27 20:51:32 -04:00
2d0adb562d Specify circuit test messages. 2015-09-27 11:37:39 -07:00
3bc9530db7 Object-Model refactor: Removed notion of Client 2015-09-27 06:08:39 -04:00
75a191a856 don't create an InetSocketAddress on local address if it's equal to ZT_SOCKADDR_NULL 2015-09-26 14:10:45 -07:00
7c3be2b5c1 fix function signature in lookup for onSendPacketRequested function 2015-09-26 14:10:16 -07:00
0b9e5928d3 update PacketSender interface 2015-09-26 13:53:38 -07:00
e8cdff3eaf Merge branch 'adamierymenko-dev' into android-jni-dev
also update for changed function calls that now accept a local address

# Conflicts:
#	include/ZeroTierOne.h
#	java/CMakeLists.txt
#	java/jni/Android.mk
#	java/jni/ZT1_jnicache.cpp
#	java/jni/ZT1_jnilookup.h
#	java/jni/ZT1_jniutils.cpp
#	java/jni/com_zerotierone_sdk_Node.cpp
2015-09-26 13:47:55 -07:00
fe78eb77d4 Fixed another closure bug 2015-09-24 19:22:56 -04:00
f69454ec98 (1) Make ZT_ naming convention consistent (get rid of ZT1_), (2) Make local interface a full sockaddr_storage instead of an int identifier, which turns out to be better for multi-homing and other uses. 2015-09-24 16:21:36 -07:00
8a8264bc39 Fixed their_fd closure bug 2015-09-24 17:33:25 -04:00
1119f64a77 Fixed connection closure issue 2015-09-24 17:10:30 -04:00
c25ceaf06b Fixed recursive lock problem in closeConnection 2015-09-24 16:15:14 -04:00
b263926ea6 thread fixes. 2015-09-24 13:02:10 -07:00
84747b1a14 thread fixes... 2015-09-24 13:01:19 -07:00
9396b8d53c Minor debug changes 2015-09-24 15:56:48 -04:00
37497ec2a8 Minor changes 2015-09-24 15:31:11 -04:00
851e4c667f Minor changes 2015-09-24 15:30:07 -04:00
9feeafd757 Make LWIPStack thread safe. 2015-09-24 12:29:10 -07:00
0027a1e152 Merge branch 'netcon' of http://10.6.6.2/zerotier/zerotierone into netcon 2015-09-24 14:33:49 -04:00
65af5af138 Added debug statements 2015-09-24 14:33:15 -04:00
557d2b3b0d Make LWIPStack clean up properly. 2015-09-24 11:11:16 -07:00
fbde40d1fc Merge branch 'adamierymenko-dev' into netcon 2015-09-24 11:00:22 -07:00
557c0c29b0 minor changes 2015-09-23 19:45:44 -04:00
0e5aac6a11 Prefer IPv6 paths if available. 2015-09-23 16:16:36 -07:00
b242216674 Version bump, preparing for a likely 1.0.6 soon. 2015-09-23 16:10:06 -07:00
423412df98 Pick a random secondary UDP port for uPnP mapped traffic because of broken routers. 2015-09-23 15:16:20 -07:00
c85dd262ed moved lib files to ext 2015-09-23 18:03:21 -04:00
02d5a31822 added lwip unix port lib files 2015-09-23 17:55:15 -04:00
7821d1cbdd . 2015-09-23 14:44:13 -07:00
80dc7fb675 Pick random port on -p0 2015-09-23 14:38:16 -07:00
a3ed5277ef Make sure ZT_NO_TYPE_PUNNING also obeyed here. 2015-09-23 14:09:27 -07:00
2a527ea82e Fix for timer jitter problem. 2015-09-23 14:01:41 -07:00
367ffde00c Plumb through localInterfaceId to track local interfaces corresponding with remote addresses. 2015-09-23 13:49:56 -07:00
bbdb8eb0de more commenting and cleaning 2015-09-23 15:23:26 -04:00
b6a6346405 commenting and cleanup 2015-09-23 14:23:36 -04:00
4464fa5d39 Eliminate another warning. 2015-09-23 10:29:05 -07:00
86996d4315 Eliminate compiler warning. 2015-09-23 10:27:53 -07:00
07cef1bdb8 misc cleanup 2015-09-22 19:53:36 -04:00
69f006f641 . 2015-09-22 16:02:02 -07:00
d656e87395 Send a random small payload for NAT keepalives, since zero byte packets seem to fail to keep associations alive behind some NATs. 2015-09-22 15:58:00 -07:00
3cb8070980 it's alive! -- hooked up new fd-handling code 2015-09-22 18:44:54 -04:00
ff7ac0487b . 2015-09-22 15:16:38 -07:00
19c0923a86 Merge branch 'adamierymenko-dev' into netcon 2015-09-22 15:11:51 -07:00
6ce64c2557 Phy<> loses socketpair, gains raw FD monitoring. 2015-09-22 15:11:32 -07:00
3ed5edb295 fixed fd-transfer logic bug, needs new write-queue logic 2015-09-22 17:43:20 -04:00
c3dbae8d5e more debugs 2015-09-22 13:35:37 -04:00
b2494b53e6 adjusted output size for packets 2015-09-22 13:27:27 -04:00
f091a074d4 output lengths 2015-09-22 13:25:24 -04:00
f80d65286c more debug statements 2015-09-22 13:21:33 -04:00
0271e3d3ac . 2015-09-22 10:00:00 -07:00
00cb8dbda8 timer change 2015-09-22 12:48:53 -04:00
025069de7e timer change 2015-09-21 20:51:35 -04:00
86673bd6d6 fixed minor bugs and added debug outputs 2015-09-21 19:39:26 -04:00
ddf3d1f949 Controller side support for IPv6 assignment. 2015-09-18 13:35:00 -07:00
3664966340 Generate local IPv6 addresses from network IDs and addresses. 2015-09-17 21:30:32 -07:00
cb6864f04a updated nc_accept and lwip.so 2015-09-15 20:32:00 -04:00
701e1654a1 moved IP/netif allocation code 2015-09-15 19:06:16 -04:00
732de5bf7f some cleanup 2015-09-15 18:47:40 -04:00
11731af45a it's alive! 2015-09-15 18:27:52 -04:00
735ae9b369 debug changes 2015-09-15 15:41:57 -04:00
cb277f52e8 Merge branch 'netcon' of http://10.6.6.2/zerotier/zerotierone into netcon 2015-09-15 14:16:28 -04:00
8ea83c9548 netif code hooked up 2015-09-15 14:15:59 -04:00
610ab0750c Drop Sqlite-based Log table for now and switch to an in-memory log for recent activity. Log table gets too big on busy nodes. Should probably support push of events to some kind of event system later. 2015-09-15 10:59:23 -07:00
d06499a50c Merge branch 'adamierymenko-dev' of http://git.int.zerotier.com/zerotier/zerotierone into netcon 2015-09-14 12:00:03 -07:00
ef316ced3b Fix JSON. 2015-09-14 11:59:43 -07:00
0617b17534 Merge branch 'netcon' of http://git.int.zerotier.com/zerotier/zerotierone into netcon 2015-09-14 11:36:01 -07:00
f7d3e262a9 ifdef default assignments 2015-09-11 17:16:38 -07:00
8189b2ba91 retval fix 2015-09-11 19:29:35 -04:00
e73868bc5a various segfault fixes 2015-09-11 19:02:44 -04:00
6f0bc1f676 added debugs, fixed linux makefile 2015-09-11 18:22:41 -04:00
88898c68d7 Merge branch 'adamierymenko-dev' of http://git.int.zerotier.com/zerotier/zerotierone into netcon 2015-09-11 15:02:38 -07:00
cd005341c5 Extra statement to clean up Members -- cascade did not seem to work, possibly due to dual key. 2015-09-11 15:02:26 -07:00
bc666d0ab7 added pbuf alloc block 2015-09-11 15:26:39 -04:00
933b47389d Add Arp to netcon build. 2015-09-11 12:19:48 -07:00
a8d7a31327 Integrate arp into NetconEthernetTap. 2015-09-11 12:12:45 -07:00
c2226cf0df added TRACEs 2015-09-11 14:47:16 -04:00
5f6eb2ce98 Merge branch 'adamierymenko-dev' into netcon 2015-09-11 11:46:44 -07:00
c1a53a2653 ARP cache and responder agent code for use in netcon and iOS. 2015-09-11 11:45:04 -07:00
776f93e7be closeConnection / closeClient changes 2015-09-11 14:12:27 -04:00
5a5a513b18 small method changes 2015-09-11 14:00:42 -04:00
cc4a2bb0c3 filled out hendlers 2015-09-10 20:34:48 -04:00
e4dc46741f compiles, technically 2015-09-10 20:22:35 -04:00
20beafedc5 refactor almost complete 2015-09-10 20:02:13 -04:00
8d82ac5cc8 Merge branch 'adamierymenko-dev' into netcon 2015-09-10 15:56:15 -07:00
9dc2ef5549 Rename some stuff in Phy since it can be used with any stream socket. 2015-09-10 15:55:48 -07:00
cd3d77987c . 2015-09-10 15:52:24 -07:00
b11d429bc0 refactor in progress 2015-09-10 18:48:45 -04:00
e391bc004b refactor in progress 2015-09-10 18:19:43 -04:00
a35fa7ac93 Add expansion of netconf in _test field. 2015-09-10 15:14:10 -07:00
bebe3d7cfa Fix deadlock in test mode. 2015-09-10 14:47:04 -07:00
c1f1530d54 refactor in progress 2015-09-10 17:44:01 -04:00
1f7a41cff8 Fix to allowing identity to be populated if not present. 2015-09-10 14:37:34 -07:00
f4d3c995bc refactor in progress 2015-09-10 16:52:18 -04:00
637da383f5 Remove unnecessary accessors. 2015-09-10 13:22:44 -07:00
389ea272a0 Merge adamierymenko-dev 2015-09-10 13:20:00 -07:00
9a723be263 Add socketpair support to Phy. 2015-09-10 13:18:57 -07:00
3802d37d29 started refactor 2015-09-10 15:46:37 -04:00
750352836f initial commit 2015-09-10 13:56:01 -04:00
a43c3fbf2e Merge branch 'adamierymenko-dev' into netcon 2015-09-09 09:54:39 -07:00
4fbcad2468 Allow identity to be populated for newly inserted Member objects to permit transfer from old network controller and testing. 2015-09-08 13:02:42 -07:00
0d386f1c31 Add a bit of useful testing instrumentation to SqliteNetworkController. 2015-09-08 11:35:55 -07:00
85b90f122a Final std::map<> from Switch, and add some smallish default values for hash size. 2015-09-04 15:35:43 -07:00
3dba016a93 Almost done... very few std::map<>s remaining in any spot that matters. 2015-09-04 15:21:22 -07:00
db0369e9b8 Remove way-overkill multimap from Switch. 2015-09-04 14:56:39 -07:00
0ab3e49be9 Starting in on Switch... kill map in defrag queue, which will probably improve performance pretty decently under high load with lots of peers. 2015-09-04 14:44:22 -07:00
f116c4b9c0 ... and another ... 2015-09-04 14:24:31 -07:00
307e44f7c8 Two for one! (std::map removal) 2015-09-04 14:14:32 -07:00
d1341578d8 ... and another one! 2015-09-04 13:53:48 -07:00
7b8ce16057 Another std::map<> dies. 2015-09-04 13:42:19 -07:00
3a959a7763 Swap out std::map<> for Hashtable<> for main peer database in Topology. (ongoing std::map-ectomy) 2015-09-04 12:14:21 -07:00
cfd101c9b8 Add entries() to go with keys() for future use. 2015-09-04 11:50:12 -07:00
ca6ec120a9 Merge branch 'netcon' of http://git.int.zerotier.com/zerotier/zerotierone into netcon 2015-09-03 18:45:07 -07:00
88ba39b162 Merge branch 'adamierymenko-dev' into netcon 2015-09-03 18:44:57 -07:00
da9a720c3f Hash table bug fix, and add copy constructor and assignment operator for principle of least surprise. 2015-09-03 17:33:06 -07:00
10707c3673 build fix 2015-09-03 16:44:04 -07:00
b9d4b42f93 A few more fixes, ready to integrate main payload. 2015-09-03 16:05:18 -07:00
bf4cab5f2f Netcon build fixes. 2015-09-02 16:31:13 -07:00
1f4c667646 Netcon mode for Linux (in this branch, will make conditional later) 2015-09-02 16:15:22 -07:00
dfb08ec753 More netcon stuff, and Phy build fix. 2015-09-02 15:51:28 -07:00
4626175d11 Stub of NetconEthernetTap 2015-09-02 15:17:38 -07:00
4838cbc350 Unix domain sockets in Phy<> 2015-09-02 14:32:01 -07:00
53d98343b7 Merge branch 'master' into android-jni 2015-08-31 19:53:39 -07:00
73bedfcc01 ifdef default assignments 2015-08-29 17:54:30 -07:00
d5b48c90ed added a 512x512 app icon (for Play store) 2015-08-27 19:51:27 -07:00
ebfbb7f452 Merge branch 'master' of http://git.int.zerotier.com/ZeroTier/ZeroTierOne into android-jni 2015-08-27 19:31:46 -07:00
b11ffc9635 Integrate Hashtable into Multicaster, where @mwarning found heaviest std::map() overhead. 2015-08-27 16:17:21 -07:00
3947807b1f A simple and fast Hashtable, tested but not yet integrated with anything. 2015-08-27 15:36:13 -07:00
5db538d85e VERSION 1.0.5: Windows and Linux (upgrade) bug fixes
Version 1.0.5 is a very minor release. It includes a new build of the Windows
device driver that supports Windows Vista and 2008 Server, and a fix to prevent
an issue that could occur when updating Linux installations from old pre-1.0.3
versions to 1.0.3 or 1.0.4.

It also includes a few very minor fixes and improvements to the controller code,
which doesn't affect most users.

This second commit just bumps version.h. :)
2015-08-25 09:55:14 -07:00
a9176d7b62 VERSION 1.0.5: Windows and Linux (upgrade) bug fixes
Version 1.0.5 is a very minor release. It includes a new build of the Windows
device driver that supports Windows Vista and 2008 Server, and a fix to prevent
an issue that could occur when updating Linux installations from old pre-1.0.3
versions to 1.0.3 or 1.0.4.

It also includes a few very minor fixes and improvements to the controller code,
which doesn't affect most users.
2015-08-25 09:47:37 -07:00
b4487cefc9 Document rules requirement in controller. 2015-08-25 09:46:59 -07:00
867258de8b Document clock convenience field. 2015-08-25 09:44:21 -07:00
5fcef91278 Ignore old root-topology if present -- fix for upgrading on Linux and possibly elsewhere. 2015-08-25 09:42:37 -07:00
2aa1b5d9b7 Add clock helper field to both member and network to permit time duration calculation easily. 2015-08-24 12:44:07 -07:00
9a5be0a092 typo 2015-08-24 11:24:33 -07:00
4da794b389 Add authorizedMemberCount to controller network config records. 2015-08-19 11:43:56 -07:00
0a5429cab0 Lookup of member must be a left outer join in case the member is being manually inserted before we see the node. 2015-08-17 21:08:02 +00:00
7d676ad16a Merge branch 'adamierymenko-dev' into android-jni 2015-08-13 19:36:30 -07:00
b75bdedaee Manually set DeviceInstanceID since this registry key is missing on Windows Vista and Server 2008. 2015-08-13 15:52:54 -07:00
085734aaba Windows driver (NDIS6) rebuild using earlier DDK revision to allow driver to load in Windows 2008 Server and Windows Vista. Still issues with those platforms, but driver loads -- and shouldn't hurt newer versions (will test). 2015-08-13 15:18:48 -07:00
0fd6808e21 Merge branch 'master' into android-jni 2015-08-01 11:52:47 -07:00
c9b4028cd3 Merge branch 'adamierymenko-dev' into android-jni 2015-07-29 20:13:32 -07:00
508d31513a Merge branch 'adamierymenko-dev' into android-jni 2015-07-28 19:18:33 -07:00
bc0954381c Merge branch 'adamierymenko-dev' into android-jni 2015-07-21 17:53:39 -07:00
d05e8a9772 Merge branch 'adamierymenko-dev' into android-jni 2015-07-20 19:51:58 -07:00
1e8ead441c Merge branch 'adamierymenko-dev' into android-jni 2015-07-16 18:09:57 -07:00
e45475c5b5 fixed a misspelling 2015-07-09 20:26:23 -07:00
a408e5f685 set ZT_NO_TYPE_PUNNING and -O3 for Android builds 2015-07-08 18:00:13 -07:00
f67ddb579d Merge branch 'adamierymenko-dev' into android-jni 2015-07-08 17:30:22 -07:00
1ad2cfeedf Merge branch 'adamierymenko-dev' into android-jni 2015-07-07 19:24:02 -07:00
6d398beefd Merge branch 'adamierymenko-dev' into android-jni 2015-07-03 18:15:56 -07:00
ab34884e3e Set -O0
anything above that currently goes kaboom on ARM platforms
2015-07-03 18:14:50 -07:00
0b7cd2f40a change some build settings. add a lock 2015-07-01 20:26:14 -07:00
2a2e3b80b3 Merge branch 'adamierymenko-dev' into android-jni 2015-07-01 18:13:59 -07:00
f803dd5ff4 ... 2015-07-01 18:13:39 -07:00
d853dbf2d8 Merge branch 'adamierymenko-dev' into android-jni 2015-06-30 19:23:23 -07:00
aee8e95d49 logging 2015-06-30 19:21:46 -07:00
c9919cc5ba reflect changes to ZT1_PeerRole in JNI 2015-06-26 18:26:57 -07:00
9c26d10ea6 Merge branch 'adamierymenko-dev' into android-jni 2015-06-26 17:44:09 -07:00
bfb152f53f configure the NDK to build all supported ABIs and package them up in the jar 2015-06-24 20:31:22 -07:00
759d71037e added Comparable interface to VirtualNetworkConfig so we can sort arrays containing it. 2015-06-23 23:03:02 -07:00
adf89901c4 dont consider multicast groups in VirtualNetworkConfig.equals() 2015-06-19 19:00:06 -07:00
dfdd46db80 Merge branch 'adamierymenko-dev' into android-jni 2015-06-17 18:42:23 -07:00
c59c74ddda Merge branch 'adamierymenko-dev' into android-jni 2015-06-13 14:39:45 -07:00
abbcb0a12c Modified ant build script so that it can be integrated with Android Studio's build system 2015-06-13 14:38:04 -07:00
472206dfb2 Rename JniCache to JniLookup
Removed caching capabilities as the cached methods, fields, and objects appears to be broken on Android
2015-06-10 20:16:13 -07:00
7e84f5a7db killing whitespace 2015-06-09 23:24:54 -07:00
6889fcfc28 Looks like it was the JNI cash causing the crash.
Forcing it to look up classes and methods instead of caching them stopped the crashes in the GC.  Will investigate more later.
2015-06-09 23:24:47 -07:00
4dc0ff8f13 Replace calls to Get<Type>ArrayElements with GetPrimitiveArrayCritical.
This puts code accessing the data in a critical section so that the GC cannot run while JNI has access to the array.  This helps with stability somewhat, but I'm still getting some crashes in the GC
2015-06-09 23:12:44 -07:00
3013d90f57 ignore windows binary output 2015-06-09 22:38:31 -07:00
60da0e6cae Merge branch 'adamierymenko-dev' into android-jni 2015-06-09 19:38:47 -07:00
ced040c503 Logging and adding .equals() methods to MulticastGroup and VirtualNetworkCofnig 2015-06-09 19:38:05 -07:00
7cc64c5cb6 Might help to set the enabled field on a VirtualNetworkConfig object :) 2015-06-03 21:29:19 -07:00
b84dba3ecb more logging 2015-06-03 21:29:07 -07:00
8fb9df9751 delete dead test code 2015-06-03 18:35:38 -07:00
881 changed files with 140107 additions and 57425 deletions

75
.clang-format Normal file
View File

@ -0,0 +1,75 @@
---
BasedOnStyle: LLVM
BreakBeforeBraces: Stroustrup
IndentWidth: 4
TabWidth: 4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AlwaysBreakAfterReturnType: None
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'true'
IndentPPDirectives: None
IndentWrappedFunctionNames: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: None
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterLogicalNot: 'true'
SpaceAfterTemplateKeyword: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '3'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'true'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
UseTab: 'Never'
---
Language: Cpp
Standard: Cpp03
ColumnLimit: '240'
---
Language: ObjC
ColumnLimit: '240'
---
Language: Java
ColumnLimit: '240'
---
Language: CSharp
ColumnLimit: '240'
...

6
.clangd Normal file
View File

@ -0,0 +1,6 @@
CompileFlags:
Add:
- "-std=c++17"
- "-I../ext"
- "-I../ext/prometheus-cpp-lite-1.0/core/include"
- "-I../ext/prometheus-cpp-lite-1.0/simpleapi/include"

46
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,46 @@
---
name: Bug report
about: Create a report to help us improve
---
**Alternative, faster ways to get help**
If you have just started using ZeroTier, here are some places to get help:
- my.zerotier.com has a _Community_ tab. It's a live chat with other users and the developers.
- [ZeroTier Knowledge Base](https://zerotier.atlassian.net/wiki/spaces/SD/overview)
- www.zerotier.com has a Contact Us button
- email contact@zerotier.com
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a Network '...'
2. Install zerotier-one '....'
3. '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots or console output to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. Mac, Linux, Windows, BSD]
- OS/Distribution Version
- ZeroTier Version [e.g. 1.2.4]
- Hardware [e.g. raspberry pi 3]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Version [e.g. 1.2.4]
**Additional context**
Add any other context about the problem here.
- ZeroTier Network Configuration
- Router Config
- Firewall Config (try turning the firewall off)
- General Network Environment: [ e.g Home, University Campus, Corporate LAN ]

View File

@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

106
.gitignore vendored Executable file → Normal file
View File

@ -1,12 +1,56 @@
# Main binaries created in *nix builds
/zerotier-*
# OS-created garbage files from various platforms
build/
/version.h
.DS_Store
.Trashes
*.swp
._*
*~
*~.nib
.Apple*
Thumbs.db
@eaDir
DerivedData/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
*.xccheckout
xcuserdata/
.vscode
__pycache__
attic/world/*.c25519
attic/world/mkworld
*.log
*.opensdf
*.user
*.cache
*.obj
*.tlog
*.pid
*.pkg
*.o
*.o-*
*.core
*.deb
*.rpm
*.autosave
*.tmp
.depend
node_modules
debian/files
debian/zerotier-one
debian/zerotier-one*.debhelper
debian/*.log
debian/zerotier-one.substvars
root/identity.*
root/config.*
/ext/installfiles/windows/chocolatey/zerotier-one/*.nupkg
/go/zerotier
# Windows build droppings
/windows/ZeroTierOne.sdf
/windows/ZeroTierOne.v11.suo
/windows/x64
@ -21,48 +65,21 @@ Thumbs.db
/windows/Release
/windows/WebUIWrapper/bin
/windows/WebUIWrapper/obj
/windows/lib
/ext/installfiles/windows/ZeroTier One-SetupFiles
/ext/installfiles/windows/Prerequisites
/ext/installfiles/windows/*-cache
/ZeroTier One.msi
/*.msi
/windows/.vs
*.vcxproj.backup
/windows/TapDriver6/Win7Debug
/windows/TapDriver6/win7Release
/windows/*.db
/windows/*.opendb
enc_temp_folder
/windows/copyutil/bin
/windows/copyutil/obj
# *nix/Mac build droppings
/build-*
/ZeroTierOneInstaller-*
# Miscellaneous file types that we don't want to check in
*.log
*.opensdf
*.user
*.cache
*.obj
*.tlog
*.pid
*.pkg
*.o
*.core
*.deb
*.rpm
*.autosave
*.tmp
# Root topology build files, temporaries, and never check in secrets
/root-topology/bin2c
/root-topology/mktopology
/root-topology/*.secret
/root-topology/test/supernodes
/root-topology/test/test-root-topology
# MacGap wrapper build files
/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/project.xcworkspace/xcuserdata/*
/ext/mac-ui-macgap1-wrapper/src/MacGap.xcodeproj/xcuserdata/*
/ext/mac-ui-macgap1-wrapper/src/build
# Web UI dev temporaries
/ui/.module-cache
node_modules
# Java/Android/JNI build droppings
java/obj/
java/libs/
java/bin/
@ -71,3 +88,6 @@ java/doc/
java/build_win64/
java/build_win32/
/java/mac32_64/
windows/WinUI/obj/
windows/WinUI/bin/
windows/ZeroTierOne/Debug/

3
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/workspace.xml

9
.idea/ZeroTierOne.iml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

11
.idea/dictionaries/api.xml generated Normal file
View File

@ -0,0 +1,11 @@
<component name="ProjectDictionaryState">
<dictionary name="api">
<words>
<w>apisocket</w>
<w>nwid</w>
<w>secrand</w>
<w>sockaddr</w>
<w>unmarshals</w>
</words>
</dictionary>
</component>

View File

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

6
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ZeroTierOne.iml" filepath="$PROJECT_DIR$/.idea/ZeroTierOne.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

29
.idea/watcherTasks.xml generated Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<TaskOptions isEnabled="true">
<option name="arguments" value="fmt $FilePath$" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="go" />
<option name="immediateSync" value="false" />
<option name="name" value="go fmt" />
<option name="output" value="$FilePath$" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="$GoExecPath$" />
<option name="runOnExternalChanges" value="false" />
<option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="true" />
<option name="workingDir" value="$ProjectFileDir$" />
<envs>
<env name="GOROOT" value="$GOROOT$" />
<env name="GOPATH" value="$GOPATH$" />
<env name="PATH" value="$GoBinDirs$" />
</envs>
</TaskOptions>
</component>
</project>

View File

@ -1,44 +1,63 @@
## Authors
# Authors and Third Party Code Licensing Information
* ZeroTier protocol design and core network virtualization engine, ZeroTier One service, React web UI, packaging for most platforms, kitchen sink...<br>
## 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
## Contributors
* ZeroTier SDK (formerly known as Network Containers)<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
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
https://github.com/zerotier/ZeroTierOne/graphs/contributors/
## Third Party Code
## Third-Party Code
* LZ4 compression algorithm by Yann Collet (BSD license)<br>
http://code.google.com/p/lz4/
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.
* http-parser by many authors (MIT license)<br>
https://github.com/joyent/http-parser
* LZ4 compression algorithm by Yann Collet
* json-parser by James McLaughlin (BSD license)<br>
https://github.com/udp/json-parser
* Files: node/Packet.cpp (bundled within anonymous namespace)
* Home page: http://code.google.com/p/lz4/
* License grant: BSD 2-clause
* TunTapOSX by Mattias Nissler (BSD license)<br>
http://tuntaposx.sourceforge.net
* C++11 json (nlohmann/json) by Niels Lohmann
* tap-windows and tap-windows6 by the OpenVPN project (GPL)<br>
https://github.com/OpenVPN/tap-windows<br>
https://github.com/OpenVPN/tap-windows6
* Files: ext/json/*
* Home page: https://github.com/nlohmann/json
* License grant: MIT
* Salsa20 stream cipher, Curve25519 elliptic curve cipher, Ed25519
digital signature algorithm, and Poly1305 MAC algorithm, all by
Daniel J. Bernstein (public domain)<br>
http://cr.yp.to/
* tap-windows6 by the OpenVPN project
* MiniUPNPC by Thomas Bernard [BSD]
http://miniupnp.free.fr
* Files: windows/TapDriver6/*
* Home page: https://github.com/OpenVPN/tap-windows6/
* License grant: GNU GPL v2
* ZeroTier Modifications: change name of driver to ZeroTier, add ioctl() to get L2 multicast memberships (source is in ext/ and modifications inherit GPL)
* 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 grant: public domain
* ZeroTier Modifications: slight cryptographically-irrelevant modifications for inclusion into ZeroTier core
* cpp-httplib by yhirose
* Files: ext/cpp-httplib/*
* Home page: https://github.com/yhirose/cpp-httplib
* License grant: MIT

199
CMakeLists.txt Normal file
View File

@ -0,0 +1,199 @@
cmake_minimum_required (VERSION 3.10)
if(${CMAKE_VERSION} VERSION_LESS 3.15)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.15)
endif()
if(WIN32)
# If building on Windows, set minimum target to Windows 7
set(CMAKE_SYSTEM_VERSION "7" CACHE STRING INTERNAL FORCE)
endif(WIN32)
set(ZEROTIER_ONE_VERSION_MAJOR 2 CACHE INTERNAL "")
set(ZEROTIER_ONE_VERSION_MINOR 0 CACHE INTERNAL "")
set(ZEROTIER_ONE_VERSION_REVISION 0 CACHE INTERNAL "")
set(ZEROTIER_ONE_VERSION_BUILD 0 CACHE INTERNAL "")
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
option(BUILD_CENTRAL_CONTROLLER "Build ZeroTier Central Controller" OFF)
option(ZT_TRACE "Trace Messages" OFF)
option(ZT_DEBUG_TRACE "Debug Trace Messages" OFF)
if (BUILD_CENTRAL_CONTROLLER)
find_package(PostgreSQL REQUIRED)
set(ENABLE_SSL_SUPPORT OFF)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_TOOLS OFF)
set(BUILD_TESTS OFF)
set(BUILD_API_DOCS OFF)
add_subdirectory("ext/librabbitmq")
endif(BUILD_CENTRAL_CONTROLLER)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X Deployment Version")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DZT_TRACE)
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")
project(zerotier
DESCRIPTION "ZeroTier Network Hypervisor"
LANGUAGES CXX C)
if(WIN32)
add_definitions(-DNOMINMAX)
else(WIN32)
if(APPLE)
message("Setting macOS Compiler Flags ${CMAKE_BUILD_TYPE}")
add_compile_options(
-Wall
-Wno-deprecated
-mmacosx-version-min=10.9
$<$<CONFIG:Debug>:-g>
$<$<CONFIG:DEBUG>:-O0>
$<$<CONFIG:RELEASE>:-Ofast>
$<$<CONFIG:RELEASE>:-fPIE>
$<$<CONFIG:RELEASE>:-flto>
$<$<CONFIG:RELWITHDEBINFO>:-Ofast>
$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
$<$<CONFIG:RELWITHDEBINFO>:-g>
)
add_link_options(
-mmacosx-version-min=10.9
$<$<CONFIG:RELEASE>:-flto>
)
elseif (
CMAKE_SYSTEM_NAME MATCHES "Linux" OR
CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR
CMAKE_SYSTEM_NAME MATCHES "OpenBSD" OR
CMAKE_SYSTEM_NAME MATCHES "NetBSD"
)
message("Setting Linux/BSD Compiler Flags (${CMAKE_BUILD_TYPE})")
add_compile_options(
-Wall
-Wno-deprecated
$<$<CONFIG:Debug>:-g>
$<$<CONFIG:DEBUG>:-O0>
$<$<CONFIG:RELEASE>:-O3>
$<$<CONFIG:RELEASE>:-fPIE>
$<$<CONFIG:RELWITHDEBINFO>:-O3>
$<$<CONFIG:RELWITHDEBINFO>:-fPIE>
$<$<CONFIG:RELWITHDEBINFO>:-g>
)
endif(APPLE)
endif(WIN32)
if (
CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "amd64" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "i386" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "i486" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "i586" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "i686"
)
message("Adding SSE and AES-NI flags for processor ${CMAKE_SYSTEM_PROCESSOR}")
add_compile_options(
-maes
-mmmx
-mrdrnd
-mpclmul
-msse
-msse2
-msse3
-msse4.1
)
endif()
if(ZT_TRACE)
add_definitions(-DZT_TRACE)
endif()
if(ZT_DEBUG_TRACE)
add_definitions(-DZT_DEBUG_TRACE)
endif()
add_subdirectory(node)
add_subdirectory(controller)
add_subdirectory(osdep)
add_subdirectory(go/native)
#if(WIN32)
# add_subdirectory("windows/WinUI")
# add_subdirectory("windows/copyutil")
# add_definitions(-DNOMINMAX)
#endif(WIN32)
set(
zt_osdep
zt_core
zt_controller
zt_go_native
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version.h
)
#set(src
# one.cpp
# "ext/http-parser/http_parser.c"
#)
#set(headers
# "ext/http-parser/http_parser.h"
#)
if(WIN32)
set(libs ${libs} wsock32 ws2_32 rpcrt4 iphlpapi)
else(WIN32)
set(libs ${libs} pthread)
endif(WIN32)
#if(WIN32)
# set(libs ${libs} wsock32 ws2_32 rpcrt4 iphlpapi)
# set(src
# ${src}
# "windows/ZeroTierOne/ServiceBase.cpp"
# "windows/ZeroTierOne/ServiceInstaller.cpp"
# "windows/ZeroTierOne/ZeroTierOneService.cpp"
# "windows/ZeroTierOne/ZeroTierOne.rc"
# )
# set(headers
# ${headers}
# "windows/ZeroTierOne/ServiceBase.h"
# "windows/ZeroTierOne/ServiceInstaller.h"
# "windows/ZeroTierOne/ZeroTierOneService.h"
# )
#else(WIN32)
# set(libs ${libs} pthread resolv)
#endif(WIN32)
#if(BUILD_CENTRAL_CONTROLLER)
# set(libs ${libs} rabbitmq-static ${PostgreSQL_LIBRARIES})
#endif(BUILD_CENTRAL_CONTROLLER)
#add_executable(${PROJECT_NAME} ${src} ${headers})
#target_link_libraries(${PROJECT_NAME} ${libs})
#target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR})
add_executable(zerotier-selftest selftest.cpp)
target_link_libraries(zerotier-selftest ${libs} zt_core zt_osdep)
target_compile_features(zerotier-selftest PUBLIC cxx_std_11)

12
COPYING Normal file
View File

@ -0,0 +1,12 @@
ZeroTier One, an endpoint server for the ZeroTier virtual network layer.
Copyright © 20112019 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 :

90
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,90 @@
#!/usr/bin/env groovy
node('master') {
checkout scm
def changelog = getChangeLog currentBuild
mattermostSend "Building ${env.JOB_NAME} #${env.BUILD_NUMBER} \n Change Log: \n ${changelog}"
}
parallel 'centos7': {
node('centos7') {
try {
checkout scm
stage('Build Centos 7') {
sh '''. /opt/rh/devtoolset-8/enable
rm -rf build/
mkdir build && cd build
cmake ..
make -j4
./zerotier-selftest
'''
}
}
catch (err) {
currentBuild.result = "FAILURE"
mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on Centos 7 (<${env.BUILD_URL}|Open>)"
throw err
}
}
// }, 'android-ndk': {
// node('android-ndk') {
// try {
// checkout scm
// stage('Build Android NDK') {
// sh "/android/android-ndk-r15b/ndk-build -C $WORKSPACE/java ZT1=${WORKSPACE}"
// }
// }
// catch (err) {
// currentBuild.result = "FAILURE"
// mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on Android NDK (<${env.BUILD_URL}|Open>)"
// throw err
// }
// }
// }, 'macOS': {
// node('macOS') {
// try {
// checkout scm
// stage('Build macOS') {
// sh 'make -f make-mac.mk'
// }
// stage('Build macOS UI') {
// sh 'cd macui && xcodebuild -target "ZeroTier One" -configuration Debug'
// }
// }
// catch (err) {
// currentBuild.result = "FAILURE"
// mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on macOS (<${env.BUILD_URL}|Open>)"
// throw err
// }
// }
// }, 'windows': {
// node('windows') {
// try {
// checkout scm
// stage('Build Windows') {
// bat '''CALL "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\vcvarsall.bat" amd64
// git clean -dfx
// msbuild windows\\ZeroTierOne.sln
// '''
// }
// }
// catch (err) {
// currentBuild.result = "FAILURE"
// mattermostSend color: '#ff0000', message: "${env.JOB_NAME} broken on Windows (<${env.BUILD_URL}|Open>)"
// throw err
// }
// }
}
mattermostSend color: "#00ff00", message: "${env.JOB_NAME} #${env.BUILD_NUMBER} Complete (<${env.BUILD_URL}|Show More...>)"

View File

@ -1,13 +1,149 @@
ZeroTier One is licensed under the terms of the GNU General Public License
version 3, which are available here:
-----------------------------------------------------------------------------
http://gplv3.fsf.org/
Business Source License 1.1
Modification and redistribution of ZeroTier One is permitted in source form.
Binary distribution is permitted provided all copyright notices remain
intact and any modifications to the source code are also distributed.
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
"Business Source License" is a trademark of MariaDB Corporation Ab.
ZeroTier One may not be embedded into any closed-source application (e.g. via
linking), nor may closed-source derivatives be created, without a separately
negotiated license from ZeroTier Networks LLC. See the terms of the GPLv3 for
details.
-----------------------------------------------------------------------------
Parameters
Licensor: ZeroTier, Inc.
Licensed Work: ZeroTier Network Virtualization Engine 1.4.4
The Licensed Work is (c)2019 ZeroTier, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided you
do not use it in any of the following ways:
* Sell hosted ZeroTier services as a "SaaS" Product
(1) Operate or sell access to ZeroTier root servers,
network controllers, or authorization key or certificate
generation components of the Licensed Work as a
for-profit service, regardless of whether the use of
these components is sold alone or is bundled with other
services. Note that this does not apply to the use of
ZeroTier behind the scenes to operate a service not
related to ZeroTier network administration.
* Create Non-Open-Source Commercial Derviative Works
(2) Link or directly include the Licensed Work in a
commercial or for-profit application or other product
not distributed under an Open Source Initiative (OSI)
compliant license. See: https://opensource.org/licenses
(3) Remove the name, logo, copyright, or other branding
material from the Licensed Work to create a "rebranded"
or "white labeled" version to distribute as part of
any commercial or for-profit product or service.
* Certain Government Uses
(4) Use or deploy the Licensed Work in a government
setting in support of any active government function
or operation with the exception of the following:
physical or mental health care, family and social
services, social welfare, senior care, child care, and
the care of persons with disabilities.
Change Date: 2023-01-01
Change License: Apache License version 2.0 as published by the Apache
Software Foundation
https://www.apache.org/licenses/
Alternative Licensing
If you would like to use the Licensed Work in any way that conflicts with
the stipulations of the Additional Use Grant, contact ZeroTier, Inc. to
obtain an alternative commercial license.
Visit us on the web at: https://www.zerotier.com/
Notice
The Business Source License (this document, or the "License") is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.
For more information on the use of the Business Source License for ZeroTier
products, please visit our pricing page which contains license details and
and license FAQ: https://zerotier.com/pricing
For more information on the use of the Business Source License generally,
please visit the Adopting and Developing Business Source License FAQ at
https://mariadb.com/bsl-faq-adopting.
-----------------------------------------------------------------------------
Business Source License 1.1
Terms
The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.
Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.
If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.
All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.
You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.
Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.
This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.
-----------------------------------------------------------------------------
MariaDB hereby grants you permission to use this Licenses 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 Licenses 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.

View File

@ -1,18 +1,20 @@
# Common makefile -- loads make rules for each platform
OSTYPE=$(shell uname -s)
BUILDDIR := build
ifeq ($(OSTYPE),Darwin)
include make-mac.mk
endif
.PHONY: all
ifeq ($(OSTYPE),Linux)
include make-linux.mk
endif
all: setup
cd ${BUILDDIR} && $(MAKE) -j$(shell getconf _NPROCESSORS_ONLN)
ifeq ($(OSTYPE),FreeBSD)
include make-freebsd.mk
endif
ifeq ($(OSTYPE),OpenBSD)
include make-freebsd.mk
endif
setup:
mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Release
debug:
mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug && $(MAKE)
clean:
rm -rf ${BUILDDIR}
distclean:
rm -rf ${BUILDDIR}

33
OFFICIAL-RELEASE-STEPS.md Normal file
View File

@ -0,0 +1,33 @@
ZeroTier Official Release Steps
======
This is mostly for ZeroTier internal use, but others who want to do builds might find it helpful.
Note: Many of these steps will require GPG and other signing keys that are kept in cold storage and must be mounted.
# Bumping the Version and Preparing Installers
The version must be incremented in all of the following files:
/version.h
/zerotier-one.spec
/debian/changelog
/ext/installfiles/mac/ZeroTier One.pkgproj
/ext/installfiles/windows/ZeroTier One.aip
/windows/WinUI/AboutView.xaml
The final .AIP file can only be edited on Windows with [Advanced Installer Enterprise](http://www.advancedinstaller.com/). In addition to incrementing the version be sure that a new product code is generated. (The "upgrade code" GUID on the other hand must never change.)
# Building for Supported Platforms
## Macintosh
Mac's easy. Just type:
make official
You will need [Packages](http://s.sudre.free.fr/Software/Packages/about.html) and our release signing key in the keychain.
## Windows
First load the Visual Studio solution and rebuild the UI and ZeroTier One in both x64 and i386 `Release` mode. Then load [Advanced Installer Enterprise](http://www.advancedinstaller.com/), check that the version is correct, and build. The build will fail if any build artifacts are missing, and Windows must have our product singing key (from DigiCert) available to sign the resulting MSI file. The MSI must then be tested on at least a few different CLEAN Windows VMs to ensure that the installer is valid and properly signed.

175
README.md
View File

@ -1,35 +1,66 @@
ZeroTier One
ZeroTier - Global Area Networking
======
ZeroTier is a software defined networking layer for Earth.
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.
It can be used for on-premise network virtualization, as a peer to peer VPN for mobile teams, for hybrid or multi-data-center cloud deployments, or just about anywhere else secure software defined virtual networking is useful.
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.
ZeroTier One is our OS-level client service. It allows Mac, Linux, Windows, FreeBSD, and soon other types of clients to join ZeroTier virtual networks like conventional VPNs or VLANs. It can run on native systems, VMs, or containers (Docker, OpenVZ, etc.).
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.
Visit [ZeroTier's site](https://www.zerotier.com/) for more information. You can also download professionally packaged binary installers/packages for a variety of supported OSes there if you don't want to build ZeroTier One from source.
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."
### Building from Source
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.
For Mac, Linux, and BSD, just type "make" (or "gmake" on BSD). You won't need much installed; here are the requirements for various platforms:
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.
* Mac: Xcode command line tools, and [Packages](http://s.sudre.free.fr/Software/Packages/about.html) if you want to build an OSX .pkg installer ("make mac-dist-pkg"). It should build on OSX 10.7 or newer.
* Linux: gcc/g++ or clang/clang++ (Makefile will use clang by default if available.)
* FreeBSD (and other BSD): C++ compiler (G++ usually) and GNU make (gmake).
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.).
Each supported platform has its own *make-XXX.mk* file that contains the actual make rules for the platform. The right .mk file is included by the main Makefile based on the GNU make *OSTYPE* variable. Take a look at the .mk file for your platform for other targets, debug build rules, etc.
### Getting Started
Windows, of course, is special. We build for Windows with Microsoft Visual Studio 2012 on Windows 7. A solution file is located in the *windows* subfolder. Newer versions of Visual Studio (and Windows) may work but haven't been tested. Older versions almost certainly will not, since they lack things like *stdint.h* and certain STL features. MinGW or other ports of gcc/clang to Windows should also work but haven't been tested. Build steps for Windows are a bit more complicated. For the moment you are on your own there.
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.
Mobile versions are in progress. They don't work yet, and in any case only the glue code will be included in this repository. The full mobile apps are in private repositories on our own git server.
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.
### Supported Platforms
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.
CPU architecture shouldn't matter unless it's smaller than 32-bit or something really bizarre like a "middle-endian" processor. We have reports of ZeroTier One running on arm32, arm64, and MIPS. It builds and runs out of the box on Raspberry Pi, BeagleBone, BananaPi, and other ARM-based developer/hobbyist boards.
### Project Layout
ZeroTier is written in C and C++ (C++03 / ISO/IEC 14882:2003) and uses data structures and algorithms from the C++03 STL. We do not use any C++11 features (yet), since we want to support a few old and embedded platforms that don't have C++11 compilers. You *will* require a compiler and headers new enough to support 64-bit integers (long long) and the *stdint.h* header. The latter could also be faked by adding defines for things like *uint32\_t*, *int64\_t*, etc.
The base path contains the ZeroTier One service main entry point (`one.cpp`), self test code, makefiles, etc.
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.
- `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
@ -45,10 +76,10 @@ The service is controlled via the JSON API, which by default is available at 127
Here's where home folders live (by default) on each OS:
* Linux: /var/lib/zerotier-one
* BSD: /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.)
* **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:
@ -56,116 +87,22 @@ Running ZeroTier One on a Mac is the same, but OSX requires a kernel extension.
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*.
We recommend using our binary packages on Windows, since there are several prerequisites such as a tap driver that must be installed on the system *and* in the home folder.
### Joining A Network
ZeroTier virtual networks are identified by 16-digit hexadecimal network IDs, while devices are identified by 10-digit addresses. To get your address run:
sudo zerotier-cli status
(Use ./zerotier-cli if you're running it right from your build folder.)
You should see something like:
200 info ########## ONLINE #.#.#
That 10-digit hex code is you. It's derived via a one-way proof of work function from your cryptographic public key. Your public key can be found in *identity.public* in ZeroTier's home folder, while *identity.secret* contains your full identity including the secret portion of the key pair.
(The identity files define your device's *identity*. Moving them to another system will move that identity. Be careful when cloning virtual machines that have identities stored on them. If two devices have the same identity, they'll "fight" over it and you won't know which device will receive network packets.)
If you want to do a quick test, you can join [Earth](https://www.zerotier.com/earth.html). It's a global public network that anyone can join. Type:
sudo zerotier-cli join 8056c2e21c000001
Then:
sudo zerotier-cli listnetworks
At first it'll be in *REQUESTING\_CONFIGURATION* state. In a few seconds to a minute you should see something like:
200 listnetworks 8056c2e21c000001 earth.zerotier.net ##:##:##:##:##:## OK PUBLIC zt0 ##.##.##.##/##
Earth will assign you an IP address in the "unofficially available" globally unrouted 28.0.0.0/7 IP block so as to avoid conflicts with local networks. (Your networks can use any IP scheme, or can even leave IP addresses unmanaged.) Once you get an IP, you should be able to ping something:
ping earth.zerotier.net
Go to [http://earth.zerotier.net/](http://earth.zerotier.net/) to see a short little welcome page that will tell you your IP and Ethernet MAC address.
Earth is a public place. If you don't want to stick around run:
sudo zerotier-cli leave 8056c2e21c000001
The network (and associated interface) should be gone.
Networks are created and administrated by network controllers. Most users will want to use our hosted controllers. Visit [our web site](https://www.zerotier.com/) for more information. Later in this README there are brief instructions about building ZeroTier One with network controller support for those who want to try running their own.
Macintosh and Windows installers also install a GUI application.
### Installing
We don't have a "make install" rule quite yet. On Linux you can type:
make installer
This will build a binary that, when run, will install ZeroTier One on most current Linux distributions. We also have RPM and DEB build files in *ext/installfiles/linux* that wrap this installer in packages for RedHat/CentOS and Debian/Ubuntu derived distributions. If *rpmbuild* is present on the system, the RPM will be built. If *dpkg-deb* is present, the DEB package will be built.
On Mac the best way is to install [Packages](http://s.sudre.free.fr/Software/Packages/about.html) and use:
make mac-dist-pkg
This builds a .pkg file that can be installed.
BSD has no installer yet. We're working on it.
Linux/BSD and Mac installations have an *uninstall.sh* file in their ZeroTier home folder that cleanly removes ZeroTier One from the system. Run this with:
sudo /path/to/ZeroTier/home/folder/uninstall.sh
Windows installers are insane. We build our .MSI installers with [Advanced Installer Enterprise](http://www.advancedinstaller.com). The Advanced Installer project file is in *ext/installfiles/windows*. To avoid lasting psychological trauma we recommend leaving Windows installers alone and using the pre-built Windows binaries on our web site.
### Using ZeroTier One in Docker Containers
To run the ZeroTier One service in a Docker container, run it with "--device=/dev/net/tun --cap-add=NET_ADMIN". This will allow ZeroTier One to open a "tap" virtual network port inside the container.
Alternately, you can use Ethernet bridging to bridge the *docker0* device on your system to a ZeroTier virtual network. This allows you to run ZeroTier One on the host and bridge the entire Docker network backplane to a virtual network or other hosts.
We're working on better "official" Docker support. In the meantime there is a [user-contributed project here](https://github.com/davide/docker-zerotier).
### Building with Network Controller Support
**Warning: as of beta version 1.0.3 the new network controller is not heavily tested. We recommend waiting for 1.0.4 to deploy this in production.**
Network controllers are nodes responsible for issuing configurations and certificates to members of ZeroTier virtual networks. Most users won't need to run their own, so this code is by default not included in the ZeroTier One binary.
You can build a network controller on Linux or Mac with:
make ZT_ENABLE_NETWORK_CONTROLLER=1
This will build a version that contains the Sqlite-backed network controller and associated extensions to the JSON local service control API. You will need the development headers for sqlite3 installed. On Mac these ship as part of Xcode, while on Linux they'll be found in packages for the various distributions.
See the JSON API documentation in [service/](service/) for more information about how to control controllers.
### Troubleshooting
### 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 founder 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:
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.
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 you're interested, there's a [technical deep dive about NAT traversal on our blog](https://www.zerotier.com/blog/?p=226). A troubleshooting tool to help you diagnose NAT issues is planned for the future as are uPnP/IGD/NAT-PMP and IPv6 transport.
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.
### License
The ZeroTier source code is open source and is licensed under the GNU GPL v3 (not LGPL). If you'd like to embed it in a closed-source commercial product or appliance, please e-mail [contact@zerotier.com](mailto:contact@zerotier.com) to discuss commercial licensing. Otherwise it can be used for free.
Additional help [can be found in our knowledge base](https://zerotier.atlassian.net/wiki/spaces/SD/overview).

233
RELEASE-NOTES.md Normal file
View File

@ -0,0 +1,233 @@
ZeroTier 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.

BIN
artwork/AppIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
artwork/AppIcon@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
artwork/AppIcon@3x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
artwork/AppIcon_20x20.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

BIN
artwork/AppIcon_29x29.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
artwork/AppIcon_40x40.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
artwork/AppIcon_58x58.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
artwork/AppIcon_60x60.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
artwork/AppIcon_80x80.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
artwork/AppIcon_87x87.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
artwork/AppIcon_90x90.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
artwork/AppIcon_iPad@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -1,153 +0,0 @@
/*
* ZeroTier One - Network Virtualization Everywhere
* Copyright (C) 2011-2015 ZeroTier, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
* ZeroTier may be used and distributed under the terms of the GPLv3, which
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
*
* If you would like to embed ZeroTier into a commercial application or
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
*/
#ifndef ZT_BWACCOUNT_HPP
#define ZT_BWACCOUNT_HPP
#include "Constants.hpp"
#include <algorithm>
#include <stdint.h>
#include <math.h>
#include "Utils.hpp"
#ifdef __WINDOWS__
#define round(x) ((x-floor(x))>0.5 ? ceil(x) : floor(x))
#endif
namespace ZeroTier {
/**
* Bandwidth account used for rate limiting multicast groups
*
* This is used to apply a bank account model to multicast groups. Each
* multicast packet counts against a balance, which accrues at a given
* rate in bytes per second. Debt is possible. These parameters are
* configurable.
*
* A bank account model permits bursting behavior, which correctly models
* how OSes and apps typically use multicast. It's common for things to
* spew lots of multicast messages at once, wait a while, then do it
* again. A consistent bandwidth limit model doesn't fit.
*/
class BandwidthAccount
{
public:
/**
* Create an uninitialized account
*
* init() must be called before this is used.
*/
BandwidthAccount() throw() {}
/**
* Create and initialize
*
* @param preload Initial balance to place in account
* @param maxb Maximum allowed balance (> 0)
* @param acc Rate of accrual in bytes per second
* @param now Current time
*/
BandwidthAccount(uint32_t preload,uint32_t maxb,uint32_t acc,uint64_t now)
throw()
{
init(preload,maxb,acc,now);
}
/**
* Initialize or re-initialize account
*
* @param preload Initial balance to place in account
* @param maxb Maximum allowed balance (> 0)
* @param acc Rate of accrual in bytes per second
* @param now Current time
*/
inline void init(uint32_t preload,uint32_t maxb,uint32_t acc,uint64_t now)
throw()
{
_lastTime = ((double)now / 1000.0);
_balance = preload;
_maxBalance = maxb;
_accrual = acc;
}
/**
* Update and retrieve balance of this account
*
* @param now Current time
* @return New balance updated from current clock
*/
inline uint32_t update(uint64_t now)
throw()
{
double lt = _lastTime;
double nowf = ((double)now / 1000.0);
_lastTime = nowf;
return (_balance = std::min(_maxBalance,(uint32_t)round((double)_balance + ((double)_accrual * (nowf - lt)))));
}
/**
* Update balance and conditionally deduct
*
* If the deduction amount fits, it is deducted after update. Otherwise
* balance is updated and false is returned.
*
* @param amt Amount to deduct
* @param now Current time
* @return True if amount fit within balance and was deducted
*/
inline bool deduct(uint32_t amt,uint64_t now)
throw()
{
if (update(now) >= amt) {
_balance -= amt;
return true;
}
return false;
}
/**
* @return Most recent balance without update
*/
inline uint32_t balance() const
throw()
{
return _balance;
}
private:
double _lastTime;
uint32_t _balance;
uint32_t _maxBalance;
uint32_t _accrual;
};
} // namespace ZeroTier
#endif

461
attic/Binder.hpp Normal file
View File

@ -0,0 +1,461 @@
/*
* Copyright (c)2019 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2023-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
#define ZT_BINDER_HPP
#include "../node/Constants.hpp"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __WINDOWS__
#include <WinSock2.h>
#include <Windows.h>
#include <ShlObj.h>
#include <netioapi.h>
#include <iphlpapi.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <unistd.h>
#include <ifaddrs.h>
#ifdef __LINUX__
#include <sys/ioctl.h>
#include <net/if.h>
#endif
#endif
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <atomic>
#include "../node/InetAddress.hpp"
#include "../node/Mutex.hpp"
#include "../node/Utils.hpp"
#include "Phy.hpp"
#include "OSUtils.hpp"
#if (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__))
#define ZT_UDP_DESIRED_BUF_SIZE 1048576
#else
#define ZT_UDP_DESIRED_BUF_SIZE 131072
#endif
// Period between refreshes of bindings
#define ZT_BINDER_REFRESH_PERIOD 30000
// Max number of bindings
#define ZT_BINDER_MAX_BINDINGS 256
namespace ZeroTier {
/**
* Enumerates local devices and binds to all potential ZeroTier path endpoints
*
* This replaces binding to wildcard (0.0.0.0 and ::0) with explicit binding
* as part of the path to default gateway support. Under the hood it uses
* different queries on different OSes to enumerate devices, and also exposes
* device enumeration and endpoint IP data for use elsewhere.
*
* On OSes that do not support local port enumeration or where this is not
* meaningful, this degrades to binding to wildcard.
*/
class Binder
{
private:
struct _Binding
{
_Binding() : udpSock((PhySocket *)0),tcpListenSock((PhySocket *)0) {}
PhySocket *udpSock;
PhySocket *tcpListenSock;
InetAddress address;
};
public:
Binder() : _bindingCount(0) {}
/**
* Close all bound ports, should be called on shutdown
*
* @param phy Physical interface
*/
template<typename PHY_HANDLER_TYPE>
void closeAll(Phy<PHY_HANDLER_TYPE> &phy)
{
Mutex::Lock _l(_lock);
for(unsigned int b=0,c=_bindingCount;b<c;++b) {
phy.close(_bindings[b].udpSock,false);
phy.close(_bindings[b].tcpListenSock,false);
}
_bindingCount = 0;
}
/**
* Scan local devices and addresses and rebind TCP and UDP
*
* This should be called after wake from sleep, on detected network device
* changes, on startup, or periodically (e.g. every 30-60s).
*
* @param phy Physical interface
* @param ports Ports to bind on all interfaces
* @param portCount Number of ports
* @param explicitBind If present, override interface IP detection and bind to these (if possible)
* @param ifChecker Interface checker function to see if an interface should be used
* @tparam PHY_HANDLER_TYPE Type for Phy<> template
* @tparam INTERFACE_CHECKER Type for class containing shouldBindInterface() method
*/
template<typename PHY_HANDLER_TYPE,typename INTERFACE_CHECKER>
void refresh(Phy<PHY_HANDLER_TYPE> &phy,unsigned int *ports,unsigned int portCount,const std::vector<InetAddress> explicitBind,INTERFACE_CHECKER &ifChecker)
{
std::map<InetAddress,std::string> localIfAddrs;
PhySocket *udps,*tcps;
Mutex::Lock _l(_lock);
bool interfacesEnumerated = true;
if (explicitBind.empty()) {
#ifdef __WINDOWS__
char aabuf[32768];
ULONG aalen = sizeof(aabuf);
if (GetAdaptersAddresses(AF_UNSPEC,GAA_FLAG_SKIP_ANYCAST|GAA_FLAG_SKIP_MULTICAST|GAA_FLAG_SKIP_DNS_SERVER,(void *)0,reinterpret_cast<PIP_ADAPTER_ADDRESSES>(aabuf),&aalen) == NO_ERROR) {
PIP_ADAPTER_ADDRESSES a = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(aabuf);
while (a) {
PIP_ADAPTER_UNICAST_ADDRESS ua = a->FirstUnicastAddress;
while (ua) {
InetAddress ip(ua->Address.lpSockaddr);
if (ifChecker.shouldBindInterface("",ip)) {
switch(ip.ipScope()) {
default: break;
case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
case InetAddress::IP_SCOPE_GLOBAL:
case InetAddress::IP_SCOPE_SHARED:
case InetAddress::IP_SCOPE_PRIVATE:
for(int x=0;x<(int)portCount;++x) {
ip.setPort(ports[x]);
localIfAddrs.insert(std::pair<InetAddress,std::string>(ip,std::string()));
}
break;
}
}
ua = ua->Next;
}
a = a->Next;
}
}
else {
interfacesEnumerated = false;
}
#else // not __WINDOWS__
/* On Linux we use an alternative method if available since getifaddrs()
* gets very slow when there are lots of network namespaces. This won't
* work unless /proc/PID/net/if_inet6 exists and it may not on some
* embedded systems, so revert to getifaddrs() there. */
#ifdef __LINUX__
char fn[256],tmp[256];
std::set<std::string> ifnames;
const unsigned long pid = (unsigned long)getpid();
// Get all device names
OSUtils::ztsnprintf(fn,sizeof(fn),"/proc/%lu/net/dev",pid);
FILE *procf = fopen(fn,"r");
if (procf) {
while (fgets(tmp,sizeof(tmp),procf)) {
tmp[255] = 0;
char *saveptr = (char *)0;
for(char *f=Utils::stok(tmp," \t\r\n:|",&saveptr);(f);f=Utils::stok((char *)0," \t\r\n:|",&saveptr)) {
if ((strcmp(f,"Inter-") != 0)&&(strcmp(f,"face") != 0)&&(f[0] != 0))
ifnames.insert(f);
break; // we only want the first field
}
}
fclose(procf);
}
else {
interfacesEnumerated = false;
}
// Get IPv6 addresses (and any device names we don't already know)
OSUtils::ztsnprintf(fn,sizeof(fn),"/proc/%lu/net/if_inet6",pid);
procf = fopen(fn,"r");
if (procf) {
while (fgets(tmp,sizeof(tmp),procf)) {
tmp[255] = 0;
char *saveptr = (char *)0;
unsigned char ipbits[16];
memset(ipbits,0,sizeof(ipbits));
char *devname = (char *)0;
int n = 0;
for(char *f=Utils::stok(tmp," \t\r\n",&saveptr);(f);f=Utils::stok((char *)0," \t\r\n",&saveptr)) {
switch(n++) {
case 0: // IP in hex
Utils::unhex(f,32,ipbits,16);
break;
case 5: // device name
devname = f;
break;
}
}
if (devname) {
ifnames.insert(devname);
InetAddress ip(ipbits,16,0);
if (ifChecker.shouldBindInterface(devname,ip)) {
switch(ip.ipScope()) {
default: break;
case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
case InetAddress::IP_SCOPE_GLOBAL:
case InetAddress::IP_SCOPE_SHARED:
case InetAddress::IP_SCOPE_PRIVATE:
for(int x=0;x<(int)portCount;++x) {
ip.setPort(ports[x]);
localIfAddrs.insert(std::pair<InetAddress,std::string>(ip,std::string(devname)));
}
break;
}
}
}
}
fclose(procf);
}
// Get IPv4 addresses for each device
if (ifnames.size() > 0) {
const int controlfd = (int)socket(AF_INET,SOCK_DGRAM,0);
struct ifconf configuration;
configuration.ifc_len = 0;
configuration.ifc_buf = nullptr;
if (controlfd < 0) goto ip4_address_error;
if (ioctl(controlfd, SIOCGIFCONF, &configuration) < 0) goto ip4_address_error;
configuration.ifc_buf = (char*)malloc(configuration.ifc_len);
if (ioctl(controlfd, SIOCGIFCONF, &configuration) < 0) goto ip4_address_error;
for (int i=0; i < (int)(configuration.ifc_len / sizeof(ifreq)); i ++) {
struct ifreq& request = configuration.ifc_req[i];
struct sockaddr* addr = &request.ifr_ifru.ifru_addr;
if (addr->sa_family != AF_INET) continue;
std::string ifname = request.ifr_ifrn.ifrn_name;
// name can either be just interface name or interface name followed by ':' and arbitrary label
if (ifname.find(':') != std::string::npos)
ifname = ifname.substr(0, ifname.find(':'));
InetAddress ip(&(((struct sockaddr_in *)addr)->sin_addr),4,0);
if (ifChecker.shouldBindInterface(ifname.c_str(), ip)) {
switch(ip.ipScope()) {
default: break;
case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
case InetAddress::IP_SCOPE_GLOBAL:
case InetAddress::IP_SCOPE_SHARED:
case InetAddress::IP_SCOPE_PRIVATE:
for(int x=0;x<(int)portCount;++x) {
ip.setPort(ports[x]);
localIfAddrs.insert(std::pair<InetAddress,std::string>(ip,ifname));
}
break;
}
}
}
ip4_address_error:
free(configuration.ifc_buf);
if (controlfd > 0) close(controlfd);
}
const bool gotViaProc = (localIfAddrs.size() > 0);
#else
const bool gotViaProc = false;
#endif
#if !defined(ZT_SDK) || !defined(__ANDROID__) // getifaddrs() freeifaddrs() not available on Android
if (!gotViaProc) {
struct ifaddrs *ifatbl = (struct ifaddrs *)0;
struct ifaddrs *ifa;
if ((getifaddrs(&ifatbl) == 0)&&(ifatbl)) {
ifa = ifatbl;
while (ifa) {
if ((ifa->ifa_name)&&(ifa->ifa_addr)) {
InetAddress ip = *(ifa->ifa_addr);
if (ifChecker.shouldBindInterface(ifa->ifa_name,ip)) {
switch(ip.ipScope()) {
default: break;
case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
case InetAddress::IP_SCOPE_GLOBAL:
case InetAddress::IP_SCOPE_SHARED:
case InetAddress::IP_SCOPE_PRIVATE:
for(int x=0;x<(int)portCount;++x) {
ip.setPort(ports[x]);
localIfAddrs.insert(std::pair<InetAddress,std::string>(ip,std::string(ifa->ifa_name)));
}
break;
}
}
}
ifa = ifa->ifa_next;
}
freeifaddrs(ifatbl);
}
else {
interfacesEnumerated = false;
}
}
#endif
#endif
} else {
for(std::vector<InetAddress>::const_iterator i(explicitBind.begin());i!=explicitBind.end();++i)
localIfAddrs.insert(std::pair<InetAddress,std::string>(*i,std::string()));
}
// Default to binding to wildcard if we can't enumerate addresses
if (!interfacesEnumerated && localIfAddrs.empty()) {
for(int x=0;x<(int)portCount;++x) {
localIfAddrs.insert(std::pair<InetAddress,std::string>(InetAddress((uint32_t)0,ports[x]),std::string()));
localIfAddrs.insert(std::pair<InetAddress,std::string>(InetAddress((const void *)"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",16,ports[x]),std::string()));
}
}
const unsigned int oldBindingCount = _bindingCount;
_bindingCount = 0;
// Save bindings that are still valid, close those that are not
for(unsigned int b=0;b<oldBindingCount;++b) {
if (localIfAddrs.find(_bindings[b].address) != localIfAddrs.end()) {
if (_bindingCount != b)
_bindings[(unsigned int)_bindingCount] = _bindings[b];
++_bindingCount;
} else {
PhySocket *const udps = _bindings[b].udpSock;
PhySocket *const tcps = _bindings[b].tcpListenSock;
_bindings[b].udpSock = (PhySocket *)0;
_bindings[b].tcpListenSock = (PhySocket *)0;
phy.close(udps,false);
phy.close(tcps,false);
}
}
// Create new bindings for those not already bound
for(std::map<InetAddress,std::string>::const_iterator ii(localIfAddrs.begin());ii!=localIfAddrs.end();++ii) {
unsigned int bi = 0;
while (bi != _bindingCount) {
if (_bindings[bi].address == ii->first)
break;
++bi;
}
if (bi == _bindingCount) {
udps = phy.udpBind(reinterpret_cast<const struct sockaddr *>(&(ii->first)),(void *)0,ZT_UDP_DESIRED_BUF_SIZE);
tcps = phy.tcpListen(reinterpret_cast<const struct sockaddr *>(&(ii->first)),(void *)0);
if ((udps)&&(tcps)) {
#ifdef __LINUX__
// Bind Linux sockets to their device so routes that we manage do not override physical routes (wish all platforms had this!)
if (ii->second.length() > 0) {
char tmp[256];
Utils::scopy(tmp,sizeof(tmp),ii->second.c_str());
int fd = (int)Phy<PHY_HANDLER_TYPE>::getDescriptor(udps);
if (fd >= 0)
setsockopt(fd,SOL_SOCKET,SO_BINDTODEVICE,tmp,strlen(tmp));
fd = (int)Phy<PHY_HANDLER_TYPE>::getDescriptor(tcps);
if (fd >= 0)
setsockopt(fd,SOL_SOCKET,SO_BINDTODEVICE,tmp,strlen(tmp));
}
#endif // __LINUX__
if (_bindingCount < ZT_BINDER_MAX_BINDINGS) {
_bindings[_bindingCount].udpSock = udps;
_bindings[_bindingCount].tcpListenSock = tcps;
_bindings[_bindingCount].address = ii->first;
phy.setIfName(udps,(char*)ii->second.c_str(),(int)ii->second.length());
++_bindingCount;
}
} else {
phy.close(udps,false);
phy.close(tcps,false);
}
}
}
}
/**
* @return All currently bound local interface addresses
*/
inline std::vector<InetAddress> allBoundLocalInterfaceAddresses() const
{
std::vector<InetAddress> aa;
Mutex::Lock _l(_lock);
for(unsigned int b=0,c=_bindingCount;b<c;++b)
aa.push_back(_bindings[b].address);
return aa;
}
/**
* Send from all bound UDP sockets
*/
template<typename PHY_HANDLER_TYPE>
inline bool udpSendAll(Phy<PHY_HANDLER_TYPE> &phy,const struct sockaddr_storage *addr,const void *data,unsigned int len,unsigned int ttl)
{
bool r = false;
Mutex::Lock _l(_lock);
for(unsigned int b=0,c=_bindingCount;b<c;++b) {
if (ttl) phy.setIp4UdpTtl(_bindings[b].udpSock,ttl);
if (phy.udpSend(_bindings[b].udpSock,(const struct sockaddr *)addr,data,len)) r = true;
if (ttl) phy.setIp4UdpTtl(_bindings[b].udpSock,255);
}
return r;
}
/**
* @param addr Address to check
* @return True if this is a bound local interface address
*/
inline bool isBoundLocalInterfaceAddress(const InetAddress &addr) const
{
Mutex::Lock _l(_lock);
for(unsigned int b=0;b<_bindingCount;++b) {
if (_bindings[b].address == addr)
return true;
}
return false;
}
/**
* Quickly check that a UDP socket is valid
*
* @param udpSock UDP socket to check
* @return True if socket is currently bound/allocated
*/
inline bool isUdpSocketValid(PhySocket *const udpSock)
{
for(unsigned int b=0,c=_bindingCount;b<c;++b) {
if (_bindings[b].udpSock == udpSock)
return (b < _bindingCount); // double check atomic which may have changed
}
return false;
}
private:
_Binding _bindings[ZT_BINDER_MAX_BINDINGS];
std::atomic<unsigned int> _bindingCount;
Mutex _lock;
};
} // namespace ZeroTier
#endif

View File

@ -1,408 +0,0 @@
/*
* ZeroTier One - Network Virtualization Everywhere
* Copyright (C) 2011-2015 ZeroTier, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
* ZeroTier may be used and distributed under the terms of the GPLv3, which
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
*
* If you would like to embed ZeroTier into a commercial application or
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <algorithm>
#include "RuntimeEnvironment.hpp"
#include "Logger.hpp"
#include "Filter.hpp"
#include "Utils.hpp"
namespace ZeroTier {
const char *const Filter::UNKNOWN_NAME = "(unknown)";
const Range<unsigned int> Filter::ANY;
static inline Range<unsigned int> __parseRange(char *r)
throw(std::invalid_argument)
{
char *saveptr = (char *)0;
unsigned int a = 0;
unsigned int b = 0;
unsigned int fn = 0;
for(char *f=Utils::stok(r,"-",&saveptr);(f);f=Utils::stok((char *)0,"-",&saveptr)) {
if (*f) {
switch(fn++) {
case 0:
if (*f != '*')
a = b = (unsigned int)strtoul(f,(char **)0,10);
break;
case 1:
if (*f != '*')
b = (unsigned int)strtoul(f,(char **)0,10);
break;
default:
throw std::invalid_argument("rule range must be <int>, <int>-<int>, or *");
}
}
}
return Range<unsigned int>(a,b);
}
Filter::Rule::Rule(const char *s)
throw(std::invalid_argument)
{
char *saveptr = (char *)0;
char tmp[256];
if (!Utils::scopy(tmp,sizeof(tmp),s))
throw std::invalid_argument("rule string too long");
unsigned int fn = 0;
for(char *f=Utils::stok(tmp,";",&saveptr);(f);f=Utils::stok((char *)0,";",&saveptr)) {
if (*f) {
switch(fn++) {
case 0:
_etherType = __parseRange(f);
break;
case 1:
_protocol = __parseRange(f);
break;
case 2:
_port = __parseRange(f);
break;
default:
throw std::invalid_argument("rule string has unknown extra fields");
}
}
}
if (fn != 3)
throw std::invalid_argument("rule string must contain 3 fields");
}
bool Filter::Rule::operator()(unsigned int etype,const void *data,unsigned int len) const
throw(std::invalid_argument)
{
if ((!_etherType)||(_etherType(etype))) { // ethertype is ANY, or matches
// Ethertype determines meaning of protocol and port
switch(etype) {
case ZT_ETHERTYPE_IPV4:
if (len > 20) {
if ((!_protocol)||(_protocol(((const uint8_t *)data)[9]))) { // protocol is ANY or match
if (!_port) // port is ANY
return true;
// Don't match on fragments beyond fragment 0. If we've blocked
// fragment 0, further fragments will fall on deaf ears anyway.
if ((Utils::ntoh(((const uint16_t *)data)[3]) & 0x1fff))
return false;
// Internet header length determines where data begins, in multiples of 32 bits
unsigned int ihl = 4 * (((const uint8_t *)data)[0] & 0x0f);
switch(((const uint8_t *)data)[9]) { // port's meaning depends on IP protocol
case ZT_IPPROTO_ICMP:
// For ICMP, port is ICMP type
return _port(((const uint8_t *)data)[ihl]);
case ZT_IPPROTO_TCP:
case ZT_IPPROTO_UDP:
case ZT_IPPROTO_SCTP:
case ZT_IPPROTO_UDPLITE:
// For these, port is destination port. Protocol designers were
// nice enough to put the field in the same place.
return _port(((const uint16_t *)data)[(ihl / 2) + 1]);
default:
// port has no meaning for other IP types, so ignore it
return true;
}
return false; // no match on port
}
} else throw std::invalid_argument("undersized IPv4 packet");
break;
case ZT_ETHERTYPE_IPV6:
if (len > 40) {
int nextHeader = ((const uint8_t *)data)[6];
unsigned int pos = 40;
while ((pos < len)&&(nextHeader >= 0)&&(nextHeader != 59)) { // 59 == no next header
fprintf(stderr,"[rule] V6: start header parse, header %.2x pos %d\n",nextHeader,pos);
switch(nextHeader) {
case 0: // hop-by-hop options
case 60: // destination options
case 43: // routing
case 135: // mobility (mobile IPv6 options)
if (_protocol((unsigned int)nextHeader))
return true; // match if our goal was to match any of these
nextHeader = ((const uint8_t *)data)[pos];
pos += 8 + (8 * ((const uint8_t *)data)[pos + 1]);
break;
case 44: // fragment
if (_protocol(44))
return true; // match if our goal was to match fragments
nextHeader = ((const uint8_t *)data)[pos];
pos += 8;
break;
case ZT_IPPROTO_AH: // AH
return _protocol(ZT_IPPROTO_AH); // true if AH is matched protocol, otherwise false since packet will be IPsec
case ZT_IPPROTO_ESP: // ESP
return _protocol(ZT_IPPROTO_ESP); // true if ESP is matched protocol, otherwise false since packet will be IPsec
case ZT_IPPROTO_ICMPV6:
// Only match ICMPv6 if we've selected it specifically
if (_protocol(ZT_IPPROTO_ICMPV6)) {
// Port is interpreted as ICMPv6 type
if ((!_port)||(_port(((const uint8_t *)data)[pos])))
return true;
}
break;
case ZT_IPPROTO_TCP:
case ZT_IPPROTO_UDP:
case ZT_IPPROTO_SCTP:
case ZT_IPPROTO_UDPLITE:
// If we encounter any of these, match if protocol matches or is wildcard as
// we'll consider these the "real payload" if present.
if ((!_protocol)||(_protocol(nextHeader))) {
if ((!_port)||(_port(((const uint16_t *)data)[(pos / 2) + 1])))
return true; // protocol matches or is ANY, port is ANY or matches
}
break;
default: {
char foo[128];
Utils::snprintf(foo,sizeof(foo),"unrecognized IPv6 header type %d",(int)nextHeader);
throw std::invalid_argument(foo);
}
}
fprintf(stderr,"[rule] V6: end header parse, next header %.2x, new pos %d\n",nextHeader,pos);
}
} else throw std::invalid_argument("undersized IPv6 packet");
break;
default:
// For other ethertypes, protocol and port are ignored. What would they mean?
return true;
}
}
return false;
}
std::string Filter::Rule::toString() const
{
char buf[128];
std::string s;
switch(_etherType.magnitude()) {
case 0:
s.push_back('*');
break;
case 1:
Utils::snprintf(buf,sizeof(buf),"%u",_etherType.start);
s.append(buf);
break;
default:
Utils::snprintf(buf,sizeof(buf),"%u-%u",_etherType.start,_etherType.end);
s.append(buf);
break;
}
s.push_back(';');
switch(_protocol.magnitude()) {
case 0:
s.push_back('*');
break;
case 1:
Utils::snprintf(buf,sizeof(buf),"%u",_protocol.start);
s.append(buf);
break;
default:
Utils::snprintf(buf,sizeof(buf),"%u-%u",_protocol.start,_protocol.end);
s.append(buf);
break;
}
s.push_back(';');
switch(_port.magnitude()) {
case 0:
s.push_back('*');
break;
case 1:
Utils::snprintf(buf,sizeof(buf),"%u",_port.start);
s.append(buf);
break;
default:
Utils::snprintf(buf,sizeof(buf),"%u-%u",_port.start,_port.end);
s.append(buf);
break;
}
return s;
}
Filter::Filter(const char *s)
throw(std::invalid_argument)
{
char tmp[16384];
if (!Utils::scopy(tmp,sizeof(tmp),s))
throw std::invalid_argument("filter string too long");
char *saveptr = (char *)0;
unsigned int fn = 0;
for(char *f=Utils::stok(tmp,",",&saveptr);(f);f=Utils::stok((char *)0,",",&saveptr)) {
try {
_rules.push_back(Rule(f));
++fn;
} catch (std::invalid_argument &exc) {
char tmp[256];
Utils::snprintf(tmp,sizeof(tmp),"invalid rule at index %u: %s",fn,exc.what());
throw std::invalid_argument(tmp);
}
}
std::sort(_rules.begin(),_rules.end());
}
std::string Filter::toString() const
{
std::string s;
for(std::vector<Rule>::const_iterator r(_rules.begin());r!=_rules.end();++r) {
if (s.length() > 0)
s.push_back(',');
s.append(r->toString());
}
return s;
}
void Filter::add(const Rule &r)
{
for(std::vector<Rule>::iterator rr(_rules.begin());rr!=_rules.end();++rr) {
if (r == *rr)
return;
}
_rules.push_back(r);
std::sort(_rules.begin(),_rules.end());
}
const char *Filter::etherTypeName(const unsigned int etherType)
throw()
{
switch(etherType) {
case ZT_ETHERTYPE_IPV4: return "ETHERTYPE_IPV4";
case ZT_ETHERTYPE_ARP: return "ETHERTYPE_ARP";
case ZT_ETHERTYPE_RARP: return "ETHERTYPE_RARP";
case ZT_ETHERTYPE_ATALK: return "ETHERTYPE_ATALK";
case ZT_ETHERTYPE_AARP: return "ETHERTYPE_AARP";
case ZT_ETHERTYPE_IPX_A: return "ETHERTYPE_IPX_A";
case ZT_ETHERTYPE_IPX_B: return "ETHERTYPE_IPX_B";
case ZT_ETHERTYPE_IPV6: return "ETHERTYPE_IPV6";
}
return UNKNOWN_NAME;
}
const char *Filter::ipProtocolName(const unsigned int ipp)
throw()
{
switch(ipp) {
case ZT_IPPROTO_ICMP: return "IPPROTO_ICMP";
case ZT_IPPROTO_IGMP: return "IPPROTO_IGMP";
case ZT_IPPROTO_TCP: return "IPPROTO_TCP";
case ZT_IPPROTO_UDP: return "IPPROTO_UDP";
case ZT_IPPROTO_GRE: return "IPPROTO_GRE";
case ZT_IPPROTO_ESP: return "IPPROTO_ESP";
case ZT_IPPROTO_AH: return "IPPROTO_AH";
case ZT_IPPROTO_ICMPV6: return "IPPROTO_ICMPV6";
case ZT_IPPROTO_OSPF: return "IPPROTO_OSPF";
case ZT_IPPROTO_IPIP: return "IPPROTO_IPIP";
case ZT_IPPROTO_IPCOMP: return "IPPROTO_IPCOMP";
case ZT_IPPROTO_L2TP: return "IPPROTO_L2TP";
case ZT_IPPROTO_SCTP: return "IPPROTO_SCTP";
case ZT_IPPROTO_FC: return "IPPROTO_FC";
case ZT_IPPROTO_UDPLITE: return "IPPROTO_UDPLITE";
case ZT_IPPROTO_HIP: return "IPPROTO_HIP";
}
return UNKNOWN_NAME;
}
const char *Filter::icmpTypeName(const unsigned int icmpType)
throw()
{
switch(icmpType) {
case ZT_ICMP_ECHO_REPLY: return "ICMP_ECHO_REPLY";
case ZT_ICMP_DESTINATION_UNREACHABLE: return "ICMP_DESTINATION_UNREACHABLE";
case ZT_ICMP_SOURCE_QUENCH: return "ICMP_SOURCE_QUENCH";
case ZT_ICMP_REDIRECT: return "ICMP_REDIRECT";
case ZT_ICMP_ALTERNATE_HOST_ADDRESS: return "ICMP_ALTERNATE_HOST_ADDRESS";
case ZT_ICMP_ECHO_REQUEST: return "ICMP_ECHO_REQUEST";
case ZT_ICMP_ROUTER_ADVERTISEMENT: return "ICMP_ROUTER_ADVERTISEMENT";
case ZT_ICMP_ROUTER_SOLICITATION: return "ICMP_ROUTER_SOLICITATION";
case ZT_ICMP_TIME_EXCEEDED: return "ICMP_TIME_EXCEEDED";
case ZT_ICMP_BAD_IP_HEADER: return "ICMP_BAD_IP_HEADER";
case ZT_ICMP_TIMESTAMP: return "ICMP_TIMESTAMP";
case ZT_ICMP_TIMESTAMP_REPLY: return "ICMP_TIMESTAMP_REPLY";
case ZT_ICMP_INFORMATION_REQUEST: return "ICMP_INFORMATION_REQUEST";
case ZT_ICMP_INFORMATION_REPLY: return "ICMP_INFORMATION_REPLY";
case ZT_ICMP_ADDRESS_MASK_REQUEST: return "ICMP_ADDRESS_MASK_REQUEST";
case ZT_ICMP_ADDRESS_MASK_REPLY: return "ICMP_ADDRESS_MASK_REPLY";
case ZT_ICMP_TRACEROUTE: return "ICMP_TRACEROUTE";
case ZT_ICMP_MOBILE_HOST_REDIRECT: return "ICMP_MOBILE_HOST_REDIRECT";
case ZT_ICMP_MOBILE_REGISTRATION_REQUEST: return "ICMP_MOBILE_REGISTRATION_REQUEST";
case ZT_ICMP_MOBILE_REGISTRATION_REPLY: return "ICMP_MOBILE_REGISTRATION_REPLY";
}
return UNKNOWN_NAME;
}
const char *Filter::icmp6TypeName(const unsigned int icmp6Type)
throw()
{
switch(icmp6Type) {
case ZT_ICMP6_DESTINATION_UNREACHABLE: return "ICMP6_DESTINATION_UNREACHABLE";
case ZT_ICMP6_PACKET_TOO_BIG: return "ICMP6_PACKET_TOO_BIG";
case ZT_ICMP6_TIME_EXCEEDED: return "ICMP6_TIME_EXCEEDED";
case ZT_ICMP6_PARAMETER_PROBLEM: return "ICMP6_PARAMETER_PROBLEM";
case ZT_ICMP6_ECHO_REQUEST: return "ICMP6_ECHO_REQUEST";
case ZT_ICMP6_ECHO_REPLY: return "ICMP6_ECHO_REPLY";
case ZT_ICMP6_MULTICAST_LISTENER_QUERY: return "ICMP6_MULTICAST_LISTENER_QUERY";
case ZT_ICMP6_MULTICAST_LISTENER_REPORT: return "ICMP6_MULTICAST_LISTENER_REPORT";
case ZT_ICMP6_MULTICAST_LISTENER_DONE: return "ICMP6_MULTICAST_LISTENER_DONE";
case ZT_ICMP6_ROUTER_SOLICITATION: return "ICMP6_ROUTER_SOLICITATION";
case ZT_ICMP6_ROUTER_ADVERTISEMENT: return "ICMP6_ROUTER_ADVERTISEMENT";
case ZT_ICMP6_NEIGHBOR_SOLICITATION: return "ICMP6_NEIGHBOR_SOLICITATION";
case ZT_ICMP6_NEIGHBOR_ADVERTISEMENT: return "ICMP6_NEIGHBOR_ADVERTISEMENT";
case ZT_ICMP6_REDIRECT_MESSAGE: return "ICMP6_REDIRECT_MESSAGE";
case ZT_ICMP6_ROUTER_RENUMBERING: return "ICMP6_ROUTER_RENUMBERING";
case ZT_ICMP6_NODE_INFORMATION_QUERY: return "ICMP6_NODE_INFORMATION_QUERY";
case ZT_ICMP6_NODE_INFORMATION_RESPONSE: return "ICMP6_NODE_INFORMATION_RESPONSE";
case ZT_ICMP6_INV_NEIGHBOR_SOLICITATION: return "ICMP6_INV_NEIGHBOR_SOLICITATION";
case ZT_ICMP6_INV_NEIGHBOR_ADVERTISEMENT: return "ICMP6_INV_NEIGHBOR_ADVERTISEMENT";
case ZT_ICMP6_MLDV2: return "ICMP6_MLDV2";
case ZT_ICMP6_HOME_AGENT_ADDRESS_DISCOVERY_REQUEST: return "ICMP6_HOME_AGENT_ADDRESS_DISCOVERY_REQUEST";
case ZT_ICMP6_HOME_AGENT_ADDRESS_DISCOVERY_REPLY: return "ICMP6_HOME_AGENT_ADDRESS_DISCOVERY_REPLY";
case ZT_ICMP6_MOBILE_PREFIX_SOLICITATION: return "ICMP6_MOBILE_PREFIX_SOLICITATION";
case ZT_ICMP6_MOBILE_PREFIX_ADVERTISEMENT: return "ICMP6_MOBILE_PREFIX_ADVERTISEMENT";
case ZT_ICMP6_CERTIFICATION_PATH_SOLICITATION: return "ICMP6_CERTIFICATION_PATH_SOLICITATION";
case ZT_ICMP6_CERTIFICATION_PATH_ADVERTISEMENT: return "ICMP6_CERTIFICATION_PATH_ADVERTISEMENT";
case ZT_ICMP6_MULTICAST_ROUTER_ADVERTISEMENT: return "ICMP6_MULTICAST_ROUTER_ADVERTISEMENT";
case ZT_ICMP6_MULTICAST_ROUTER_SOLICITATION: return "ICMP6_MULTICAST_ROUTER_SOLICITATION";
case ZT_ICMP6_MULTICAST_ROUTER_TERMINATION: return "ICMP6_MULTICAST_ROUTER_TERMINATION";
case ZT_ICMP6_RPL_CONTROL_MESSAGE: return "ICMP6_RPL_CONTROL_MESSAGE";
}
return UNKNOWN_NAME;
}
} // namespace ZeroTier

View File

@ -1,284 +0,0 @@
/*
* ZeroTier One - Network Virtualization Everywhere
* Copyright (C) 2011-2015 ZeroTier, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
* ZeroTier may be used and distributed under the terms of the GPLv3, which
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
*
* If you would like to embed ZeroTier into a commercial application or
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
*/
#ifndef _ZT_FILTER_HPP
#define _ZT_FILTER_HPP
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#include <utility>
#include <stdexcept>
#include "Range.hpp"
/* Ethernet frame types that might be relevant to us */
#define ZT_ETHERTYPE_IPV4 0x0800
#define ZT_ETHERTYPE_ARP 0x0806
#define ZT_ETHERTYPE_RARP 0x8035
#define ZT_ETHERTYPE_ATALK 0x809b
#define ZT_ETHERTYPE_AARP 0x80f3
#define ZT_ETHERTYPE_IPX_A 0x8137
#define ZT_ETHERTYPE_IPX_B 0x8138
#define ZT_ETHERTYPE_IPV6 0x86dd
/* IP protocols we might care about */
#define ZT_IPPROTO_ICMP 0x01
#define ZT_IPPROTO_IGMP 0x02
#define ZT_IPPROTO_TCP 0x06
#define ZT_IPPROTO_UDP 0x11
#define ZT_IPPROTO_GRE 0x2f
#define ZT_IPPROTO_ESP 0x32
#define ZT_IPPROTO_AH 0x33
#define ZT_IPPROTO_ICMPV6 0x3a
#define ZT_IPPROTO_OSPF 0x59
#define ZT_IPPROTO_IPIP 0x5e
#define ZT_IPPROTO_IPCOMP 0x6c
#define ZT_IPPROTO_L2TP 0x73
#define ZT_IPPROTO_SCTP 0x84
#define ZT_IPPROTO_FC 0x85
#define ZT_IPPROTO_UDPLITE 0x88
#define ZT_IPPROTO_HIP 0x8b
/* IPv4 ICMP types */
#define ZT_ICMP_ECHO_REPLY 0
#define ZT_ICMP_DESTINATION_UNREACHABLE 3
#define ZT_ICMP_SOURCE_QUENCH 4
#define ZT_ICMP_REDIRECT 5
#define ZT_ICMP_ALTERNATE_HOST_ADDRESS 6
#define ZT_ICMP_ECHO_REQUEST 8
#define ZT_ICMP_ROUTER_ADVERTISEMENT 9
#define ZT_ICMP_ROUTER_SOLICITATION 10
#define ZT_ICMP_TIME_EXCEEDED 11
#define ZT_ICMP_BAD_IP_HEADER 12
#define ZT_ICMP_TIMESTAMP 13
#define ZT_ICMP_TIMESTAMP_REPLY 14
#define ZT_ICMP_INFORMATION_REQUEST 15
#define ZT_ICMP_INFORMATION_REPLY 16
#define ZT_ICMP_ADDRESS_MASK_REQUEST 17
#define ZT_ICMP_ADDRESS_MASK_REPLY 18
#define ZT_ICMP_TRACEROUTE 30
#define ZT_ICMP_MOBILE_HOST_REDIRECT 32
#define ZT_ICMP_MOBILE_REGISTRATION_REQUEST 35
#define ZT_ICMP_MOBILE_REGISTRATION_REPLY 36
/* IPv6 ICMP types */
#define ZT_ICMP6_DESTINATION_UNREACHABLE 1
#define ZT_ICMP6_PACKET_TOO_BIG 2
#define ZT_ICMP6_TIME_EXCEEDED 3
#define ZT_ICMP6_PARAMETER_PROBLEM 4
#define ZT_ICMP6_ECHO_REQUEST 128
#define ZT_ICMP6_ECHO_REPLY 129
#define ZT_ICMP6_MULTICAST_LISTENER_QUERY 130
#define ZT_ICMP6_MULTICAST_LISTENER_REPORT 131
#define ZT_ICMP6_MULTICAST_LISTENER_DONE 132
#define ZT_ICMP6_ROUTER_SOLICITATION 133
#define ZT_ICMP6_ROUTER_ADVERTISEMENT 134
#define ZT_ICMP6_NEIGHBOR_SOLICITATION 135
#define ZT_ICMP6_NEIGHBOR_ADVERTISEMENT 136
#define ZT_ICMP6_REDIRECT_MESSAGE 137
#define ZT_ICMP6_ROUTER_RENUMBERING 138
#define ZT_ICMP6_NODE_INFORMATION_QUERY 139
#define ZT_ICMP6_NODE_INFORMATION_RESPONSE 140
#define ZT_ICMP6_INV_NEIGHBOR_SOLICITATION 141
#define ZT_ICMP6_INV_NEIGHBOR_ADVERTISEMENT 142
#define ZT_ICMP6_MLDV2 143
#define ZT_ICMP6_HOME_AGENT_ADDRESS_DISCOVERY_REQUEST 144
#define ZT_ICMP6_HOME_AGENT_ADDRESS_DISCOVERY_REPLY 145
#define ZT_ICMP6_MOBILE_PREFIX_SOLICITATION 146
#define ZT_ICMP6_MOBILE_PREFIX_ADVERTISEMENT 147
#define ZT_ICMP6_CERTIFICATION_PATH_SOLICITATION 148
#define ZT_ICMP6_CERTIFICATION_PATH_ADVERTISEMENT 149
#define ZT_ICMP6_MULTICAST_ROUTER_ADVERTISEMENT 151
#define ZT_ICMP6_MULTICAST_ROUTER_SOLICITATION 152
#define ZT_ICMP6_MULTICAST_ROUTER_TERMINATION 153
#define ZT_ICMP6_RPL_CONTROL_MESSAGE 155
namespace ZeroTier {
class RuntimeEnvironment;
/**
* A simple Ethernet frame level filter
*
* This doesn't specify actions, since it's used as a deny filter. The rule
* in ZT1 is "that which is not explicitly prohibited is allowed." (Except for
* ethertypes, which are handled by a whitelist.)
*/
class Filter
{
public:
/**
* Value returned by etherTypeName, etc. on unknown
*
* These static methods return precisely this, so a pointer equality
* check will work.
*/
static const char *const UNKNOWN_NAME;
/**
* An empty range as a more idiomatic way of specifying a wildcard match
*/
static const Range<unsigned int> ANY;
/**
* A filter rule
*/
class Rule
{
public:
Rule()
throw() :
_etherType(),
_protocol(),
_port()
{
}
/**
* Construct a rule from a string-serialized value
*
* @param s String formatted rule, such as returned by toString()
* @throws std::invalid_argument String formatted rule is not valid
*/
Rule(const char *s)
throw(std::invalid_argument);
/**
* Construct a new rule
*
* @param etype Ethernet type or empty range for ANY
* @param prot Protocol or empty range for ANY (meaning depends on ethertype, e.g. IP protocol numbers)
* @param prt Port or empty range for ANY (only applies to some protocols)
*/
Rule(const Range<unsigned int> &etype,const Range<unsigned int> &prot,const Range<unsigned int> &prt)
throw() :
_etherType(etype),
_protocol(prot),
_port(prt)
{
}
inline const Range<unsigned int> &etherType() const throw() { return _etherType; }
inline const Range<unsigned int> &protocol() const throw() { return _protocol; }
inline const Range<unsigned int> &port() const throw() { return _port; }
/**
* Test this rule against a frame
*
* @param etype Type of ethernet frame
* @param data Ethernet frame data
* @param len Length of ethernet frame
* @return True if rule matches
* @throws std::invalid_argument Frame invalid or not parseable
*/
bool operator()(unsigned int etype,const void *data,unsigned int len) const
throw(std::invalid_argument);
/**
* Serialize rule as string
*
* @return Human readable representation of rule
*/
std::string toString() const;
inline bool operator==(const Rule &r) const throw() { return ((_etherType == r._etherType)&&(_protocol == r._protocol)&&(_port == r._port)); }
inline bool operator!=(const Rule &r) const throw() { return !(*this == r); }
inline bool operator<(const Rule &r) const
throw()
{
if (_etherType < r._etherType)
return true;
else if (_etherType == r._etherType) {
if (_protocol < r._protocol)
return true;
else if (_protocol == r._protocol) {
if (_port < r._port)
return true;
}
}
return false;
}
inline bool operator>(const Rule &r) const throw() { return (r < *this); }
inline bool operator<=(const Rule &r) const throw() { return !(r < *this); }
inline bool operator>=(const Rule &r) const throw() { return !(*this < r); }
private:
Range<unsigned int> _etherType;
Range<unsigned int> _protocol;
Range<unsigned int> _port;
};
Filter() {}
/**
* @param s String-serialized filter representation
*/
Filter(const char *s)
throw(std::invalid_argument);
/**
* @return Comma-delimited list of string-format rules
*/
std::string toString() const;
/**
* Add a rule to this filter
*
* @param r Rule to add to filter
*/
void add(const Rule &r);
inline bool operator()(unsigned int etype,const void *data,unsigned int len) const
throw(std::invalid_argument)
{
for(std::vector<Rule>::const_iterator r(_rules.begin());r!=_rules.end();++r) {
if ((*r)(etype,data,len))
return true;
}
return false;
}
static const char *etherTypeName(const unsigned int etherType)
throw();
static const char *ipProtocolName(const unsigned int ipp)
throw();
static const char *icmpTypeName(const unsigned int icmpType)
throw();
static const char *icmp6TypeName(const unsigned int icmp6Type)
throw();
private:
std::vector<Rule> _rules;
};
} // namespace ZeroTier
#endif

View File

@ -1,29 +1,15 @@
/*
* ZeroTier One - Network Virtualization Everywhere
* Copyright (C) 2011-2015 ZeroTier, Inc.
* Copyright (c)2019 ZeroTier, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Change Date: 2023-01-01
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
* ZeroTier may be used and distributed under the terms of the GPLv3, which
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
*
* If you would like to embed ZeroTier into a commercial application or
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
* 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 <stdio.h>
#include <stdint.h>
@ -34,7 +20,12 @@
#include "OSUtils.hpp"
#include "../node/Constants.hpp"
#include "../node/Utils.hpp"
#ifdef ZT_USE_SYSTEM_HTTP_PARSER
#include <http_parser.h>
#else
#include "../ext/http-parser/http_parser.h"
#endif
namespace ZeroTier {
@ -42,12 +33,18 @@ namespace {
static int ShttpOnMessageBegin(http_parser *parser);
static int ShttpOnUrl(http_parser *parser,const char *ptr,size_t length);
#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 2)
static int ShttpOnStatus(http_parser *parser,const char *ptr,size_t length);
#else
static int ShttpOnStatus(http_parser *parser);
#endif
static int ShttpOnHeaderField(http_parser *parser,const char *ptr,size_t length);
static int ShttpOnValue(http_parser *parser,const char *ptr,size_t length);
static int ShttpOnHeadersComplete(http_parser *parser);
static int ShttpOnBody(http_parser *parser,const char *ptr,size_t length);
static int ShttpOnMessageComplete(http_parser *parser);
#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 1)
static const struct http_parser_settings HTTP_PARSER_SETTINGS = {
ShttpOnMessageBegin,
ShttpOnUrl,
@ -58,17 +55,28 @@ static const struct http_parser_settings HTTP_PARSER_SETTINGS = {
ShttpOnBody,
ShttpOnMessageComplete
};
#else
static const struct http_parser_settings HTTP_PARSER_SETTINGS = {
ShttpOnMessageBegin,
ShttpOnUrl,
ShttpOnHeaderField,
ShttpOnValue,
ShttpOnHeadersComplete,
ShttpOnBody,
ShttpOnMessageComplete
};
#endif
struct HttpPhyHandler
{
// not used
inline void phyOnDatagram(PhySocket *sock,void **uptr,const struct sockaddr *from,void *data,unsigned long len) {}
inline void phyOnDatagram(PhySocket *sock,void **uptr,const struct sockaddr *localAddr,const struct sockaddr *from,void *data,unsigned long len) {}
inline void phyOnTcpAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN,const struct sockaddr *from) {}
inline void phyOnTcpConnect(PhySocket *sock,void **uptr,bool success)
{
if (success) {
phy->tcpSetNotifyWritable(sock,true);
phy->setNotifyWritable(sock,true);
} else {
*responseBody = "connection failed";
error = true;
@ -91,23 +99,30 @@ struct HttpPhyHandler
inline void phyOnTcpWritable(PhySocket *sock,void **uptr)
{
if (writePtr < writeSize) {
long n = phy->tcpSend(sock,writeBuf + writePtr,writeSize - writePtr,true);
if (writePtr < (unsigned long)writeBuf.length()) {
long n = phy->streamSend(sock,writeBuf.data() + writePtr,(unsigned long)writeBuf.length() - writePtr,true);
if (n > 0)
writePtr += n;
}
if (writePtr >= writeSize)
phy->tcpSetNotifyWritable(sock,false);
if (writePtr >= (unsigned long)writeBuf.length())
phy->setNotifyWritable(sock,false);
}
inline void phyOnFileDescriptorActivity(PhySocket *sock,void **uptr,bool readable,bool writable) {}
#ifdef __UNIX_LIKE__
inline void phyOnUnixAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN) {}
inline void phyOnUnixClose(PhySocket *sock,void **uptr) {}
inline void phyOnUnixData(PhySocket *sock,void **uptr,void *data,unsigned long len) {}
inline void phyOnUnixWritable(PhySocket *sock,void **uptr) {}
#endif // __UNIX_LIKE__
http_parser parser;
std::string currentHeaderField;
std::string currentHeaderValue;
unsigned long messageSize;
unsigned long writePtr;
uint64_t lastActivity;
unsigned long writeSize;
char writeBuf[32768];
std::string writeBuf;
unsigned long maxResponseSize;
std::map<std::string,std::string> *responseHeaders;
@ -127,12 +142,18 @@ static int ShttpOnUrl(http_parser *parser,const char *ptr,size_t length)
{
return 0;
}
#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 2)
static int ShttpOnStatus(http_parser *parser,const char *ptr,size_t length)
#else
static int ShttpOnStatus(http_parser *parser)
#endif
{
/*
HttpPhyHandler *hh = reinterpret_cast<HttpPhyHandler *>(parser->data);
hh->messageSize += (unsigned long)length;
if (hh->messageSize > hh->maxResponseSize)
return -1;
*/
return 0;
}
static int ShttpOnHeaderField(http_parser *parser,const char *ptr,size_t length)
@ -209,24 +230,26 @@ unsigned int Http::_do(
handler.lastActivity = OSUtils::now();
try {
handler.writeSize = Utils::snprintf(handler.writeBuf,sizeof(handler.writeBuf),"%s %s HTTP/1.1\r\n",method,path);
for(std::map<std::string,std::string>::const_iterator h(requestHeaders.begin());h!=requestHeaders.end();++h)
handler.writeSize += Utils::snprintf(handler.writeBuf + handler.writeSize,sizeof(handler.writeBuf) - handler.writeSize,"%s: %s\r\n",h->first.c_str(),h->second.c_str());
handler.writeSize += Utils::snprintf(handler.writeBuf + handler.writeSize,sizeof(handler.writeBuf) - handler.writeSize,"\r\n");
if ((requestBody)&&(requestBodyLength)) {
if ((handler.writeSize + requestBodyLength) > sizeof(handler.writeBuf)) {
responseBody = "request too large";
return 0;
}
memcpy(handler.writeBuf + handler.writeSize,requestBody,requestBodyLength);
handler.writeSize += requestBodyLength;
char tmp[1024];
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%s %s HTTP/1.1\r\n",method,path);
handler.writeBuf.append(tmp);
for(std::map<std::string,std::string>::const_iterator h(requestHeaders.begin());h!=requestHeaders.end();++h) {
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%s: %s\r\n",h->first.c_str(),h->second.c_str());
handler.writeBuf.append(tmp);
}
handler.writeBuf.append("\r\n");
if ((requestBody)&&(requestBodyLength))
handler.writeBuf.append((const char *)requestBody,requestBodyLength);
} catch ( ... ) {
responseBody = "request too large";
return 0;
}
handler.maxResponseSize = maxResponseSize;
if (maxResponseSize) {
handler.maxResponseSize = maxResponseSize;
} else {
handler.maxResponseSize = 2147483647;
}
handler.responseHeaders = &responseHeaders;
handler.responseBody = &responseBody;
handler.error = false;

View File

@ -1,29 +1,15 @@
/*
* ZeroTier One - Network Virtualization Everywhere
* Copyright (C) 2011-2015 ZeroTier, Inc.
* Copyright (c)2019 ZeroTier, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Change Date: 2023-01-01
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
* ZeroTier may be used and distributed under the terms of the GPLv3, which
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
*
* If you would like to embed ZeroTier into a commercial application or
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
* 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
#define ZT_HTTP_HPP
@ -144,6 +130,39 @@ public:
responseBody);
}
/**
* Make HTTP PUT request
*
* It is the responsibility of the caller to set all headers. With PUT, the
* Content-Length and Content-Type headers must be set or the PUT will not
* work.
*
* @return HTTP status code or 0 on error (responseBody will contain error message)
*/
static inline unsigned int PUT(
unsigned long maxResponseSize,
unsigned long timeout,
const struct sockaddr *remoteAddress,
const char *path,
const std::map<std::string,std::string> &requestHeaders,
const void *postData,
unsigned long postDataLength,
std::map<std::string,std::string> &responseHeaders,
std::string &responseBody)
{
return _do(
"PUT",
maxResponseSize,
timeout,
remoteAddress,
path,
requestHeaders,
postData,
postDataLength,
responseHeaders,
responseBody);
}
private:
static unsigned int _do(
const char *method,

View File

@ -1,29 +1,15 @@
/*
* ZeroTier One - Network Virtualization Everywhere
* Copyright (C) 2011-2015 ZeroTier, Inc.
* Copyright (c)2019 ZeroTier, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* Change Date: 2023-01-01
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --
*
* ZeroTier may be used and distributed under the terms of the GPLv3, which
* are available at: http://www.gnu.org/licenses/gpl-3.0.html
*
* If you would like to embed ZeroTier into a commercial application or
* redistribute it in a modified binary form, please contact ZeroTier Networks
* LLC. Start here: http://www.zerotier.com/
* 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
#define ZT_PHY_HPP
@ -46,6 +32,7 @@
#define ZT_PHY_SOCKFD_VALID(s) ((s) != INVALID_SOCKET)
#define ZT_PHY_CLOSE_SOCKET(s) ::closesocket(s)
#define ZT_PHY_MAX_SOCKETS (FD_SETSIZE)
#define ZT_PHY_MAX_INTERCEPTS ZT_PHY_MAX_SOCKETS
#define ZT_PHY_SOCKADDR_STORAGE_TYPE struct sockaddr_storage
#else // not Windows
@ -58,15 +45,24 @@
#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#if defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux)
#ifndef IPV6_DONTFRAG
#define IPV6_DONTFRAG 62
#endif
#endif
#define ZT_PHY_SOCKFD_TYPE int
#define ZT_PHY_SOCKFD_NULL (-1)
#define ZT_PHY_SOCKFD_VALID(s) ((s) > -1)
#define ZT_PHY_CLOSE_SOCKET(s) ::close(s)
#define ZT_PHY_MAX_SOCKETS (FD_SETSIZE)
#define ZT_PHY_MAX_INTERCEPTS ZT_PHY_MAX_SOCKETS
#define ZT_PHY_SOCKADDR_STORAGE_TYPE struct sockaddr_storage
#endif // Windows or not
@ -87,12 +83,22 @@ typedef void PhySocket;
* This class is templated on a pointer to a handler class which must
* implement the following functions:
*
* phyOnDatagram(PhySocket *sock,void **uptr,const struct sockaddr *from,void *data,unsigned long len)
* For all platforms:
*
* phyOnDatagram(PhySocket *sock,void **uptr,const struct sockaddr *localAddr,const struct sockaddr *from,void *data,unsigned long len)
* phyOnTcpConnect(PhySocket *sock,void **uptr,bool success)
* phyOnTcpAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN,const struct sockaddr *from)
* phyOnTcpClose(PhySocket *sock,void **uptr)
* phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len)
* phyOnTcpWritable(PhySocket *sock,void **uptr)
* phyOnFileDescriptorActivity(PhySocket *sock,void **uptr,bool readable,bool writable)
*
* On Linux/OSX/Unix only (not required/used on Windows or elsewhere):
*
* phyOnUnixAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN)
* phyOnUnixClose(PhySocket *sock,void **uptr)
* phyOnUnixData(PhySocket *sock,void **uptr,void *data,unsigned long len)
* phyOnUnixWritable(PhySocket *sock,void **uptr)
*
* These templates typically refer to function objects. Templates are used to
* avoid the call overhead of indirection, which is surprisingly high for high
@ -128,16 +134,19 @@ private:
ZT_PHY_SOCKET_TCP_OUT_CONNECTED = 0x02,
ZT_PHY_SOCKET_TCP_IN = 0x03,
ZT_PHY_SOCKET_TCP_LISTEN = 0x04,
ZT_PHY_SOCKET_RAW = 0x05,
ZT_PHY_SOCKET_UDP = 0x06
ZT_PHY_SOCKET_UDP = 0x05,
ZT_PHY_SOCKET_FD = 0x06,
ZT_PHY_SOCKET_UNIX_IN = 0x07,
ZT_PHY_SOCKET_UNIX_LISTEN = 0x08
};
struct PhySocketImpl
{
struct PhySocketImpl {
PhySocketImpl() { memset(ifname, 0, sizeof(ifname)); }
PhySocketType type;
ZT_PHY_SOCKFD_TYPE sock;
void *uptr; // user-settable pointer
ZT_PHY_SOCKADDR_STORAGE_TYPE saddr; // remote for TCP_OUT and TCP_IN, local for TCP_LISTEN, RAW, and UDP
char ifname[16];
};
std::list<PhySocketImpl> _socks;
@ -217,15 +226,94 @@ public:
ZT_PHY_CLOSE_SOCKET(_whackSendSocket);
}
/**
* @param s Socket object
* @return Underlying OS-type (usually int or long) file descriptor associated with object
*/
static inline ZT_PHY_SOCKFD_TYPE getDescriptor(PhySocket *s) throw() { return reinterpret_cast<PhySocketImpl *>(s)->sock; }
/**
* @param s Socket object
* @return Pointer to user object
*/
static inline void** getuptr(PhySocket *s) throw() { return &(reinterpret_cast<PhySocketImpl *>(s)->uptr); }
/**
* @param s Socket object
* @param nameBuf Buffer to store name of interface which this Socket object is bound to
* @param buflen Length of buffer to copy name into
*/
static inline void getIfName(PhySocket *s, char *nameBuf, int buflen)
{
if (s) {
memcpy(nameBuf, reinterpret_cast<PhySocketImpl *>(s)->ifname, buflen);
}
}
/**
* @param s Socket object
* @param ifname Buffer containing name of interface that this Socket object is bound to
* @param len Length of name of interface
*/
static inline void setIfName(PhySocket *s, char *ifname, int len)
{
if (s) {
memcpy(&(reinterpret_cast<PhySocketImpl *>(s)->ifname), ifname, len);
}
}
/**
* Whether or not the socket object is in a closed state
*
* @param s Socket object
* @return true if socket is closed, false if otherwise
*/
inline bool isClosed(PhySocket *s)
{
PhySocketImpl *sws = (reinterpret_cast<PhySocketImpl *>(s));
return sws->type == ZT_PHY_SOCKET_CLOSED;
}
/**
* Get state of socket object
*
* @param s Socket object
* @return State of socket
*/
inline int getState(PhySocket *s)
{
PhySocketImpl *sws = (reinterpret_cast<PhySocketImpl *>(s));
return sws->type;
}
/**
* In the event that this socket is erased, we need a way to convey to the multipath logic
* that this path is no longer valid.
*
* @param s Socket object
* @return Whether the state of this socket is within an acceptable range of values
*/
inline bool isValidState(PhySocket *s)
{
if (s) {
PhySocketImpl *sws = (reinterpret_cast<PhySocketImpl *>(s));
return sws->type >= ZT_PHY_SOCKET_CLOSED && sws->type <= ZT_PHY_SOCKET_UNIX_LISTEN;
}
return false;
}
/**
* Cause poll() to stop waiting immediately
*
* This can be used to reset the polling loop after changes that require
* attention, or to shut down a background thread that is waiting, etc.
*/
inline void whack()
{
#if defined(_WIN32) || defined(_WIN64)
::send(_whackSendSocket,(const char *)this,1,0);
#else
::write(_whackSendSocket,(PhySocket *)this,1);
(void)(::write(_whackSendSocket,(PhySocket *)this,1));
#endif
}
@ -239,6 +327,48 @@ public:
*/
inline unsigned long maxCount() const throw() { return ZT_PHY_MAX_SOCKETS; }
/**
* Wrap a raw file descriptor in a PhySocket structure
*
* This can be used to select/poll on a raw file descriptor as part of this
* class's I/O loop. By default the fd is set for read notification but
* this can be controlled with setNotifyReadable(). When any detected
* condition is present, the phyOnFileDescriptorActivity() callback is
* called with one or both of its arguments 'true'.
*
* The Phy<>::close() method *must* be called when you're done with this
* file descriptor to remove it from the select/poll set, but unlike other
* types of sockets Phy<> does not actually close the underlying fd or
* otherwise manage its life cycle. There is also no close notification
* callback for this fd, since Phy<> doesn't actually perform reading or
* writing or detect error conditions. This is only useful for adding a
* file descriptor to Phy<> to select/poll on it.
*
* @param fd Raw file descriptor
* @param uptr User pointer to supply to callbacks
* @return PhySocket wrapping fd or NULL on failure (out of memory or too many sockets)
*/
inline PhySocket *wrapSocket(ZT_PHY_SOCKFD_TYPE fd,void *uptr = (void *)0)
{
if (_socks.size() >= ZT_PHY_MAX_SOCKETS)
return (PhySocket *)0;
try {
_socks.push_back(PhySocketImpl());
} catch ( ... ) {
return (PhySocket *)0;
}
PhySocketImpl &sws = _socks.back();
if ((long)fd > _nfds)
_nfds = (long)fd;
FD_SET(fd,&_readfds);
sws.type = ZT_PHY_SOCKET_UNIX_IN; /* TODO: Type was changed to allow for CBs with new RPC model */
sws.sock = fd;
sws.uptr = uptr;
memset(&(sws.saddr),0,sizeof(struct sockaddr_storage));
// no sockaddr for this socket type, leave saddr null
return (PhySocket *)&sws;
}
/**
* Bind a UDP socket
*
@ -290,6 +420,9 @@ public:
f = 1; setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void *)&f,sizeof(f));
#ifdef IPV6_MTU_DISCOVER
f = 0; setsockopt(s,IPPROTO_IPV6,IPV6_MTU_DISCOVER,&f,sizeof(f));
#endif
#ifdef IPV6_DONTFRAG
f = 0; setsockopt(s,IPPROTO_IPV6,IPV6_DONTFRAG,&f,sizeof(f));
#endif
}
f = 0; setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(void *)&f,sizeof(f));
@ -301,7 +434,10 @@ public:
f = 0; setsockopt(s,IPPROTO_IP,IP_MTU_DISCOVER,&f,sizeof(f));
#endif
#ifdef SO_NO_CHECK
if (_noCheck) {
// For now at least we only set SO_NO_CHECK on IPv4 sockets since some
// IPv6 stacks incorrectly discard zero checksum packets. May remove
// this restriction later once broken stuff dies more.
if ((localAddress->sa_family == AF_INET)&&(_noCheck)) {
f = 1; setsockopt(s,SOL_SOCKET,SO_NO_CHECK,(void *)&f,sizeof(f));
}
#endif
@ -339,6 +475,24 @@ public:
return (PhySocket *)&sws;
}
/**
* Set the IP TTL for the next outgoing packet (for IPv4 UDP sockets only)
*
* @param ttl New TTL (0 or >255 will set it to 255)
* @return True on success
*/
inline bool setIp4UdpTtl(PhySocket *sock,unsigned int ttl)
{
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
#if defined(_WIN32) || defined(_WIN64)
DWORD tmp = ((ttl == 0)||(ttl > 255)) ? 255 : (DWORD)ttl;
return (::setsockopt(sws.sock,IPPROTO_IP,IP_TTL,(const char *)&tmp,sizeof(tmp)) == 0);
#else
int tmp = ((ttl == 0)||(ttl > 255)) ? 255 : (int)ttl;
return (::setsockopt(sws.sock,IPPROTO_IP,IP_TTL,(void *)&tmp,sizeof(tmp)) == 0);
#endif
}
/**
* Send a UDP packet
*
@ -358,6 +512,64 @@ public:
#endif
}
#ifdef __UNIX_LIKE__
/**
* Listen for connections on a Unix domain socket
*
* @param path Path to Unix domain socket
* @param uptr Arbitrary pointer to associate
* @return PhySocket or NULL if cannot bind
*/
inline PhySocket *unixListen(const char *path,void *uptr = (void *)0)
{
struct sockaddr_un sun;
if (_socks.size() >= ZT_PHY_MAX_SOCKETS)
return (PhySocket *)0;
memset(&sun,0,sizeof(sun));
sun.sun_family = AF_UNIX;
if (strlen(path) >= sizeof(sun.sun_path))
return (PhySocket *)0;
strcpy(sun.sun_path,path);
ZT_PHY_SOCKFD_TYPE s = ::socket(PF_UNIX,SOCK_STREAM,0);
if (!ZT_PHY_SOCKFD_VALID(s))
return (PhySocket *)0;
::fcntl(s,F_SETFL,O_NONBLOCK);
::unlink(path);
if (::bind(s,(struct sockaddr *)&sun,sizeof(struct sockaddr_un)) != 0) {
ZT_PHY_CLOSE_SOCKET(s);
return (PhySocket *)0;
}
if (::listen(s,128) != 0) {
ZT_PHY_CLOSE_SOCKET(s);
return (PhySocket *)0;
}
try {
_socks.push_back(PhySocketImpl());
} catch ( ... ) {
ZT_PHY_CLOSE_SOCKET(s);
return (PhySocket *)0;
}
PhySocketImpl &sws = _socks.back();
if ((long)s > _nfds)
_nfds = (long)s;
FD_SET(s,&_readfds);
sws.type = ZT_PHY_SOCKET_UNIX_LISTEN;
sws.sock = s;
sws.uptr = uptr;
memset(&(sws.saddr),0,sizeof(struct sockaddr_storage));
memcpy(&(sws.saddr),&sun,sizeof(struct sockaddr_un));
return (PhySocket *)&sws;
}
#endif // __UNIX_LIKE__
/**
* Bind a local listen socket to listen for new TCP connections
*
@ -523,19 +735,52 @@ public:
}
/**
* Attempt to send data to a TCP connection (non-blocking)
* Try to set buffer sizes as close to the given value as possible
*
* This will try the specified value and then lower values in 16K increments
* until one works.
*
* @param sock Socket
* @param receiveBufferSize Desired size of receive buffer
* @param sendBufferSize Desired size of send buffer
*/
inline void setBufferSizes(const PhySocket *sock,int receiveBufferSize,int sendBufferSize)
{
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
if (receiveBufferSize > 0) {
while (receiveBufferSize > 0) {
int tmpbs = receiveBufferSize;
if (::setsockopt(sws.sock,SOL_SOCKET,SO_RCVBUF,(const char *)&tmpbs,sizeof(tmpbs)) == 0)
break;
receiveBufferSize -= 16384;
}
}
if (sendBufferSize > 0) {
while (sendBufferSize > 0) {
int tmpbs = sendBufferSize;
if (::setsockopt(sws.sock,SOL_SOCKET,SO_SNDBUF,(const char *)&tmpbs,sizeof(tmpbs)) == 0)
break;
sendBufferSize -= 16384;
}
}
}
/**
* Attempt to send data to a stream socket (non-blocking)
*
* If -1 is returned, the socket should no longer be used as it is now
* destroyed. If callCloseHandler is true, the close handler will be
* called before the function returns.
*
* @param sock An open TCP socket (other socket types will fail)
* This can be used with TCP, Unix, or socket pair sockets.
*
* @param sock An open stream socket (other socket types will fail)
* @param data Data to send
* @param len Length of data
* @param callCloseHandler If true, call close handler on socket closing failure condition (default: true)
* @return Number of bytes actually sent or -1 on fatal error (socket closure)
*/
inline long tcpSend(PhySocket *sock,const void *data,unsigned long len,bool callCloseHandler = true)
inline long streamSend(PhySocket *sock,const void *data,unsigned long len,bool callCloseHandler = true)
{
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
#if defined(_WIN32) || defined(_WIN64)
@ -573,17 +818,58 @@ public:
return n;
}
#ifdef __UNIX_LIKE__
/**
* Set whether we want to be notified via the TCP writability handler when a socket is writable
* Attempt to send data to a Unix domain socket connection (non-blocking)
*
* If -1 is returned, the socket should no longer be used as it is now
* destroyed. If callCloseHandler is true, the close handler will be
* called before the function returns.
*
* @param sock An open Unix socket (other socket types will fail)
* @param data Data to send
* @param len Length of data
* @param callCloseHandler If true, call close handler on socket closing failure condition (default: true)
* @return Number of bytes actually sent or -1 on fatal error (socket closure)
*/
inline long unixSend(PhySocket *sock,const void *data,unsigned long len,bool callCloseHandler = true)
{
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
long n = (long)::write(sws.sock,data,len);
if (n < 0) {
switch(errno) {
#ifdef EAGAIN
case EAGAIN:
#endif
#if defined(EWOULDBLOCK) && ( !defined(EAGAIN) || (EWOULDBLOCK != EAGAIN) )
case EWOULDBLOCK:
#endif
#ifdef EINTR
case EINTR:
#endif
return 0;
default:
this->close(sock,callCloseHandler);
return -1;
}
}
return n;
}
#endif // __UNIX_LIKE__
/**
* For streams, sets whether we want to be notified that the socket is writable
*
* This can be used with TCP, Unix, or socket pair sockets.
*
* Call whack() if this is being done from another thread and you want
* it to take effect immediately. Otherwise it is only guaranteed to
* take effect on the next poll().
*
* @param sock TCP connection socket (other types are not valid)
* @param sock Stream connection socket
* @param notifyWritable Want writable notifications?
*/
inline const void tcpSetNotifyWritable(PhySocket *sock,bool notifyWritable)
inline void setNotifyWritable(PhySocket *sock,bool notifyWritable)
{
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
if (notifyWritable) {
@ -593,6 +879,26 @@ public:
}
}
/**
* Set whether we want to be notified that a socket is readable
*
* This is primarily for raw sockets added with wrapSocket(). It could be
* used with others, but doing so would essentially lock them and prevent
* data from being read from them until this is set to 'true' again.
*
* @param sock Socket to modify
* @param notifyReadable True if socket should be monitored for readability
*/
inline void setNotifyReadable(PhySocket *sock,bool notifyReadable)
{
PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock));
if (notifyReadable) {
FD_SET(sws.sock,&_readfds);
} else {
FD_CLR(sws.sock,&_readfds);
}
}
/**
* Wait for activity and handle one or more events
*
@ -713,13 +1019,13 @@ public:
case ZT_PHY_SOCKET_UDP:
if (FD_ISSET(s->sock,&rfds)) {
for(;;) {
for(int k=0;k<1024;++k) {
memset(&ss,0,sizeof(ss));
socklen_t slen = sizeof(ss);
long n = (long)::recvfrom(s->sock,buf,sizeof(buf),0,(struct sockaddr *)&ss,&slen);
if (n > 0) {
try {
_handler->phyOnDatagram((PhySocket *)&(*s),&(s->uptr),(const struct sockaddr *)&ss,(void *)buf,(unsigned long)n);
_handler->phyOnDatagram((PhySocket *)&(*s),&(s->uptr),(const struct sockaddr *)&(s->saddr),(const struct sockaddr *)&ss,(void *)buf,(unsigned long)n);
} catch ( ... ) {}
} else if (n < 0)
break;
@ -727,6 +1033,67 @@ public:
}
break;
case ZT_PHY_SOCKET_UNIX_IN: {
#ifdef __UNIX_LIKE__
ZT_PHY_SOCKFD_TYPE sock = s->sock; // if closed, s->sock becomes invalid as s is no longer dereferencable
if ((FD_ISSET(sock,&wfds))&&(FD_ISSET(sock,&_writefds))) {
try {
_handler->phyOnUnixWritable((PhySocket *)&(*s),&(s->uptr));
} catch ( ... ) {}
}
if (FD_ISSET(sock,&rfds)) {
long n = (long)::read(sock,buf,sizeof(buf));
if (n <= 0) {
this->close((PhySocket *)&(*s),true);
} else {
try {
_handler->phyOnUnixData((PhySocket *)&(*s),&(s->uptr),(void *)buf,(unsigned long)n);
} catch ( ... ) {}
}
}
#endif // __UNIX_LIKE__
} break;
case ZT_PHY_SOCKET_UNIX_LISTEN:
#ifdef __UNIX_LIKE__
if (FD_ISSET(s->sock,&rfds)) {
memset(&ss,0,sizeof(ss));
socklen_t slen = sizeof(ss);
ZT_PHY_SOCKFD_TYPE newSock = ::accept(s->sock,(struct sockaddr *)&ss,&slen);
if (ZT_PHY_SOCKFD_VALID(newSock)) {
if (_socks.size() >= ZT_PHY_MAX_SOCKETS) {
ZT_PHY_CLOSE_SOCKET(newSock);
} else {
fcntl(newSock,F_SETFL,O_NONBLOCK);
_socks.push_back(PhySocketImpl());
PhySocketImpl &sws = _socks.back();
FD_SET(newSock,&_readfds);
if ((long)newSock > _nfds)
_nfds = (long)newSock;
sws.type = ZT_PHY_SOCKET_UNIX_IN;
sws.sock = newSock;
sws.uptr = (void *)0;
memcpy(&(sws.saddr),&ss,sizeof(struct sockaddr_storage));
try {
//_handler->phyOnUnixAccept((PhySocket *)&(*s),(PhySocket *)&(_socks.back()),&(s->uptr),&(sws.uptr));
} catch ( ... ) {}
}
}
}
#endif // __UNIX_LIKE__
break;
case ZT_PHY_SOCKET_FD: {
ZT_PHY_SOCKFD_TYPE sock = s->sock;
const bool readable = ((FD_ISSET(sock,&rfds))&&(FD_ISSET(sock,&_readfds)));
const bool writable = ((FD_ISSET(sock,&wfds))&&(FD_ISSET(sock,&_writefds)));
if ((readable)||(writable)) {
try {
//_handler->phyOnFileDescriptorActivity((PhySocket *)&(*s),&(s->uptr),readable,writable);
} catch ( ... ) {}
}
} break;
default:
break;
@ -756,26 +1123,37 @@ public:
FD_CLR(sws.sock,&_exceptfds);
#endif
ZT_PHY_CLOSE_SOCKET(sws.sock);
if (sws.type != ZT_PHY_SOCKET_FD)
ZT_PHY_CLOSE_SOCKET(sws.sock);
switch(sws.type) {
case ZT_PHY_SOCKET_TCP_OUT_PENDING:
if (callHandlers) {
#ifdef __UNIX_LIKE__
if (sws.type == ZT_PHY_SOCKET_UNIX_LISTEN)
::unlink(((struct sockaddr_un *)(&(sws.saddr)))->sun_path);
#endif // __UNIX_LIKE__
if (callHandlers) {
switch(sws.type) {
case ZT_PHY_SOCKET_TCP_OUT_PENDING:
try {
_handler->phyOnTcpConnect(sock,&(sws.uptr),false);
} catch ( ... ) {}
}
break;
case ZT_PHY_SOCKET_TCP_OUT_CONNECTED:
case ZT_PHY_SOCKET_TCP_IN:
if (callHandlers) {
break;
case ZT_PHY_SOCKET_TCP_OUT_CONNECTED:
case ZT_PHY_SOCKET_TCP_IN:
try {
_handler->phyOnTcpClose(sock,&(sws.uptr));
} catch ( ... ) {}
}
break;
default:
break;
break;
case ZT_PHY_SOCKET_UNIX_IN:
#ifdef __UNIX_LIKE__
try {
_handler->phyOnUnixClose(sock,&(sws.uptr));
} catch ( ... ) {}
#endif // __UNIX_LIKE__
break;
default:
break;
}
}
// Causes entry to be deleted from list in poll(), ignored elsewhere

View File

@ -0,0 +1,14 @@
#define ENABLE_STRNATPMPERR
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#define _XOPEN_SOURCE 600
#ifdef __APPLE__
#ifndef _DARWIN_C_SOURCE
#define _DARWIN_C_SOURCE
#endif
#endif
#include "../ext/libnatpmp/getgateway.c"
#include "../ext/libnatpmp/wingettimeofday.c"
#include "../ext/libnatpmp/natpmp.c"

View File

@ -0,0 +1,41 @@
#define MINIUPNP_STATICLIB
#define MINIUPNPC_SET_SOCKET_TIMEOUT
#define MINIUPNPC_GET_SRC_ADDR
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#define _XOPEN_SOURCE 600
#define MINIUPNPC_VERSION_STRING "2.0"
#define UPNP_VERSION_STRING "UPnP/1.1"
#ifdef __LINUX__
#define OS_STRING "Linux"
#endif
#ifdef __APPLE__
#define OS_STRING "Darwin"
#endif
#ifdef __WINDOWS__
#define OS_STRING "Windows"
#endif
#ifndef OS_STRING
#define OS_STRING "ZeroTier"
#endif
#ifdef __APPLE__
#ifndef _DARWIN_C_SOURCE
#define _DARWIN_C_SOURCE
#endif
#endif
#include "../ext/miniupnpc/connecthostport.c"
#include "../ext/miniupnpc/igd_desc_parse.c"
#include "../ext/miniupnpc/minisoap.c"
#include "../ext/miniupnpc/miniupnpc.c"
#include "../ext/miniupnpc/miniwget.c"
#include "../ext/miniupnpc/minixml.c"
#include "../ext/miniupnpc/portlistingparse.c"
#include "../ext/miniupnpc/receivedata.c"
#include "../ext/miniupnpc/upnpcommands.c"
#include "../ext/miniupnpc/upnpdev.c"
#include "../ext/miniupnpc/upnperrors.c"
#include "../ext/miniupnpc/upnpreplyparse.c"
#include "../ext/miniupnpc/minissdpc.c"

334
attic/PortMapper.cpp Normal file
View File

@ -0,0 +1,334 @@
/*
* Copyright (c)2019 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2023-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.
*/
/****/
// Uncomment to dump debug messages
//#define ZT_PORTMAPPER_TRACE 1
#ifdef __ANDROID__
#include <android/log.h>
#define PM_TRACE(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, "PortMapper", __VA_ARGS__))
#else
#define PM_TRACE(...) fprintf(stderr, __VA_ARGS__)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "../node/Utils.hpp"
#include "OSUtils.hpp"
#include "PortMapper.hpp"
// These must be defined to get rid of dynamic export stuff in libminiupnpc and libnatpmp
#ifdef __WINDOWS__
#ifndef MINIUPNP_STATICLIB
#define MINIUPNP_STATICLIB
#endif
#ifndef STATICLIB
#define STATICLIB
#endif
#endif
#ifdef ZT_USE_SYSTEM_MINIUPNPC
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#else
#ifdef __ANDROID__
#include "miniupnpc.h"
#include "upnpcommands.h"
#else
#include "../ext/miniupnpc/miniupnpc.h"
#include "../ext/miniupnpc/upnpcommands.h"
#endif
#endif
#ifdef ZT_USE_SYSTEM_NATPMP
#include <natpmp.h>
#else
#ifdef __ANDROID__
#include "natpmp.h"
#else
#include "../ext/libnatpmp/natpmp.h"
#endif
#endif
namespace ZeroTier {
class PortMapperImpl
{
public:
PortMapperImpl(int localUdpPortToMap,const char *un) :
run(true),
localPort(localUdpPortToMap),
uniqueName(un)
{
}
~PortMapperImpl() {}
void threadMain()
throw()
{
int mode = 0; // 0 == NAT-PMP, 1 == UPnP
#ifdef ZT_PORTMAPPER_TRACE
fprintf(stderr,"PortMapper: started for UDP port %d" ZT_EOL_S,localPort);
#endif
while (run) {
// ---------------------------------------------------------------------
// NAT-PMP mode (preferred)
// ---------------------------------------------------------------------
if (mode == 0) {
natpmp_t natpmp;
natpmpresp_t response;
int r = 0;
bool natPmpSuccess = false;
for(int tries=0;tries<60;++tries) {
int tryPort = (int)localPort + tries;
if (tryPort >= 65535)
tryPort = (tryPort - 65535) + 1025;
memset(&natpmp,0,sizeof(natpmp));
memset(&response,0,sizeof(response));
if (initnatpmp(&natpmp,0,0) != 0) {
mode = 1;
closenatpmp(&natpmp);
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: NAT-PMP: init failed, switching to UPnP mode" ZT_EOL_S);
#endif
break;
}
InetAddress publicAddress;
sendpublicaddressrequest(&natpmp);
int64_t myTimeout = OSUtils::now() + 5000;
do {
fd_set fds;
struct timeval timeout;
FD_ZERO(&fds);
FD_SET(natpmp.s, &fds);
getnatpmprequesttimeout(&natpmp, &timeout);
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
r = readnatpmpresponseorretry(&natpmp, &response);
if (OSUtils::now() >= myTimeout)
break;
} while (r == NATPMP_TRYAGAIN);
if (r == 0) {
publicAddress = InetAddress((uint32_t)response.pnu.publicaddress.addr.s_addr,0);
} else {
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: NAT-PMP: request for external address failed, aborting..." ZT_EOL_S);
#endif
closenatpmp(&natpmp);
break;
}
sendnewportmappingrequest(&natpmp,NATPMP_PROTOCOL_UDP,localPort,tryPort,(ZT_PORTMAPPER_REFRESH_DELAY * 2) / 1000);
myTimeout = OSUtils::now() + 10000;
do {
fd_set fds;
struct timeval timeout;
FD_ZERO(&fds);
FD_SET(natpmp.s, &fds);
getnatpmprequesttimeout(&natpmp, &timeout);
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
r = readnatpmpresponseorretry(&natpmp, &response);
if (OSUtils::now() >= myTimeout)
break;
} while (r == NATPMP_TRYAGAIN);
if (r == 0) {
publicAddress.setPort(response.pnu.newportmapping.mappedpublicport);
#ifdef ZT_PORTMAPPER_TRACE
char paddr[128];
PM_TRACE("PortMapper: NAT-PMP: mapped %u to %s" ZT_EOL_S,(unsigned int)localPort,publicAddress.toString(paddr));
#endif
Mutex::Lock sl(surface_l);
surface.clear();
surface.push_back(publicAddress);
natPmpSuccess = true;
closenatpmp(&natpmp);
break;
} else {
closenatpmp(&natpmp);
// continue
}
}
if (!natPmpSuccess) {
mode = 1;
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: NAT-PMP: request failed, switching to UPnP mode" ZT_EOL_S);
#endif
}
}
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// UPnP mode
// ---------------------------------------------------------------------
if (mode == 1) {
char lanaddr[4096];
char externalip[4096]; // no range checking? so make these buffers larger than any UDP packet a uPnP server could send us as a precaution :P
char inport[16];
char outport[16];
struct UPNPUrls urls;
struct IGDdatas data;
int upnpError = 0;
UPNPDev *devlist = upnpDiscoverAll(5000,(const char *)0,(const char *)0,0,0,2,&upnpError);
if (devlist) {
#ifdef ZT_PORTMAPPER_TRACE
{
UPNPDev *dev = devlist;
while (dev) {
PM_TRACE("PortMapper: found UPnP device at URL '%s': %s" ZT_EOL_S,dev->descURL,dev->st);
dev = dev->pNext;
}
}
#endif
memset(lanaddr,0,sizeof(lanaddr));
memset(externalip,0,sizeof(externalip));
memset(&urls,0,sizeof(urls));
memset(&data,0,sizeof(data));
OSUtils::ztsnprintf(inport,sizeof(inport),"%d",localPort);
if ((UPNP_GetValidIGD(devlist,&urls,&data,lanaddr,sizeof(lanaddr)))&&(lanaddr[0])) {
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: UPnP: my LAN IP address: %s" ZT_EOL_S,lanaddr);
#endif
if ((UPNP_GetExternalIPAddress(urls.controlURL,data.first.servicetype,externalip) == UPNPCOMMAND_SUCCESS)&&(externalip[0])) {
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: UPnP: my external IP address: %s" ZT_EOL_S,externalip);
#endif
for(int tries=0;tries<60;++tries) {
int tryPort = (int)localPort + tries;
if (tryPort >= 65535)
tryPort = (tryPort - 65535) + 1025;
OSUtils::ztsnprintf(outport,sizeof(outport),"%u",tryPort);
// First check and see if this port is already mapped to the
// same unique name. If so, keep this mapping and don't try
// to map again since this can break buggy routers. But don't
// fail if this command fails since not all routers support it.
{
char haveIntClient[128]; // 128 == big enough for all these as per miniupnpc "documentation"
char haveIntPort[128];
char haveDesc[128];
char haveEnabled[128];
char haveLeaseDuration[128];
memset(haveIntClient,0,sizeof(haveIntClient));
memset(haveIntPort,0,sizeof(haveIntPort));
memset(haveDesc,0,sizeof(haveDesc));
memset(haveEnabled,0,sizeof(haveEnabled));
memset(haveLeaseDuration,0,sizeof(haveLeaseDuration));
if ((UPNP_GetSpecificPortMappingEntry(urls.controlURL,data.first.servicetype,outport,"UDP",(const char *)0,haveIntClient,haveIntPort,haveDesc,haveEnabled,haveLeaseDuration) == UPNPCOMMAND_SUCCESS)&&(uniqueName == haveDesc)) {
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: UPnP: reusing previously reserved external port: %s" ZT_EOL_S,outport);
#endif
Mutex::Lock sl(surface_l);
surface.clear();
InetAddress tmp(externalip);
tmp.setPort(tryPort);
surface.push_back(tmp);
break;
}
}
// Try to map this port
int mapResult = 0;
if ((mapResult = UPNP_AddPortMapping(urls.controlURL,data.first.servicetype,outport,inport,lanaddr,uniqueName.c_str(),"UDP",(const char *)0,"0")) == UPNPCOMMAND_SUCCESS) {
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: UPnP: reserved external port: %s" ZT_EOL_S,outport);
#endif
Mutex::Lock sl(surface_l);
surface.clear();
InetAddress tmp(externalip);
tmp.setPort(tryPort);
surface.push_back(tmp);
break;
} else {
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: UPnP: UPNP_AddPortMapping(%s) failed: %d" ZT_EOL_S,outport,mapResult);
#endif
Thread::sleep(1000);
}
}
} else {
mode = 0;
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: UPnP: UPNP_GetExternalIPAddress failed, returning to NAT-PMP mode" ZT_EOL_S);
#endif
}
} else {
mode = 0;
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: UPnP: UPNP_GetValidIGD failed, returning to NAT-PMP mode" ZT_EOL_S);
#endif
}
freeUPNPDevlist(devlist);
} else {
mode = 0;
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("PortMapper: upnpDiscover failed, returning to NAT-PMP mode: %d" ZT_EOL_S,upnpError);
#endif
}
}
// ---------------------------------------------------------------------
#ifdef ZT_PORTMAPPER_TRACE
PM_TRACE("UPNPClient: rescanning in %d ms" ZT_EOL_S,ZT_PORTMAPPER_REFRESH_DELAY);
#endif
Thread::sleep(ZT_PORTMAPPER_REFRESH_DELAY);
}
delete this;
}
volatile bool run;
int localPort;
std::string uniqueName;
Mutex surface_l;
std::vector<InetAddress> surface;
};
PortMapper::PortMapper(int localUdpPortToMap,const char *uniqueName)
{
_impl = new PortMapperImpl(localUdpPortToMap,uniqueName);
Thread::start(_impl);
}
PortMapper::~PortMapper()
{
_impl->run = false;
}
std::vector<InetAddress> PortMapper::get() const
{
Mutex::Lock _l(_impl->surface_l);
return _impl->surface;
}
} // namespace ZeroTier

62
attic/PortMapper.hpp Normal file
View File

@ -0,0 +1,62 @@
/*
* Copyright (c)2019 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2023-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_PORTMAPPER_HPP
#define ZT_PORTMAPPER_HPP
#include <vector>
#include "../node/Constants.hpp"
#include "../node/InetAddress.hpp"
#include "../node/Mutex.hpp"
#include "Thread.hpp"
/**
* How frequently should we refresh our UPNP/NAT-PnP/whatever state?
*/
#define ZT_PORTMAPPER_REFRESH_DELAY 120000
namespace ZeroTier {
class PortMapperImpl;
/**
* UPnP/NAT-PnP port mapping "daemon"
*/
class PortMapper
{
friend class PortMapperImpl;
public:
/**
* Create and start port mapper service
*
* @param localUdpPortToMap Port we want visible to the outside world
* @param name Unique name of this endpoint (based on ZeroTier address)
*/
PortMapper(int localUdpPortToMap,const char *uniqueName);
~PortMapper();
/**
* @return All current external mappings for our port
*/
std::vector<InetAddress> get() const;
private:
PortMapperImpl *_impl;
};
} // namespace ZeroTier
#endif

View File

@ -1,4 +0,0 @@
Retired Code and Miscellaneous Junk
======
This directory is for old code that isn't used but we don't want to lose track of, and for anything else random like debug scripts.

182
attic/Root.hpp Normal file
View File

@ -0,0 +1,182 @@
/*
* Copyright (c)2019 ZeroTier, Inc.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2023-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_ROOT_HPP
#define ZT_ROOT_HPP
#include "Constants.hpp"
#include "Str.hpp"
#include "ECC384.hpp"
#include "Locator.hpp"
#include "InetAddress.hpp"
#include "Utils.hpp"
#include "Identity.hpp"
#include "Mutex.hpp"
namespace ZeroTier {
/**
* A root entry pointing to a node capable of global identity lookup and indirect transit
*
* Root entries point to DNS records that contain TXT entries that decode to Locator objects
* pointing to actual root nodes. A default root identity and static addresses can also be
* provided as fallback if DNS is not available.
*
* Note that root identities can change if DNS returns a different result, but that DNS entries
* are authenticated using their own signature scheme. This allows a root DNS name to serve
* up different roots based on factors like location or relative load of different roots.
*
* It's also possible to create a root with no DNS and no DNS validator public key. This root
* will be a static entry pointing to a single root identity and set of physical addresses.
*/
class Root
{
public:
ZT_ALWAYS_INLINE Root() : _dnsPublicKeySize(0) {}
/**
* Create a new root entry
*
* @param dn DNS name
* @param dnspk DNS public key for record validation
* @param dnspksize Size of DNS public key (currently always the size of a NIST P-384 point compressed public key)
* @param dflId Default identity if DNS is not available
* @param dflAddrs Default IP addresses if DNS is not available
*/
template<typename S>
ZT_ALWAYS_INLINE Root(S dn,const uint8_t *const dnspk,const unsigned int dnspksize,const Identity &dflId,const std::vector<InetAddress> &dflAddrs) :
_defaultIdentity(dflId),
_defaultAddresses(dflAddrs),
_dnsName(dn),
_dnsPublicKeySize(dnspksize)
{
if (dnspksize != 0) {
if (dnspksize > sizeof(_dnsPublicKey))
throw ZT_EXCEPTION_INVALID_ARGUMENT;
memcpy(_dnsPublicKey,dnspk,dnspksize);
}
}
/**
* @return Current identity (either default or latest locator)
*/
ZT_ALWAYS_INLINE const Identity id() const
{
if (_lastFetchedLocator.id())
return _lastFetchedLocator.id();
return _defaultIdentity;
}
/**
* @param id Identity to check
* @return True if identity equals this root's current identity
*/
ZT_ALWAYS_INLINE bool is(const Identity &id) const
{
return ((_lastFetchedLocator.id()) ? (id == _lastFetchedLocator.id()) : (id == _defaultIdentity));
}
/**
* @return Current ZeroTier address (either default or latest locator)
*/
ZT_ALWAYS_INLINE const Address address() const
{
if (_lastFetchedLocator.id())
return _lastFetchedLocator.id().address();
return _defaultIdentity.address();
}
/**
* @return DNS name for this root or empty string if static entry with no DNS
*/
ZT_ALWAYS_INLINE const Str dnsName() const { return _dnsName; }
/**
* @return Latest locator or NIL locator object if none
*/
ZT_ALWAYS_INLINE Locator locator() const { return _lastFetchedLocator; }
/**
* @return Timestamp of latest retrieved locator or 0 if none
*/
ZT_ALWAYS_INLINE int64_t locatorTimestamp() const { return _lastFetchedLocator.timestamp(); }
/**
* Update locator, returning true if new locator is valid and newer than existing
*/
ZT_ALWAYS_INLINE bool updateLocator(const Locator &loc)
{
if (!loc.verify())
return false;
if ((loc.phy().size() > 0)&&(loc.timestamp() > _lastFetchedLocator.timestamp())) {
_lastFetchedLocator = loc;
return true;
}
return false;
}
/**
* Update this root's locator from a series of TXT records
*/
template<typename I>
ZT_ALWAYS_INLINE bool updateLocatorFromTxt(I start,I end)
{
try {
if (_dnsPublicKeySize != ZT_ECC384_PUBLIC_KEY_SIZE)
return false;
Locator loc;
if (!loc.decodeTxtRecords(start,end,_dnsPublicKey)) // also does verify()
return false;
if ((loc.phy().size() > 0)&&(loc.timestamp() > _lastFetchedLocator.timestamp())) {
_lastFetchedLocator = loc;
return true;
}
return false;
} catch ( ... ) {}
return false;
}
/**
* Pick a random physical IP for this root with the given address family
*
* @param addressFamily AF_INET or AF_INET6
* @return Address or InetAddress::NIL if no addresses exist for the given family
*/
ZT_ALWAYS_INLINE const InetAddress &pickPhysical(const int addressFamily) const
{
std::vector<const InetAddress *> pickList;
const std::vector<InetAddress> *const av = (_lastFetchedLocator) ? &(_lastFetchedLocator.phy()) : &_defaultAddresses;
for(std::vector<InetAddress>::const_iterator i(av->begin());i!=av->end();++i) {
if (addressFamily == (int)i->ss_family) {
pickList.push_back(&(*i));
}
}
if (pickList.size() == 1)
return *pickList[0];
else if (pickList.size() > 1)
return *pickList[(unsigned long)Utils::random() % (unsigned long)pickList.size()];
return InetAddress::NIL;
}
private:
Identity _defaultIdentity;
std::vector<InetAddress> _defaultAddresses;
Str _dnsName;
Locator _lastFetchedLocator;
unsigned int _dnsPublicKeySize;
uint8_t _dnsPublicKey[ZT_ECC384_PUBLIC_KEY_SIZE];
};
} // namespace ZeroTier
#endif

9
attic/cycle_controllers.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
CONTROLLERS=`kubectl get pods -o=name | grep controller | sed "s/^.\{4\}//"`
for c in ${CONTROLLERS[@]}
do
kubectl delete pod ${c}
sleep 30
done

View File

@ -1,32 +0,0 @@
#!/bin/bash
export PATH=/bin:/usr/bin
if [ ! -e /usr/bin/openssl ]; then
echo $0: requires /usr/bin/openssl, please install openssl tools
exit 1
fi
if [ "$#" -lt 1 ]; then
echo $0: Usage: $0 '<input>' '[output]'
exit 1
fi
if [ ! -r "$1" ]; then
echo $0: $1 does not exist or is not readable.
exit 1
fi
outpath=`echo "$1" | sed 's/[.]aes$//'`
if [ "$#" -ge 2 ]; then
outpath="$2"
fi
if [ -f "$outpath" ]; then
echo $0: $outpath already exists, delete or rename first.
exit 1
fi
openssl aes-256-cbc -d -salt -in "$1" -out "$outpath"
echo $0: wrote "$outpath"

View File

@ -1,32 +0,0 @@
#!/bin/bash
export PATH=/bin:/usr/bin
if [ ! -e /usr/bin/openssl ]; then
echo $0: requires /usr/bin/openssl, please install openssl tools
exit 1
fi
if [ "$#" -lt 1 ]; then
echo $0: Usage: $0 '<input>' '[output]'
exit 1
fi
if [ ! -r "$1" ]; then
echo $0: $1 does not exist or is not readable.
exit 1
fi
outpath="$1.aes"
if [ "$#" -ge 2 ]; then
outpath="$2"
fi
if [ -f "$outpath" ]; then
echo $0: $outpath already exists, delete or rename first.
exit 1
fi
openssl aes-256-cbc -salt -in "$1" -out "$outpath"
echo $0: wrote "$outpath"

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,17 @@
CC=gcc
CXX=g++
#ARCH_FLAGS=-arch x86_64 -arch i386 -arch ppc
DEFS=-DHAS_DEV_URANDOM
CXXDEFS=-DBOOST_DISABLE_ASSERTS -DBOOST_NO_TYPEID -DNDEBUG
CFLAGS=-mmacosx-version-min=10.4 -std=c99 -O6 -ftree-vectorize -Wall $(DEFS) $(ARCH_FLAGS)
CXXFLAGS=-mmacosx-version-min=10.4 -Drestrict=__restrict__ -O6 -ftree-vectorize -Wall $(DEFS) $(CXXDEFS) $(ARCH_FLAGS)
LDFLAGS=-mmacosx-version-min=10.4 $(ARCH_FLAGS)
DLLFLAGS=$(ARCH_FLAGS) -shared
DLLEXT=dylib
LIBANODE_LIBS=-lcrypto -lpthread -lresolv
LIBSPARK_LIBS=-lz

View File

@ -0,0 +1,17 @@
CC=gcc
CXX=g++
DEFS=-DHAS_DEV_URANDOM
CFLAGS=-std=c99 -O6 -fPIC -Wall $(DEFS)
CXXFLAGS=-Drestrict=__restrict__ -O6 -Wall $(DEFS) -I..
#CFLAGS=-g -Wall $(DEFS)
#CXXFLAGS=-g -Wall $(DEFS)
LDFLAGS=
DLLFLAGS=-shared
DLLEXT=so
LIBANODE_LIBS=-lcrypto -lresolv -pthread
LIBSPARK_LIBS=-lz

View File

@ -0,0 +1,764 @@
*****************************************************************************
Anode Protocol Specification Draft
Version 0.8
(c)2009-2010 Adam Ierymenko
*****************************************************************************
Table of Contents
*****************************************************************************
1. Introduction
Anode provides three components that work together to provide a global,
secure, and mobile addressing system for computer networks:
1) An addressing system based on public key cryptography enabling network
devices or applications to assign themselves secure, unique, and globally
reachable network addresses in a flat address space.
2) A system enabling network participants holding global addresses to locate
one another on local or global networks with "zero configuration."
3) A communications protocol for communication between addressed network
participants that requires no special operating system support and no
changes to existing network infrastructure.
Using Anode, both fixed and mobile applications and devices can communicate
directly as if they were all connected to the same VPN. Anode restores the
original vision of the Internet as a "flat" network where anything can talk
to anything, and adds the added benefits of address mobility and strong
protection against address spoofing and other protocol level attacks.
1.1. Design Philosophy
Anode's design philosophy is the classical "KISS" principle: "Keep It Simple
Stupid." Anode's design principles are:
#1: Do not try to solve too many problems at once, and stay in scope.
Anode does not attempt to solve too many problems at once. It attempts to
solve the problems of mobile addressing, address portability, and "flat"
addressing in the presence of NAT or other barriers.
It does not attempt to duplicate the full functionality of SSL, X.509, SSH,
XMPP, an enterprise service bus, a pub/sub architecture, BitTorrent, etc. All
of those protocols and services can be used over Anode if their functionality
is desired.
#2: Avoid state management.
State multiplies the complexity and failure modes of network protocols. State
also tends to get in the way of the achievement of new features implicitly
(see principle #4). Avoid state whenever possible.
#3: Avoid algorithm and dependency bloat.
Anode uses only elliptic curve Diffie-Hellman (EC-DH) and AES-256. No other
cryptographic algorithms or hash functions are presently necessary. This
yields implementations compact enough for embedded devices.
Anode also requires few or no dependencies, depending on whether the two
needed cryptographic algorithms are obtained through a library or included.
No other protocols or libraries are required in an implementation.
#4: Achieve features implicitly.
Use a simple stateless design that allows features to be achieved implicitly
rather than specified explicitly. For example, Anode can do multi-homing and
could be used to build a mesh network, but neither of these features is
explicitly specified.
*****************************************************************************
2. Core Concepts and Algorithms
This section describes addresses, zones, common algorithms, and other core
concepts.
2.1. Zones
A zone is a 32-bit integer encoded into every Anode address. Zones serve to
assist in the location of peers by address on global IP networks. They are
not presently significant for local communications, though they could be
used to partition addresses into groups or link them with configuration
options.
Each zone has a corresponding zone file which can be fetched in a number of
ways (see below). A zone file is a flat text format dictionary of the format
"key=value" separated by carriage returns. Line feeds are ignored, and any
character may be escaped with a backslash (\) character. Blank lines are
ignored.
The following entries must appear in a zone file:
n=<zone name>
d=<zone description>
c=<zone contact, e-mail address of zone administrator>
r=<zone revision, monotonically increasing integer with each edit>
ttl=<seconds before zone file should be re-checked for changes>
Additional fields may appear as well, including fields specific to special
applications or protocols supported within the zone. Some of these are
defined in this document.
Zone file fetching mechanisms are described below. Multiple mechanisms are
specified to enable fallback in the event that one mechanism is not available.
2.1.1. Zone File Retrieval
Zone files are retrieved via HTTP, with the HTTP address being formed in one
of two ways.
The preferred DNS method:
To fetch a zone file via DNS, use the zone ID to generate a host name and URI
of the form:
http://a--XXXXXXXX.net/z
The XXXXXXXX field is the zone ID in hexadecimal.
The fallback IP method:
For fallback in the absence of DNS, the zone ID can be used directly as an
IPv4 or IPv4-mapped-to-IPv6 IP address. A URI is generated of the form:
http://ip_address/z
Support for this method requires that a zone ID be chosen to correspond to a
permanent IPv4 (preferably mappable to IPv6 space as well) IP address.
2.1.2. Zone ID Reservation
By convention, a zone ID is considered reserved when a domain of the form
"a--XXXXXXXX.net" (where XXXXXXXX is the ID in hex) is registered.
It is recommended that this be done even for zone IDs not used for global
address location in order to globally reserve them.
2.2. Addresses
Anode addresses are binary strings containing a 32-bit zone ID, a public key,
and possibly other fields. Only one address type is presently defined:
|---------------------------------------------------------------------------|
| Name | Type ID | Elliptic Curve Parameters | Total Length |
|---------------------------------------------------------------------------|
| ANODE-256-40 | 1 | NIST-P-256 | 40 |
|---------------------------------------------------------------------------|
|---------------------------------------------------------------------------|
| Name | Binary Layout |
|---------------------------------------------------------------------------|
| ANODE-256-40 | <type[1]><zone[4]><unused[2]><public key[33]> |
|---------------------------------------------------------------------------|
The public key is a "compressed" form elliptic curve public key as described
in RFC5480.
The unused section of the address must be zero. These bytes are reserved for
future use.
2.2.1. ASCII Format For Addresses
Addresses are encoded in ASCII using base-32, which provides a quotable and
printable encoding that is of manageable length and is case-insensitive. For
example, an ANODE-256-40 address is 64 characters long in base-32 encoding.
2.3. Relaying
An Anode peer may optionally relay packets to any other reachable peer.
Relaying is accomplished by sending a packet to a peer with the recipient set
to the final recipient. The receiving peer will, if relaying is allowed and if
it knows of or can reach the recipient, forward the packet.
No error is returned if relaying fails, so relay paths are treated as possible
paths for communication until a return is received in the same way as direct
paths.
Relaying can be used by peers to send messages indirectly, locate one
another, and determine network location information to facilitate the
establishment of direct communications.
Peers may refuse to relay or may limit the transmission rate at which packets
can be relayed.
2.3.1. Zone Relays
If a zone's addresses are globally reachable on global IP networks, it must
have one or more zone relays. These must have globally reachable public
static IP addresses.
Zone relays are specified in the zone file in the following format:
zr.<address checksum>=<ip>[,<ip>]:<udp port>:<tcp port>:<anode addresses>
The address checksum is the sum of the bytes in the Anode address modulus
the number of "zr" entries, in hexadecimal. For example, if a zone had four
global relays its zone file could contain the lines:
zr.0=1.2.3.4:4343:4344:klj4j3...
zr.1=2.3.4.5:4343:4344:00194j...
zr.2=3.4.5.6:4343:4344:1j42zz...
zr.3=4.5.6.7:4343:4344:z94j1q...
The relay would be chosen by taking the sum of the bytes in the address
modulo 4. For example, if the bytes of an address sum to 5081 then relay
zr.1 would be used to communicate with that address.
If more than one IP address is listed for a given relay, the peer must choose
at random from among the addresses of the desired type (IPv4 or IPv6).
Each relay must have one Anode address for every address type supported within
the zone. (At present there is only one address type defined.)
Peers should prefer UDP and fall back to TCP only if UDP is not available.
To make itself available, a peer must make itself known to its designated zone
relay. This is accomplished by sending a PING message.
2.4. Key Agreement and Derivation
Key agreement is performed using elliptic curve Diffie-Hellman. This yields
a raw key whose size depends on the elliptic curve parameters in use.
The following algorithm is used to derive a key of any length from a raw
key generated through key agreement:
1) Zero the derived key buffer.
2) Determine the largest of the original raw key or the derived key.
3) Loop from 0 to the largest length determined in step 2, XOR each byte of
the derived key buffer with the corresponding byte of the original key
buffer with each index being modulus the length of the respective buffer.
2.5. Message Authentication
For message authentication, CMAC-AES (with AES-256) is used. This is also
known in some literature as OMAC1-AES. The key is derived from key agreement
between the key pair of the sending peer and the address of the recipient.
2.6. AES-DIGEST
To maintain cryptographic algorithm frugality, a cryptographic hash function
is constructed from the AES-256 cipher. This hash function uses the common
Davis-Meyer construction with Merkle-Damgård length padding.
It is described by the following pseudocode:
byte previous_digest[16]
byte digest[16] = { 0,0,... }
byte block[32] = { 0,0,... }
integer block_counter = 0
; digest message
for each byte b of message
block[block_counter] = b
block_counter = block_counter + 1
if block_counter == 32 then
block_counter = 0
save digest[] in previous_digest[]
encrypt digest[] with aes-256 using block[] as 256-bit aes-256 key
xor digest[] with previous_digest[]
end if
next
; append end marker, do final block
block[block_counter] = 0x80
block_counter = block_counter + 1
zero rest of block[] from block_counter to 15
save digest[] in previous_digest[]
encrypt digest[] with aes-256 using block[] as 256-bit aes-256 key
xor digest[] with previous_digest[]
; Merkle-Damgård length padding
zero first 8 bytes of block[]
fill last 8 bytes of block[] w/64-bit length in big-endian order
save digest[] in previous_digest[]
encrypt digest[] with aes-256 using block[] as 256-bit aes-128 key
xor digest[] with previous_digest[]
; digest[] now contains 128-bit message digest
2.7. Short Address Identifiers (Address IDs)
A short 8-byte version of the Anode address is used in the protocol to reduce
transmission overhead when both sides are already aware of the other's full
address.
The short address identifier is formed by computing the AES-DIGEST of the
full address and then XORing the first 8 bytes of the digest with the last
8 bytes to yield an 8-byte shortened digest.
2.8. DNS Resolution of Anode Addresses
Anode addresses can be saved in DNS TXT records in the following format:
anode:<address in base32 ASCII encoding>
This permits Anode addresses to be resolved from normal DNS host name.
2.9. Packet Transmission Mechanisms
2.9.1. UDP Transmission
The recommended method of sending Anode packets is UDP. Each packet is simply
sent as a UDP packet.
2.9.2. TCP Transmission
To send packets over TCP, each packet is prefixed by its size as a 16-bit
integer.
2.9.3. HTTP Transmission
Anode packets may be submitted in HTTP POST transactions for transport over
networks where HTTP is the only available protocol.
Anode packets are simply prefixed with a 16-byte packet size and concatenated
together just as they are in a TCP stream. One or more packets may be sent
with each HTTP POST transaction for improved performance.
Since this method is intended for use in "hostile" or highly restricted
circumstances, no additional details such as special headers or MIME types
are specified to allow maximum flexibility. Peers should ignore anything
other than the payload.
2.10. Endpoints
An endpoint indicates a place where Anode packets may be sent. The following
endpoint types are specified:
|---------------------------------------------------------------------------|
| Endpoint Type | Description | Address Format |
|---------------------------------------------------------------------------|
| 0x00 | Unspecified | (none) |
| 0x01 | Ethernet | <mac[6]> |
| 0x02 | UDP/IPv4 | <ip[4]><port[2]> |
| 0x03 | TCP/IPv4 | <ip[4]><port[2]> |
| 0x04 | UDP/IPv6 | <ip[16]><port[2]> |
| 0x05 | TCP/IPv6 | <ip[16]><port[2]> |
| 0x06 | HTTP | <null-terminated full URI> |
|---------------------------------------------------------------------------|
Endpoints are encoded by beginning with a single byte indicating the endpoint
type followed by the address information required for the given type.
Note that IP ports bear no relationship to Anode protocol ports.
2.11. Notes
All integers in the protocol are transmitted in network (big endian) byte
order.
*****************************************************************************
3. Common Packet Format
A common header is used for all Anode packets:
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Hop Count | 1 | 8-bit hop count (not included in MAC) |
| Flags | 1 | 8-bit flags |
| MAC | 8 | 8 byte shortened CMAC-AES of packet |
| Sender Address | ? | Full address or short ID of sender |
| Recipient Address | ? | Full address or short ID of recipient |
| Peer IDs | 1 | Two 4-bit peer IDs: sender, recipient |
| Message Type | 1 | 8-bit message type |
| Message | ? | Message payload |
|---------------------------------------------------------------------------|
3.1. Hop Count
The hop count begins at zero and must be incremented by each peer that relays
the packet to another peer. The hop count must not wrap to zero at 255.
Because the hop count is modified in transit, it is not included in MAC
calculation or authentication.
The hop count is used to prioritize endpoints that are direct over endpoints
that involve relaying, or to prioritize closer routes over more distant
ones.
3.2. Flags and Flag Behavior
|---------------------------------------------------------------------------|
| Flag | Description |
|---------------------------------------------------------------------------|
| 0x01 | Sender address fully specified |
| 0x02 | Recipient address fully specified |
| 0x04 | Authentication error response |
|---------------------------------------------------------------------------|
If flag 0x01 is set, then the sender address will be the full address rather
than a short address identifier. The length of the address can be determined
from the first byte of the address, which always specifies the address type.
Flag 0x02 has the same meaning for the recipient address.
A peer must send fully specified sender addresses until it receives a response
from the recipient. At this point the sender may assume that the recipient
knows its address and use short a short sender address instead. This
assumption should time out, with a recommended timeout of 60 seconds.
There is presently no need to send fully specified recipient addresses, but
the flag is present in case it is needed and must be honored.
Flag 0x04 indicates that this is an error response containing a failed
authentication error. Since authentication failed, this packet may not have
a valid MAC. Packets with this flag must never have any effect other than
to inform of an error. This error, since it is unauthenticated, must never
have any side effects such as terminating a connection.
3.3. MAC
The MAC is calculated as follows:
1) Temporarily set the 64-bit/8-byte MAC field in the packet to the packet's
size as a 64-bit big-endian integer.
2) Calculate the MAC for the entire packet (excluding the first byte) using
the key agreed upon between the sender and the recipient, resulting in a
16 byte full CMAC-AES MAC.
3) Derive the 8 byte packet MAC by XORing the first 8 bytes of the full 16
byte CMAC-AES MAC with the last 8 bytes. Place this into the packet's MAC
field.
3.4. Peer IDs
Peer IDs provide a method for up to 15 different peers to share an address,
each with a unique ID allowing packets to be routed to them individually.
A peer ID of zero indicates "any" or "unspecified." Real peers must have a
nonzero peer ID. In the normal single peer per address case, any peer ID may
be used. If multiple peers are to share an address, some implementation-
dependent method must be used to ensure that each peer has a unique peer ID.
Relaying peers must follow these rules based on the recipient peer ID when
relaying messages:
- IF the peer ID is zero or if the peer ID is not known, the message must
be forwarded to a random endpoint for the given recipient address.
- IF the peer ID is nonzero and matches one or more known endpoints for the
given recipient address and peer ID, the message must only be sent to
a matching endpoint.
A receiving peer should process any message that it receives regardless of
whether its recipient peer ID is correct. The peer ID is primarily for relays.
Peers should typically send messages with a nonzero recipient peer ID when
responding to or involved in a conversation with a specific peer (e.g. a
streaming connection), and send zero recipient peer IDs otherwise.
3.5. Short Address Conflict Disambiguation
In the unlikely event of two Anode addresses with the same short identifier,
the recipient should use MAC validation to disambiguate. The peer ID must not
be relied upon for this purpose.
*****************************************************************************
4. Basic Signaling and Transport Protocol
4.1. Message Types
|---------------------------------------------------------------------------|
| Type | ID | Description |
|---------------------------------------------------------------------------|
| ERROR | 0x00 | Error response |
| PING | 0x01 | Echo request |
| PONG | 0x02 | Echo response |
| EPC_REQ | 0x03 | Endpoint check request |
| EPC | 0x04 | Endpoint check response |
| EPI | 0x05 | Endpoint information |
| NAT_T | 0x06 | NAT traversal message |
| NETID_REQ | 0x07 | Request network address identification and/or test |
| NETID | 0x08 | Response to network address identification request |
| DGRAM | 0x09 | Simple UDP-like datagram |
|---------------------------------------------------------------------------|
4.2. Message Details
4.2.1. ERROR
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Error Code | 2 | 16-bit error code |
| Error Arguments | ? | Error arguments, depending on error type |
|---------------------------------------------------------------------------|
Error arguments are empty unless otherwise stated below.
Error codes:
|---------------------------------------------------------------------------|
| Error Code | Description |
|---------------------------------------------------------------------------|
| 0x01 | Message not valid |
| 0x02 | Message authentication or decryption failed |
| 0x03 | Relaying and related features not authorized |
| 0x04 | Relay recipient not reachable |
|---------------------------------------------------------------------------|
Generation of errors is optional. A peer may choose to ignore invalid
messages or to throttle the sending of errors.
4.2.2. PING
(Payload unspecified.)
Request echo of payload as PONG message.
4.2.3. PONG
(Payload unspecified.)
Echoed payload of received PING message.
4.2.4. EPC_REQ
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Request ID | 4 | 32-bit request ID |
|---------------------------------------------------------------------------|
Request echo of request ID in EPC message, used to check and learn endpoints.
To learn a network endpoint for a peer, CHECK_REQ is sent. If CHECK is
returned with a valid request ID, the endpoint is considered valid.
4.2.5. EPC
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Request ID | 4 | 32-bit request ID echoed back |
|---------------------------------------------------------------------------|
Response to EPC_REQ containing request ID.
4.2.6. EPI
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Flags | 1 | 8-bit flags |
| Endpoint | ? | Endpoint type and address |
| NAT-T mode | 1 | 8-bit NAT traversal mode |
| NAT-T options | ? | Options related to specified NAT-T mode |
|---------------------------------------------------------------------------|
EPI stands for EndPoint Identification, and is sent to notify another peer of
a network endpoint where the sending peer is reachable.
If the receiving peer is interested in communicating with the sending peer,
the receiving peer must send EPC_REQ to the sending peer at the specified
endpoint to check the validity of that endpoint. The endpoint is learned if a
valid EPC is returned.
If the endpoint in EPI is unspecified, the actual source of the EPI message
is the endpoint. This allows EPI messages to be broadcast on a local LAN
segment to advertise the presence of an address on a local network. EPI
broadcasts on local IP networks must be made to UDP port 8737.
Usually EPI is sent via relays (usually zone relays) to inform a peer of an
endpoint for direct communication.
There are presently no flags, so flags must be zero.
4.2.7. NAT_T
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| NAT-T mode | 1 | 8-bit NAT traversal mode |
| NAT-T options | ? | Options related to specified NAT-T mode |
|---------------------------------------------------------------------------|
NAT_T is used to send messages specific to certain NAT traversal modes.
4.2.8. NETID_REQ
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Request ID | 4 | 32-bit request ID |
| Endpoint | ? | Endpoint type and address information |
|---------------------------------------------------------------------------|
When a NETID_REQ message is received, the recipient attempts to echo it back
as a NETID message to the specified endpoint address. If the endpoint is
unspecified, the recipient must fill it in with the actual origin of the
NETID_REQ message. This allows a peer to cooperate with another peer (usually
a zone relay) to empirically determine its externally visible network
address information.
A peer may ignore NETID_REQ or respond with an error if it does not allow
relaying.
4.2.9. NETID
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Request ID | 4 | 32-bit request ID echoed back |
| Endpoint Type | 1 | 8-bit endpoint type |
| Endpoint Address | ? | Endpoint Address (size depends on type) |
|---------------------------------------------------------------------------|
NETID is sent in response to NETID_REQ to the specified endpoint address. It
always contains the endpoint address to which it was sent.
4.2.10. DGRAM
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Source Port | 2 | 16-bit source port |
| Destination Port | 2 | 16-bit destination port |
| Payload | ? | Datagram packet payload |
|---------------------------------------------------------------------------|
A datagram is a UDP-like message without flow control or delivery assurance.
*****************************************************************************
5. Stream Protocol
The stream protocol is very similar to TCP, though it omits some features
that are not required since they are taken care of by the encapsulating
protocol. SCTP was also an inspiration in the design.
5.1. Message Types
|---------------------------------------------------------------------------|
| Type | ID | Description |
|---------------------------------------------------------------------------|
| S_OPEN | 20 | Initiate a streaming connection (like TCP SYN) |
| S_CLOSE | 21 | Terminate a streaming connection (like TCP RST/FIN) |
| S_DATA | 22 | Data packet |
| S_ACK | 23 | Acknowedge receipt of one or more data packets |
| S_DACK | 24 | Combination of DATA and ACK |
|---------------------------------------------------------------------------|
5.2. Message Details
5.2.1. S_OPEN
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Sender Link ID | 2 | 16-bit sender link ID |
| Destination Port | 2 | 16-bit destination port |
| Window Size | 2 | 16-bit window size in 1024-byte increments |
| Init. Seq. Number | 4 | 32-bit initial sequence number |
| Flags | 1 | 8-bit flags |
|---------------------------------------------------------------------------|
The OPEN message corresponds to TCP SYN, and initiates a connection. It
specifies the initial window size for the sender and the sender's initial
sequence number, which should be randomly chosen to prevent replay attacks.
If OPEN is successful, the recipient sends its own OPEN to establish the
connetion. If OPEN is unsuccessful, CLOSE is sent with its initial and current
sequence numbers equal and an appropriate reason such as "connection refused."
The sender link ID must be unique for a given recipient.
If flag 01 is set, the sender link ID is actually a source port where the
sender might be listening for connections as well. This exactly duplicates
the behavior of standard TCP. Otherwise, the sender link ID is simply an
arbitrary number that the sender uses to identify the connection with this
recipient and there is no port of origin. Ports of origin are optional for
Anode streaming connections to permit greater scalability.
5.2.2. S_CLOSE
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Sender Link ID | 2 | 16-bit sender link ID |
| Destination Port | 2 | 16-bit destination port |
| Flags | 1 | 8-bit flags |
| Reason | 1 | 8-bit close reason |
| Init. Seq. Number | 4 | 32-bit initial sequence number |
| Sequence Number | 4 | 32-bit current sequence number |
|---------------------------------------------------------------------------|
The CLOSE message serves a function similar to TCP FIN. The initial sequence
number is the original starting sequence number sent with S_OPEN, while the
current sequence number is the sequence number corresponding to the close
and must be ACKed to complete the close operation. The use of the initial
sequence number helps to serve as a key to prevent replay attacks.
CLOSE is also used to indicate a failed OPEN attempt. In this case the current
sequence number will be equal to the initial sequence number and no ACK will
be expected.
There are currently no flags, so flags must be zero.
The reason field describes the reason for the close:
|---------------------------------------------------------------------------|
| Reason Code | Description |
|---------------------------------------------------------------------------|
| 00 | Application closed connection |
| 01 | Connection refused |
| 02 | Protocol error |
| 03 | Timed out |
|---------------------------------------------------------------------------|
Established connections will usually be closed with reason 00, while reason
01 is usually provided if an OPEN is received but the port is not bound.
5.2.3. S_DATA
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Sender Link ID | 2 | 16-bit sender link ID |
| Destination Port | 2 | 16-bit destination port |
| Sequence Number | 4 | 32-bit sequence number |
| Payload | ? | Data payload |
|---------------------------------------------------------------------------|
The DATA message carries a packet of data, with the sequence number
determining order. The sequence number is monotonically incremented with
each data packet, and wraps at the maximum value of an unsigned 32-bit
integer.
5.2.4. S_ACK
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Sender Link ID | 2 | 16-bit sender link ID |
| Destination Port | 2 | 16-bit destination port |
| Window Size | 2 | 16-bit window size in 1024-byte increments |
| Acknowledgements | ? | One or more acknowledgements (see below) |
|---------------------------------------------------------------------------|
Each acknowledgement is a 32-bit integer followed by an 8-bit integer (5 bytes
total). The 32-bit integer is the first sequence number to acknowledge, and
the 8-bit integer is the number of sequential following sequence numbers to
acknowledge. For example "1, 4" would acknowledge sequence numbers 1, 2, 3,
and 4.
5.2.5. S_DACK
|---------------------------------------------------------------------------|
| Field | Length | Description |
|---------------------------------------------------------------------------|
| Sender Link ID | 2 | 16-bit sender link ID |
| Destination Port | 2 | 16-bit destination port |
| Window Size | 2 | 16-bit window size in 1024-byte increments |
| Num. Acks | 1 | 8-bit number of acknowledgements |
| Acknowledgements | ? | One or more acknowledgements |
| Payload | ? | Data payload |
|---------------------------------------------------------------------------|
The DACK message combines ACK and DATA, allowing two peers that are both
transmitting data to efficiently ACK without a separate packet.

View File

@ -0,0 +1,33 @@
SYSNAME:=${shell uname}
SYSNAME!=uname
include ../config.mk.${SYSNAME}
LIBANODE_OBJS= \
impl/aes.o \
impl/dictionary.o \
impl/dns_txt.o \
impl/ec.o \
impl/environment.o \
impl/misc.o \
impl/thread.o \
address.o \
aes_digest.o \
errors.o \
identity.o \
network_address.o \
secure_random.o \
system_transport.o \
uri.o
# zone.o
all: $(LIBANODE_OBJS)
ar rcs libanode.a $(LIBANODE_OBJS)
ranlib libanode.a
$(CC) $(CFLAGS) -o utils/anode-make-identity utils/anode-make-identity.c $(LIBANODE_OBJS) $(LIBANODE_LIBS)
clean: force
rm -f $(LIBANODE_OBJS)
rm -f libanode.$(DLLEXT) libanode.a
rm -f utils/anode-make-identity
force: ;

View File

@ -0,0 +1,98 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "impl/aes.h"
#include "impl/ec.h"
#include "impl/misc.h"
#include "impl/types.h"
#include "anode.h"
int AnodeAddress_calc_short_id(
const AnodeAddress *address,
AnodeAddressId *short_address_id)
{
unsigned char digest[16];
switch(AnodeAddress_get_type(address)) {
case ANODE_ADDRESS_ANODE_256_40:
Anode_aes_digest(address->bits,ANODE_ADDRESS_LENGTH_ANODE_256_40,digest);
break;
default:
return ANODE_ERR_ADDRESS_INVALID;
}
*((uint64_t *)short_address_id->bits) = ((uint64_t *)digest)[0] ^ ((uint64_t *)digest)[1];
return 0;
}
int AnodeAddress_get_zone(const AnodeAddress *address,AnodeZone *zone)
{
switch(AnodeAddress_get_type(address)) {
case ANODE_ADDRESS_ANODE_256_40:
*((uint32_t *)&(zone->bits[0])) = *((uint32_t *)&(address->bits[1]));
return 0;
}
return ANODE_ERR_ADDRESS_INVALID;
}
int AnodeAddress_to_string(const AnodeAddress *address,char *buf,int len)
{
const unsigned char *inptr;
char *outptr;
unsigned int i;
switch(AnodeAddress_get_type(address)) {
case ANODE_ADDRESS_ANODE_256_40:
if (len < (((ANODE_ADDRESS_LENGTH_ANODE_256_40 / 5) * 8) + 1))
return ANODE_ERR_BUFFER_TOO_SMALL;
inptr = (const unsigned char *)address->bits;
outptr = buf;
for(i=0;i<(ANODE_ADDRESS_LENGTH_ANODE_256_40 / 5);++i) {
Anode_base32_5_to_8(inptr,outptr);
inptr += 5;
outptr += 8;
}
*outptr = (char)0;
return ((ANODE_ADDRESS_LENGTH_ANODE_256_40 / 5) * 8);
}
return ANODE_ERR_ADDRESS_INVALID;
}
int AnodeAddress_from_string(const char *str,AnodeAddress *address)
{
const char *blk_start = str;
const char *ptr = str;
unsigned int address_len = 0;
while (*ptr) {
if ((unsigned long)(ptr - blk_start) == 8) {
if ((address_len + 5) > sizeof(address->bits))
return ANODE_ERR_ADDRESS_INVALID;
Anode_base32_8_to_5(blk_start,(unsigned char *)&(address->bits[address_len]));
address_len += 5;
blk_start = ptr;
}
++ptr;
}
if (ptr != blk_start)
return ANODE_ERR_ADDRESS_INVALID;
if (AnodeAddress_get_type(address) != ANODE_ADDRESS_ANODE_256_40)
return ANODE_ERR_ADDRESS_INVALID;
return 0;
}

View File

@ -0,0 +1,85 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "anode.h"
#include "impl/aes.h"
#include "impl/misc.h"
#include "impl/types.h"
void Anode_aes_digest(const void *const message,unsigned long message_len,void *const hash)
{
unsigned char previous_digest[16];
unsigned char digest[16];
unsigned char block[32];
const unsigned char *in = (const unsigned char *)message;
const unsigned char *end = in + message_len;
unsigned long block_counter;
AnodeAesExpandedKey expkey;
((uint64_t *)digest)[0] = 0ULL;
((uint64_t *)digest)[1] = 0ULL;
((uint64_t *)block)[0] = 0ULL;
((uint64_t *)block)[1] = 0ULL;
((uint64_t *)block)[2] = 0ULL;
((uint64_t *)block)[3] = 0ULL;
/* Davis-Meyer hash function built from block cipher */
block_counter = 0;
while (in != end) {
block[block_counter++] = *(in++);
if (block_counter == 32) {
block_counter = 0;
((uint64_t *)previous_digest)[0] = ((uint64_t *)digest)[0];
((uint64_t *)previous_digest)[1] = ((uint64_t *)digest)[1];
Anode_aes256_expand_key(block,&expkey);
Anode_aes256_encrypt(&expkey,digest,digest);
((uint64_t *)digest)[0] ^= ((uint64_t *)previous_digest)[0];
((uint64_t *)digest)[1] ^= ((uint64_t *)previous_digest)[1];
}
}
/* Davis-Meyer end marker */
block[block_counter++] = 0x80;
while (block_counter != 32) block[block_counter++] = 0;
((uint64_t *)previous_digest)[0] = ((uint64_t *)digest)[0];
((uint64_t *)previous_digest)[1] = ((uint64_t *)digest)[1];
Anode_aes256_expand_key(block,&expkey);
Anode_aes256_encrypt(&expkey,digest,digest);
((uint64_t *)digest)[0] ^= ((uint64_t *)previous_digest)[0];
((uint64_t *)digest)[1] ^= ((uint64_t *)previous_digest)[1];
/* Merkle-Damgård length padding */
((uint64_t *)block)[0] = 0ULL;
if (sizeof(message_len) >= 8) { /* 32/64 bit? this will get optimized out */
block[8] = (uint8_t)((uint64_t)message_len >> 56);
block[9] = (uint8_t)((uint64_t)message_len >> 48);
block[10] = (uint8_t)((uint64_t)message_len >> 40);
block[11] = (uint8_t)((uint64_t)message_len >> 32);
} else ((uint32_t *)block)[2] = 0;
block[12] = (uint8_t)(message_len >> 24);
block[13] = (uint8_t)(message_len >> 16);
block[14] = (uint8_t)(message_len >> 8);
block[15] = (uint8_t)message_len;
((uint64_t *)previous_digest)[0] = ((uint64_t *)digest)[0];
((uint64_t *)previous_digest)[1] = ((uint64_t *)digest)[1];
Anode_aes256_expand_key(block,&expkey);
Anode_aes256_encrypt(&expkey,digest,digest);
((uint64_t *)digest)[0] ^= ((uint64_t *)previous_digest)[0];
((uint64_t *)digest)[1] ^= ((uint64_t *)previous_digest)[1];
((uint64_t *)hash)[0] = ((uint64_t *)digest)[0];
((uint64_t *)hash)[1] = ((uint64_t *)digest)[1];
}

View File

@ -0,0 +1,795 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_ANODE_H
#define _ANODE_ANODE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NULL
#define NULL ((void *)0)
#endif
#define ANODE_ADDRESS_LENGTH_ANODE_256_40 40
#define ANODE_ADDRESS_MAX_LENGTH 40
#define ANODE_ADDRESS_SECRET_LENGTH_ANODE_256_40 32
#define ANODE_ADDRESS_MAX_SECRET_LENGTH 32
#define ANODE_ADDRESS_ID_LENGTH 8
#define ANODE_ZONE_LENGTH 4
#define ANODE_ERR_NONE 0
#define ANODE_ERR_INVALID_ARGUMENT (-10000)
#define ANODE_ERR_OUT_OF_MEMORY (-10001)
#define ANODE_ERR_INVALID_URI (-10002)
#define ANODE_ERR_BUFFER_TOO_SMALL (-10003)
#define ANODE_ERR_ADDRESS_INVALID (-10010)
#define ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED (-10011)
#define ANODE_ERR_CONNECTION_CLOSED (-10012)
#define ANODE_ERR_CONNECTION_CLOSED_BY_REMOTE (-10013)
#define ANODE_ERR_CONNECT_FAILED (-10014)
#define ANODE_ERR_UNABLE_TO_BIND (-10015)
#define ANODE_ERR_TOO_MANY_OPEN_SOCKETS (-10016)
#define ANODE_ERR_DNS_NAME_NOT_FOUND_OR_TIMED_OUT (-10017)
/**
* Get a human-readable error description for an error code
*
* The value of 'err' can be either negative or positive.
*
* @param err Error code
* @return Human-readable description
*/
extern const char *Anode_strerror(int err);
/* ----------------------------------------------------------------------- */
/* Secure random source */
/* ----------------------------------------------------------------------- */
/**
* Opaque secure random instance
*/
typedef void AnodeSecureRandom;
/**
* Initialize a secure random source
*
* No cleanup/destructor is necessary.
*
* @param srng Random structure to initialize
*/
extern AnodeSecureRandom *AnodeSecureRandom_new();
/**
* Generate random bytes
*
* @param srng Secure random source
* @param buf Buffer to fill
* @param count Number of bytes to generate
*/
extern void AnodeSecureRandom_gen_bytes(AnodeSecureRandom *srng,void *buf,long count);
/**
* Destroy and free a secure random instance
*
* @param srng Secure random source
*/
extern void AnodeSecureRandom_delete(AnodeSecureRandom *srng);
/* ----------------------------------------------------------------------- */
/* AES-256 derived Davis-Meyer hash function */
/* ----------------------------------------------------------------------- */
/**
* Digest a message using AES-DIGEST to yield a 16-byte hash code
*
* @param message Message to digest
* @param message_len Length of message in bytes
* @param hash Buffer to store 16 byte hash code
*/
extern void Anode_aes_digest(
const void *const message,
unsigned long message_len,
void *const hash);
/* ----------------------------------------------------------------------- */
/* Address Types and Components */
/* ----------------------------------------------------------------------- */
/**
* Anode address
*
* The first byte always identifies the address type, which right now can
* only be type 1 (ANODE-256-40).
*/
typedef struct
{
char bits[ANODE_ADDRESS_MAX_LENGTH];
} AnodeAddress;
/**
* 8-byte short Anode address ID
*/
typedef struct
{
char bits[ANODE_ADDRESS_ID_LENGTH];
} AnodeAddressId;
/**
* 4-byte Anode zone ID
*/
typedef struct
{
char bits[ANODE_ZONE_LENGTH];
} AnodeZone;
/**
* Anode address types
*/
enum AnodeAddressType
{
ANODE_ADDRESS_ANODE_256_40 = 1
};
/**
* Get the type of an Anode address
*
* This is a shortcut macro for just looking at the first byte and casting
* it to the AnodeAddressType enum.
*
* @param a Pointer to address
* @return Type as enum AnodeAddressType
*/
#define AnodeAddress_get_type(a) ((enum AnodeAddressType)((a)->bits[0]))
/**
* Calculate the short 8 byte address ID from an address
*
* @param address Binary address
* @param short_address_id Buffer to store 8-byte short address ID
* @return 0 on success or error code on failure
*/
extern int AnodeAddress_calc_short_id(
const AnodeAddress *address,
AnodeAddressId *short_address_id);
/**
* Extract the zone from an anode address
*
* @param address Binary address
* @param zone Zone value-result parameter to fill on success
* @return 0 on success or error code on failure
*/
extern int AnodeAddress_get_zone(const AnodeAddress *address,AnodeZone *zone);
/**
* Convert an address to an ASCII string
*
* Anode addresses are 64 characters in ASCII form, so the buffer should
* have 65 bytes of space.
*
* @param address Address to convert
* @param buf Buffer to receive address in string form (should have 65 bytes of space)
* @param len Length of buffer
* @return Length of resulting string or a negative error code on error
*/
extern int AnodeAddress_to_string(const AnodeAddress *address,char *buf,int len);
/**
* Convert a string into an address
*
* @param str Address in string form
* @param address Address buffer to receive result
* @return Zero on sucess or error code on error
*/
extern int AnodeAddress_from_string(const char *str,AnodeAddress *address);
/**
* Supported network address types
*/
enum AnodeNetworkAddressType
{
ANODE_NETWORK_ADDRESS_IPV4 = 0,
ANODE_NETWORK_ADDRESS_IPV6 = 1,
ANODE_NETWORK_ADDRESS_ETHERNET = 2, /* reserved but unused */
ANODE_NETWORK_ADDRESS_USB = 3, /* reserved but unused */
ANODE_NETWORK_ADDRESS_BLUETOOTH = 4, /* reserved but unused */
ANODE_NETWORK_ADDRESS_IPC = 5, /* reserved but unused */
ANODE_NETWORK_ADDRESS_80211S = 6, /* reserved but unused */
ANODE_NETWORK_ADDRESS_SERIAL = 7, /* reserved but unused */
ANODE_NETWORK_ADDRESS_ANODE_256_40 = 8
};
/**
* Anode network address
*
* This can contain an address of any type: IPv4, IPv6, or Anode, and is used
* with the common transport API.
*
* The length of the address stored in bits[] is determined by the type.
*/
typedef struct
{
enum AnodeNetworkAddressType type;
char bits[ANODE_ADDRESS_MAX_LENGTH];
} AnodeNetworkAddress;
/**
* An endpoint with an address and a port
*/
typedef struct
{
AnodeNetworkAddress address;
int port;
} AnodeNetworkEndpoint;
/* Constants for binding to any address (v4 or v6) */
extern const AnodeNetworkAddress AnodeNetworkAddress_IP_ANY_V4;
extern const AnodeNetworkAddress AnodeNetworkAddress_IP_ANY_V6;
/* Local host address in v4 and v6 */
extern const AnodeNetworkAddress AnodeNetworkAddress_IP_LOCAL_V4;
extern const AnodeNetworkAddress AnodeNetworkAddress_IP_LOCAL_V6;
/**
* Convert a network address to an ASCII string
*
* The buffer must have room for a 15 character string for IPv4, a 40 byte
* string for IPv6, and a 64 byte string for Anode addresses. This does not
* include the trailing null.
*
* @param address Address to convert
* @param buf Buffer to receive address in string form
* @param len Length of buffer
* @return Length of resulting string or a negative error code on error
*/
extern int AnodeNetworkAddress_to_string(const AnodeNetworkAddress *address,char *buf,int len);
/**
* Convert a string into a network address of the correct type
*
* @param str Address in string form
* @param address Address buffer to receive result
* @return Zero on sucess or error code on error
*/
extern int AnodeNetworkAddress_from_string(const char *str,AnodeNetworkAddress *address);
/**
* Fill a network endpoint from a C-API sockaddr structure
*
* The argument must be struct sockaddr_in for IPv4 or sockaddr_in6 for IPv6.
* The common sin_family field will be used to differentiate.
*
* @param sockaddr Pointer to proper sockaddr structure
* @param endpoint Endpoint structure to fill
* @return Zero on success or error on failure
*/
extern int AnodeNetworkEndpoint_from_sockaddr(const void *sockaddr,AnodeNetworkEndpoint *endpoint);
/**
* Fill a sockaddr from a network endpoint
*
* To support either IPv4 or IPv6 addresses, there is a sockaddr_storage
* structure in most C APIs. If you supply anything other than an IP address
* such as an Anode address, this will return an error.
*
* @param endpoint Endpoint structure to convert
* @param sockaddr Sockaddr structure storage
* @param sockaddr_len Length of sockaddr structure storage in bytes
* @return Zero on success or error on failure
*/
extern int AnodeNetworkEndpoint_to_sockaddr(const AnodeNetworkEndpoint *endpoint,void *sockaddr,int sockaddr_len);
/* ----------------------------------------------------------------------- */
/* Identity Generation and Management */
/* ----------------------------------------------------------------------- */
/**
* Anode identity structure containing address and secret key
*
* This structure is memcpy-safe, and its members are accessible.
*/
typedef struct
{
/* The public Anode address */
AnodeAddress address;
/* Short address ID */
AnodeAddressId address_id;
/* The secret key corresponding with the public address */
/* Secret length is determined by address type */
char secret[ANODE_ADDRESS_MAX_SECRET_LENGTH];
} AnodeIdentity;
/**
* Generate a new identity
*
* This generates a public/private key pair and from that generates an
* identity containing an address and a secret key.
*
* @param identity Destination structure to store new identity
* @param zone Zone ID
* @param type Type of identity to generate
* @return Zero on success, error on failure
*/
extern int AnodeIdentity_generate(
AnodeIdentity *identity,
const AnodeZone *zone,
enum AnodeAddressType type);
/**
* Convert an Anode identity to a string representation
*
* @param identity Identity to convert
* @param dest String buffer
* @param dest_len Length of string buffer
* @return Length of string created or negative error code on failure
*/
extern int AnodeIdentity_to_string(
const AnodeIdentity *identity,
char *dest,
int dest_len);
/**
* Convert a string representation to an Anode identity structure
*
* @param identity Destination structure to fill
* @param str C-string containing string representation
* @return Zero on success or negative error code on failure
*/
extern int AnodeIdentity_from_string(
AnodeIdentity *identity,
const char *str);
/* ----------------------------------------------------------------------- */
/* Transport API */
/* ----------------------------------------------------------------------- */
struct _AnodeTransport;
typedef struct _AnodeTransport AnodeTransport;
struct _AnodeEvent;
typedef struct _AnodeEvent AnodeEvent;
/**
* Anode socket
*/
typedef struct
{
/* Type of socket (read-only) */
enum {
ANODE_SOCKET_DATAGRAM = 1,
ANODE_SOCKET_STREAM_LISTEN = 2,
ANODE_SOCKET_STREAM_CONNECTION = 3
} type;
/* Socket state */
enum {
ANODE_SOCKET_CLOSED = 0,
ANODE_SOCKET_OPEN = 1,
ANODE_SOCKET_CONNECTING = 2,
} state;
/* Local address or remote address for stream connections (read-only) */
AnodeNetworkEndpoint endpoint;
/* Name of owning class (read-only) */
const char *class_name;
/* Pointers for end user use (writable) */
void *user_ptr[2];
/* Special handler to receive events or null for default (writable) */
void (*event_handler)(const AnodeEvent *event);
} AnodeSocket;
/**
* Anode transport I/O event
*/
struct _AnodeEvent
{
enum {
ANODE_TRANSPORT_EVENT_DATAGRAM_RECEIVED = 1,
ANODE_TRANSPORT_EVENT_STREAM_INCOMING_CONNECT = 2,
ANODE_TRANSPORT_EVENT_STREAM_OUTGOING_CONNECT_ESTABLISHED = 3,
ANODE_TRANSPORT_EVENT_STREAM_OUTGOING_CONNECT_FAILED = 4,
ANODE_TRANSPORT_EVENT_STREAM_CLOSED = 5,
ANODE_TRANSPORT_EVENT_STREAM_DATA_RECEIVED = 6,
ANODE_TRANSPORT_EVENT_STREAM_AVAILABLE_FOR_WRITE = 7,
ANODE_TRANSPORT_EVENT_DNS_RESULT = 8
} type;
AnodeTransport *transport;
/* Anode socket corresponding to this event */
AnodeSocket *sock;
/* Originating endpoint for incoming datagrams */
AnodeNetworkEndpoint *datagram_from;
/* DNS lookup results */
const char *dns_name;
AnodeNetworkAddress *dns_addresses;
int dns_address_count;
/* Error code or 0 for none */
int error_code;
/* Data for incoming datagrams and stream received events */
int data_length;
char *data;
};
/**
* Enum used for dns_resolve method in transport to specify query rules
*
* This can be specified for ipv4, ipv6, and Anode address types to tell the
* DNS resolver when to bother querying for addresses of the given type.
* NEVER means to never query for this type, and ALWAYS means to always
* query. IF_NO_PREVIOUS means to query for this type if no addresses were
* found in previous queries. Addresses are queried in the order of ipv4,
* ipv6, then Anode, so if you specify IF_NO_PREVIOUS for all three you will
* get addresses in that order of priority.
*/
enum AnodeTransportDnsIncludeMode
{
ANODE_TRANSPORT_DNS_QUERY_NEVER = 0,
ANODE_TRANSPORT_DNS_QUERY_ALWAYS = 1,
ANODE_TRANSPORT_DNS_QUERY_IF_NO_PREVIOUS = 2
};
struct _AnodeTransport
{
/**
* Set the default event handler
*
* @param transport Transport engine
* @param event_handler Default event handler
*/
void (*set_default_event_handler)(AnodeTransport *transport,
void (*event_handler)(const AnodeEvent *event));
/**
* Enqueue a function to be executed during a subsequent call to poll()
*
* This can be called from other threads, so it can be used to pass a
* message to the I/O thread in multithreaded applications.
*
* If it is called from the same thread, the function is still queued to be
* run later rather than being run instantly.
*
* The order in which invoked functions are called is undefined.
*
* @param transport Transport engine
* @param ptr Arbitrary pointer to pass to function to be called
* @param func Function to be called
*/
void (*invoke)(AnodeTransport *transport,
void *ptr,
void (*func)(void *));
/**
* Initiate a forward DNS query
*
* @param transport Transport instance
* @param name DNS name to query
* @param event_handler Event handler or null for default event path
* @param ipv4_include_mode Inclusion mode for IPv4 addresses
* @param ipv6_include_mode Inclusion mode for IPv6 addresses
* @param anode_include_mode Inclusion mode for Anode addresses
*/
void (*dns_resolve)(AnodeTransport *transport,
const char *name,
void (*event_handler)(const AnodeEvent *),
enum AnodeTransportDnsIncludeMode ipv4_include_mode,
enum AnodeTransportDnsIncludeMode ipv6_include_mode,
enum AnodeTransportDnsIncludeMode anode_include_mode);
/**
* Open a datagram socket
*
* @param transport Transport instance
* @param local_address Local address to bind
* @param local_port Local port to bind
* @param error_code Value-result parameter to receive error code on error
* @return Listen socket or null if error (check error_code in error case)
*/
AnodeSocket *(*datagram_listen)(AnodeTransport *transport,
const AnodeNetworkAddress *local_address,
int local_port,
int *error_code);
/**
* Open a socket to listen for incoming stream connections
*
* @param transport Transport instance
* @param local_address Local address to bind
* @param local_port Local port to bind
* @param error_code Value-result parameter to receive error code on error
* @return Listen socket or null if error (check error_code in error case)
*/
AnodeSocket *(*stream_listen)(AnodeTransport *transport,
const AnodeNetworkAddress *local_address,
int local_port,
int *error_code);
/**
* Send a datagram to a network endpoint
*
* @param transport Transport instance
* @param socket Originating datagram socket
* @param data Data to send
* @param data_len Length of data to send
* @param to_endpoint Destination endpoint
* @return Zero on success or error code on error
*/
int (*datagram_send)(AnodeTransport *transport,
AnodeSocket *sock,
const void *data,
int data_len,
const AnodeNetworkEndpoint *to_endpoint);
/**
* Initiate an outgoing stream connection attempt
*
* For IPv4 and IPv6 addresses, this will initiate a TCP connection. For
* Anode addresses, Anode's internal streaming protocol will be used.
*
* @param transport Transport instance
* @param to_endpoint Destination endpoint
* @param error_code Error code value-result parameter, filled on error
* @return Stream socket object or null on error (check error_code)
*/
AnodeSocket *(*stream_connect)(AnodeTransport *transport,
const AnodeNetworkEndpoint *to_endpoint,
int *error_code);
/**
* Indicate that you are interested in writing to a stream
*
* This does nothing if the socket is not a stream connection or is not
* connected.
*
* @param transport Transport instance
* @param sock Stream connection
*/
void (*stream_start_writing)(AnodeTransport *transport,
AnodeSocket *sock);
/**
* Indicate that you are no longer interested in writing to a stream
*
* This does nothing if the socket is not a stream connection or is not
* connected.
*
* @param transport Transport instance
* @param sock Stream connection
*/
void (*stream_stop_writing)(AnodeTransport *transport,
AnodeSocket *sock);
/**
* Send data to a stream connection
*
* This must be called after a stream is indicated to be ready for writing.
* It returns the number of bytes actually written, or a negative error
* code on failure.
*
* A return value of zero can occur here, and simply indicates that nothing
* was sent. This may occur with certain network stacks on certain
* platforms.
*
* @param transport Transport engine
* @param sock Stream socket
* @param data Data to send
* @param data_len Maximum data to send in bytes
* @return Actual data sent or negative error code on error
*/
int (*stream_send)(AnodeTransport *transport,
AnodeSocket *sock,
const void *data,
int data_len);
/**
* Close a socket
*
* If the socket is a stream connection in the connected state, this
* will generate a stream closed event with a zero error_code to indicate
* a normal close.
*
* @param transport Transport engine
* @param sock Socket object
*/
void (*close)(AnodeTransport *transport,
AnodeSocket *sock);
/**
* Run main polling loop
*
* This should be called repeatedly from the I/O thread of your main
* process. It blocks until one or more events occur, and then returns
* the number of events. Error returns here are fatal and indicate
* serious problems such as build or platform issues or a lack of any
* network interface.
*
* Functions queued with invoke() are also called inside here.
*
* @param transport Transport engine
* @return Number of events handled or negative on (fatal) error
*/
int (*poll)(AnodeTransport *transport);
/**
* Check whether transport supports an address type
*
* Inheriting classes should call their base if they do not natively
* speak the specified type.
*
* @param transport Transport engine
* @param at Address type
* @return Nonzero if true
*/
int (*supports_address_type)(const AnodeTransport *transport,
enum AnodeNetworkAddressType at);
/**
* Get the instance of AnodeTransport under this one (if any)
*
* @param transport Transport engine
* @return Base instance or null if none
*/
AnodeTransport *(*base_instance)(const AnodeTransport *transport);
/**
* @param transport Transport engine
* @return Class name of this instance
*/
const char *(*class_name)(AnodeTransport *transport);
/**
* Delete this transport and its base transports
*
* The 'transport' pointer and any streams or sockets it owns are no longer
* valid after this call.
*
* @param transport Transport engine
*/
void (*delete)(AnodeTransport *transport);
};
/**
* Construct a new system transport
*
* This is the default base for AnodeTransport, and it is constructed
* automatically if 'base' is null in AnodeTransport_new(). However, it also
* exposed to the user so that specialized transports (such as those that use
* proxy servers) can be developed on top of it. These in turn can be supplied
* as 'base' to AnodeTransport_new() to talk Anode over these transports.
*
* The system transport supports IP protocols and possibly others.
*
* @param base Base class or null for none (usually null)
* @return Base transport engine instance
*/
extern AnodeTransport *AnodeSystemTransport_new(AnodeTransport *base);
/**
* Construct a new Anode core transport
*
* This is the transport that talks Anode using the specified base transport.
* Requests for other address types are passed through to the base. If the
* base is null, an instance of AnodeSystemTransport is used.
*
* Since transport engines inherit their functionality, this transport
* will also do standard IP and everything else that the system transport
* supports. Most users will just want to construct this with a null base.
*
* @param base Base transport to use, or null to use SystemTransport
* @return Anode transport engine or null on error
*/
extern AnodeTransport *AnodeCoreTransport_new(AnodeTransport *base);
/* ----------------------------------------------------------------------- */
/* URI Parser */
/* ----------------------------------------------------------------------- */
/**
* URI broken down by component
*/
typedef struct
{
char scheme[8];
char username[64];
char password[64];
char host[128];
char path[256];
char query[256];
char fragment[64];
int port;
} AnodeURI;
/**
* URI parser
*
* A buffer too small error will occur if any field is too large for the
* AnodeURI structure.
*
* @param parsed_uri Structure to fill with parsed URI data
* @param uri_string URI in string format
* @return Zero on success or error on failure
*/
extern int AnodeURI_parse(AnodeURI *parsed_uri,const char *uri_string);
/**
* Output a URI in string format
*
* @param uri URI to output as string
* @param buf Buffer to store URI string
* @param len Length of buffer
* @return Buffer or null on error
*/
extern char *AnodeURI_to_string(const AnodeURI *uri,char *buf,int len);
/* ----------------------------------------------------------------------- */
/* Zone File Lookup and Dictionary */
/* ----------------------------------------------------------------------- */
/**
* Zone file dictionary
*/
typedef void AnodeZoneFile;
/**
* Start asynchronous zone fetch
*
* When the zone is retrieved, the lookup handler is called. If zone lookup
* failed, the zone file argument to the handler will be null.
*
* @param transport Transport engine
* @param zone Zone ID
* @param user_ptr User pointer
* @param zone_lookup_handler Handler for Anode zone lookup
*/
extern void AnodeZoneFile_lookup(
AnodeTransport *transport,
const AnodeZone *zone,
void *ptr,
void (*zone_lookup_handler)(const AnodeZone *,AnodeZoneFile *,void *));
/**
* Look up a key in a zone file
*
* @param zone Zone file object
* @param key Key to get in zone file
*/
extern const char *AnodeZoneFile_get(const AnodeZoneFile *zone,const char *key);
/**
* Free a zone file
*
* @param zone Zone to free
*/
extern void AnodeZoneFile_free(AnodeZoneFile *zone);
/* ----------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,52 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "anode.h"
struct AnodeErrDesc
{
int code;
const char *desc;
};
#define TOTAL_ERRORS 12
static const struct AnodeErrDesc ANODE_ERRORS[TOTAL_ERRORS] = {
{ ANODE_ERR_NONE, "No error (success)" },
{ ANODE_ERR_INVALID_ARGUMENT, "Invalid argument" },
{ ANODE_ERR_OUT_OF_MEMORY, "Out of memory" },
{ ANODE_ERR_INVALID_URI, "Invalid URI" },
{ ANODE_ERR_BUFFER_TOO_SMALL, "Supplied buffer too small" },
{ ANODE_ERR_ADDRESS_INVALID, "Address invalid" },
{ ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED, "Address type not supported"},
{ ANODE_ERR_CONNECTION_CLOSED, "Connection closed"},
{ ANODE_ERR_CONNECT_FAILED, "Connect failed"},
{ ANODE_ERR_UNABLE_TO_BIND, "Unable to bind to address"},
{ ANODE_ERR_TOO_MANY_OPEN_SOCKETS, "Too many open sockets"},
{ ANODE_ERR_DNS_NAME_NOT_FOUND_OR_TIMED_OUT, "DNS name not found or timed out"}
};
extern const char *Anode_strerror(int err)
{
int i;
int negerr = -err;
for(i=0;i<TOTAL_ERRORS;++i) {
if ((ANODE_ERRORS[i].code == err)||(ANODE_ERRORS[i].code == negerr))
return ANODE_ERRORS[i].desc;
}
return "Unknown error";
}

View File

@ -0,0 +1,110 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <stdio.h>
#include "impl/types.h"
#include "impl/ec.h"
#include "impl/misc.h"
#include "anode.h"
int AnodeIdentity_generate(AnodeIdentity *identity,const AnodeZone *zone,enum AnodeAddressType type)
{
struct AnodeECKeyPair kp;
switch(type) {
case ANODE_ADDRESS_ANODE_256_40:
if (!AnodeECKeyPair_generate(&kp))
return ANODE_ERR_OUT_OF_MEMORY;
identity->address.bits[0] = (unsigned char)ANODE_ADDRESS_ANODE_256_40;
identity->address.bits[1] = zone->bits[0];
identity->address.bits[2] = zone->bits[1];
identity->address.bits[3] = zone->bits[2];
identity->address.bits[4] = zone->bits[3];
identity->address.bits[5] = 0;
identity->address.bits[6] = 0;
Anode_memcpy((void *)&(identity->address.bits[7]),(const void *)kp.pub.key,ANODE_EC_PUBLIC_KEY_BYTES);
Anode_memcpy((void *)identity->secret,(const void *)kp.priv.key,kp.priv.bytes);
AnodeAddress_calc_short_id(&identity->address,&identity->address_id);
AnodeECKeyPair_destroy(&kp);
return 0;
}
return ANODE_ERR_INVALID_ARGUMENT;
}
int AnodeIdentity_to_string(const AnodeIdentity *identity,char *dest,int dest_len)
{
char hexbuf[128];
char strbuf[128];
int n;
if ((n = AnodeAddress_to_string(&identity->address,strbuf,sizeof(strbuf))) <= 0)
return n;
switch(AnodeAddress_get_type(&identity->address)) {
case ANODE_ADDRESS_ANODE_256_40:
Anode_to_hex((const unsigned char *)identity->secret,ANODE_ADDRESS_SECRET_LENGTH_ANODE_256_40,hexbuf,sizeof(hexbuf));
n = snprintf(dest,dest_len,"ANODE-256-40:%s:%s",strbuf,hexbuf);
if (n >= dest_len)
return ANODE_ERR_BUFFER_TOO_SMALL;
return n;
}
return ANODE_ERR_INVALID_ARGUMENT;
}
int AnodeIdentity_from_string(AnodeIdentity *identity,const char *str)
{
char buf[1024];
char *id_name;
char *address;
char *secret;
int ec;
Anode_str_copy(buf,str,sizeof(buf));
id_name = buf;
if (!id_name) return 0;
if (!*id_name) return 0;
address = (char *)Anode_strchr(id_name,':');
if (!address) return 0;
if (!*address) return 0;
*(address++) = (char)0;
secret = (char *)Anode_strchr(address,':');
if (!secret) return 0;
if (!*secret) return 0;
*(secret++) = (char)0;
if (Anode_strcaseeq("ANODE-256-40",id_name)) {
if ((ec = AnodeAddress_from_string(address,&identity->address)))
return ec;
if (Anode_strlen(secret) != (ANODE_ADDRESS_SECRET_LENGTH_ANODE_256_40 * 2))
return ANODE_ERR_INVALID_ARGUMENT;
Anode_from_hex(secret,(unsigned char *)identity->secret,sizeof(identity->secret));
AnodeAddress_calc_short_id(&identity->address,&identity->address_id);
return 0;
}
return ANODE_ERR_INVALID_ARGUMENT;
}

View File

@ -0,0 +1,72 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "aes.h"
void Anode_cmac_aes256(
const AnodeAesExpandedKey *expkey,
const unsigned char *restrict data,
unsigned long data_len,
unsigned char *restrict mac)
{
unsigned char cbc[16];
unsigned char pad[16];
const unsigned char *restrict pos = data;
unsigned long i;
unsigned long remaining = data_len;
unsigned char c;
((uint64_t *)((void *)cbc))[0] = 0ULL;
((uint64_t *)((void *)cbc))[1] = 0ULL;
while (remaining >= 16) {
((uint64_t *)((void *)cbc))[0] ^= ((uint64_t *)((void *)pos))[0];
((uint64_t *)((void *)cbc))[1] ^= ((uint64_t *)((void *)pos))[1];
pos += 16;
if (remaining > 16)
Anode_aes256_encrypt(expkey,cbc,cbc);
remaining -= 16;
}
((uint64_t *)((void *)pad))[0] = 0ULL;
((uint64_t *)((void *)pad))[1] = 0ULL;
Anode_aes256_encrypt(expkey,pad,pad);
c = pad[0] & 0x80;
for(i=0;i<15;++i)
pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7);
pad[15] <<= 1;
if (c)
pad[15] ^= 0x87;
if (remaining||(!data_len)) {
for(i=0;i<remaining;++i)
cbc[i] ^= *(pos++);
cbc[remaining] ^= 0x80;
c = pad[0] & 0x80;
for(i=0;i<15;++i)
pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7);
pad[15] <<= 1;
if (c)
pad[15] ^= 0x87;
}
((uint64_t *)((void *)mac))[0] = ((uint64_t *)((void *)pad))[0] ^ ((uint64_t *)((void *)cbc))[0];
((uint64_t *)((void *)mac))[1] = ((uint64_t *)((void *)pad))[1] ^ ((uint64_t *)((void *)cbc))[1];
Anode_aes256_encrypt(expkey,mac,mac);
}

View File

@ -0,0 +1,64 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_AES_H
#define _ANODE_AES_H
#include <openssl/aes.h>
#include "types.h"
/* This just glues us to OpenSSL's built-in AES-256 implementation */
#define ANODE_AES_BLOCK_SIZE 16
#define ANODE_AES_KEY_SIZE 32
typedef AES_KEY AnodeAesExpandedKey;
#define Anode_aes256_expand_key(k,ek) AES_set_encrypt_key((const unsigned char *)(k),256,(AES_KEY *)(ek))
/* Note: in and out can be the same thing */
#define Anode_aes256_encrypt(ek,in,out) AES_encrypt((const unsigned char *)(in),(unsigned char *)(out),(const AES_KEY *)(ek))
/* Note: iv is modified */
static inline void Anode_aes256_cfb_encrypt(
const AnodeAesExpandedKey *expkey,
const unsigned char *in,
unsigned char *out,
unsigned char *iv,
unsigned long len)
{
int tmp = 0;
AES_cfb128_encrypt(in,out,len,(const AES_KEY *)expkey,iv,&tmp,AES_ENCRYPT);
}
static inline void Anode_aes256_cfb_decrypt(
const AnodeAesExpandedKey *expkey,
const unsigned char *in,
unsigned char *out,
unsigned char *iv,
unsigned long len)
{
int tmp = 0;
AES_cfb128_encrypt(in,out,len,(const AES_KEY *)expkey,iv,&tmp,AES_DECRYPT);
}
/* CMAC message authentication code */
void Anode_cmac_aes256(
const AnodeAesExpandedKey *expkey,
const unsigned char *restrict data,
unsigned long data_len,
unsigned char *restrict mac);
#endif

View File

@ -0,0 +1,239 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include "dictionary.h"
static const char *EMPTY_STR = "";
void AnodeDictionary_clear(struct AnodeDictionary *d)
{
struct AnodeDictionaryEntry *e,*ne;
int oldcs;
unsigned int i;
oldcs = d->case_sensitive;
for(i=0;i<ANODE_DICTIONARY_FIXED_HASH_TABLE_SIZE;++i) {
e = d->ht[i];
while (e) {
ne = e->next;
if ((e->key)&&(e->key != EMPTY_STR)) free((void *)e->key);
if ((e->value)&&(e->value != EMPTY_STR)) free((void *)e->value);
free((void *)e);
e = ne;
}
}
Anode_zero((void *)d,sizeof(struct AnodeDictionary));
d->case_sensitive = oldcs;
}
void AnodeDictionary_put(struct AnodeDictionary *d,const char *key,const char *value)
{
struct AnodeDictionaryEntry *e;
char *p1;
const char *p2;
unsigned int bucket = (d->case_sensitive) ? AnodeDictionary__get_bucket(key) : AnodeDictionary__get_bucket_ci(key);
unsigned int len,i;
e = d->ht[bucket];
while (e) {
if (((d->case_sensitive) ? Anode_streq(key,e->key) : Anode_strcaseeq(key,e->key))) {
if (!d->case_sensitive) {
p1 = e->key;
p2 = key;
while (*p2) *(p1++) = *(p2++);
}
len = 0;
while (value[len]) ++len;
if (len) {
if ((e->value)&&(e->value != EMPTY_STR))
e->value = (char *)realloc((void *)e->value,len + 1);
else e->value = (char *)malloc(len + 1);
for(i=0;i<len;++i) e->value[i] = value[i];
e->value[i] = (char)0;
} else {
if ((e->value)&&(e->value != EMPTY_STR)) free((void *)e->value);
e->value = (char *)EMPTY_STR;
}
return;
}
e = e->next;
}
e = (struct AnodeDictionaryEntry *)malloc(sizeof(struct AnodeDictionaryEntry));
len = 0;
while (key[len]) ++len;
if (len) {
e->key = (char *)malloc(len + 1);
for(i=0;i<len;++i) e->key[i] = key[i];
e->key[i] = (char)0;
} else e->key = (char *)EMPTY_STR;
len = 0;
while (value[len]) ++len;
if (len) {
e->value = (char *)malloc(len + 1);
for(i=0;i<len;++i) e->value[i] = value[i];
e->value[i] = (char)0;
} else e->value = (char *)EMPTY_STR;
e->next = d->ht[bucket];
d->ht[bucket] = e;
++d->size;
}
void AnodeDictionary_read(
struct AnodeDictionary *d,
char *in,
const char *line_breaks,
const char *kv_breaks,
const char *comment_chars,
char escape_char,
int trim_whitespace_from_keys,
int trim_whitespace_from_values)
{
char *line = in;
char *key;
char *value;
char *p1,*p2,*p3;
char last = ~escape_char;
int eof_state = 0;
for(;;) {
if ((!*in)||((Anode_strchr(line_breaks,*in))&&((last != escape_char)||(!escape_char)))) {
if (!*in)
eof_state = 1;
else *in = (char)0;
if ((*line)&&((comment_chars)&&(!Anode_strchr(comment_chars,*line)))) {
key = line;
while (*line) {
if ((Anode_strchr(kv_breaks,*line))&&((last != escape_char)||(!escape_char))) {
*(line++) = (char)0;
break;
} else last = *(line++);
}
while ((*line)&&(Anode_strchr(kv_breaks,*line))&&((last != escape_char)||(!escape_char)))
last = *(line++);
value = line;
if (escape_char) {
p1 = key;
while (*p1) {
if (*p1 == escape_char) {
p2 = p1;
p3 = p1 + 1;
while (*p3)
*(p2++) = *(p3++);
*p2 = (char)0;
}
++p1;
}
p1 = value;
while (*p1) {
if (*p1 == escape_char) {
p2 = p1;
p3 = p1 + 1;
while (*p3)
*(p2++) = *(p3++);
*p2 = (char)0;
}
++p1;
}
}
if (trim_whitespace_from_keys)
Anode_trim(key);
if (trim_whitespace_from_values)
Anode_trim(value);
AnodeDictionary_put(d,key,value);
}
if (eof_state)
break;
else line = in + 1;
}
last = *(in++);
}
}
long AnodeDictionary_write(
struct AnodeDictionary *d,
char *out,
long out_size,
const char *line_break,
const char *kv_break)
{
struct AnodeDictionaryEntry *e;
const char *tmp;
long ptr = 0;
unsigned int bucket;
if (out_size <= 0)
return -1;
for(bucket=0;bucket<ANODE_DICTIONARY_FIXED_HASH_TABLE_SIZE;++bucket) {
e = d->ht[bucket];
while (e) {
tmp = e->key;
if (tmp) {
while (*tmp) {
out[ptr++] = *tmp++;
if (ptr >= (out_size - 1)) return -1;
}
}
tmp = kv_break;
if (tmp) {
while (*tmp) {
out[ptr++] = *tmp++;
if (ptr >= (out_size - 1)) return -1;
}
}
tmp = e->value;
if (tmp) {
while (*tmp) {
out[ptr++] = *tmp++;
if (ptr >= (out_size - 1)) return -1;
}
}
tmp = line_break;
if (tmp) {
while (*tmp) {
out[ptr++] = *tmp++;
if (ptr >= (out_size - 1)) return -1;
}
}
e = e->next;
}
}
out[ptr] = (char)0;
return ptr;
}

View File

@ -0,0 +1,126 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This is a simple string hash table suitable for small tables such as zone
* files or HTTP header lists. */
#ifndef _ANODE_DICTIONARY_H
#define _ANODE_DICTIONARY_H
#include "misc.h"
/* This is a fixed hash table and is designed for relatively small numbers
* of keys for things like zone files. */
#define ANODE_DICTIONARY_FIXED_HASH_TABLE_SIZE 16
#define ANODE_DICTIONARY_FIXED_HASH_TABLE_MASK 15
/* Computes a hash code for a string and returns the hash bucket */
static inline unsigned int AnodeDictionary__get_bucket(const char *s)
{
unsigned int hc = 3;
while (*s)
hc = ((hc << 4) + hc) + (unsigned int)*(s++);
return ((hc ^ (hc >> 4)) & ANODE_DICTIONARY_FIXED_HASH_TABLE_MASK);
}
/* Case insensitive version of get_bucket */
static inline unsigned int AnodeDictionary__get_bucket_ci(const char *s)
{
unsigned int hc = 3;
while (*s)
hc = ((hc << 4) + hc) + (unsigned int)Anode_tolower(*(s++));
return ((hc ^ (hc >> 4)) & ANODE_DICTIONARY_FIXED_HASH_TABLE_MASK);
}
struct AnodeDictionaryEntry
{
char *key;
char *value;
struct AnodeDictionaryEntry *next;
};
struct AnodeDictionary
{
struct AnodeDictionaryEntry *ht[ANODE_DICTIONARY_FIXED_HASH_TABLE_SIZE];
unsigned int size;
int case_sensitive;
};
static inline void AnodeDictionary_init(struct AnodeDictionary *d,int case_sensitive)
{
Anode_zero((void *)d,sizeof(struct AnodeDictionary));
d->case_sensitive = case_sensitive;
}
void AnodeDictionary_clear(struct AnodeDictionary *d);
static inline void AnodeDictionary_destroy(struct AnodeDictionary *d)
{
AnodeDictionary_clear(d);
}
void AnodeDictionary_put(struct AnodeDictionary *d,const char *key,const char *value);
static inline const char *AnodeDictionary_get(struct AnodeDictionary *d,const char *key)
{
struct AnodeDictionaryEntry *e;
unsigned int bucket = (d->case_sensitive) ? AnodeDictionary__get_bucket(key) : AnodeDictionary__get_bucket_ci(key);
e = d->ht[bucket];
while (e) {
if ((d->case_sensitive ? Anode_streq(key,e->key) : Anode_strcaseeq(key,e->key)))
return e->value;
e = e->next;
}
return (const char *)0;
}
static inline void AnodeDictionary_iterate(
struct AnodeDictionary *d,
void *arg,
int (*func)(void *,const char *,const char *))
{
struct AnodeDictionaryEntry *e;
unsigned int bucket;
for(bucket=0;bucket<ANODE_DICTIONARY_FIXED_HASH_TABLE_SIZE;++bucket) {
e = d->ht[bucket];
while (e) {
if (!func(arg,e->key,e->value))
return;
e = e->next;
}
}
}
void AnodeDictionary_read(
struct AnodeDictionary *d,
char *in,
const char *line_breaks,
const char *kv_breaks,
const char *comment_chars,
char escape_char,
int trim_whitespace_from_keys,
int trim_whitespace_from_values);
long AnodeDictionary_write(
struct AnodeDictionary *d,
char *out,
long out_size,
const char *line_break,
const char *kv_break);
#endif

View File

@ -0,0 +1,93 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <netdb.h>
#include "dns_txt.h"
#ifndef C_IN
#define C_IN ns_c_in
#endif
#ifndef T_TXT
#define T_TXT ns_t_txt
#endif
static volatile int Anode_resolver_initialized = 0;
int Anode_sync_resolve_txt(const char *host,char *txt,unsigned int txt_len)
{
unsigned char answer[16384],*pptr,*end;
char name[16384];
int len,explen,i;
if (!Anode_resolver_initialized) {
Anode_resolver_initialized = 1;
res_init();
}
/* Do not taunt happy fun ball. */
len = res_search(host,C_IN,T_TXT,answer,sizeof(answer));
if (len > 12) {
pptr = answer + 12;
end = answer + len;
explen = dn_expand(answer,end,pptr,name,sizeof(name));
if (explen > 0) {
pptr += explen;
if ((pptr + 2) >= end) return 2;
if (ntohs(*((uint16_t *)pptr)) == T_TXT) {
pptr += 4;
if (pptr >= end) return 2;
explen = dn_expand(answer,end,pptr,name,sizeof(name));
if (explen > 0) {
pptr += explen;
if ((pptr + 2) >= end) return 2;
if (ntohs(*((uint16_t *)pptr)) == T_TXT) {
pptr += 10;
if (pptr >= end) return 2;
len = *(pptr++);
if (len <= 0) return 2;
if ((pptr + len) > end) return 2;
if (txt_len < (len + 1))
return 4;
else {
for(i=0;i<len;++i)
txt[i] = pptr[i];
txt[len] = (char)0;
return 0;
}
}
}
}
}
}
return 1;
}

View File

@ -0,0 +1,37 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_DNS_TXT_H
#define _ANODE_DNS_TXT_H
/**
* Synchronous TXT resolver routine
*
* Error codes:
* 1 - I/O error
* 2 - Invalid response
* 3 - TXT record not found
* 4 - Destination buffer too small for result
*
* @param host Host name
* @param txt Buffer to store TXT result
* @param txt_len Size of buffer
* @return Zero on success, special error code on failure
*/
int Anode_sync_resolve_txt(const char *host,char *txt,unsigned int txt_len);
#endif

View File

@ -0,0 +1,219 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/bn.h>
#include <openssl/obj_mac.h>
#include <openssl/rand.h>
#include <openssl/ec.h>
#include <openssl/ecdh.h>
#include <openssl/ecdsa.h>
#include "types.h"
#include "misc.h"
#include "ec.h"
static EC_GROUP *AnodeEC_group = (EC_GROUP *)0;
static void *AnodeEC_KDF(const void *in,size_t inlen,void *out,size_t *outlen)
{
unsigned long i,longest_length;
if (!*outlen)
return out;
for(i=0;i<(unsigned long)*outlen;++i)
((unsigned char *)out)[i] = (unsigned char)0;
longest_length = inlen;
if (longest_length < *outlen)
longest_length = *outlen;
for(i=0;i<longest_length;++i)
((unsigned char *)out)[i % (unsigned long)*outlen] ^= ((const unsigned char *)in)[i % (unsigned long)inlen];
return out;
}
int AnodeECKeyPair_generate(struct AnodeECKeyPair *pair)
{
EC_KEY *key;
int len;
#ifdef HAS_DEV_URANDOM
char buf[128];
FILE *f = fopen("/dev/urandom","r");
if (f) {
if (fread(buf,1,sizeof(buf),f) == sizeof(buf))
RAND_add(buf,sizeof(buf),sizeof(buf)/2);
fclose(f);
}
#endif
if (!AnodeEC_group) {
AnodeEC_group = EC_GROUP_new_by_curve_name(ANODE_EC_GROUP);
if (!AnodeEC_group) return 0;
}
key = EC_KEY_new();
if (!key) return 0;
if (!EC_KEY_set_group(key,AnodeEC_group)) {
EC_KEY_free(key);
return 0;
}
if (!EC_KEY_generate_key(key)) {
EC_KEY_free(key);
return 0;
}
Anode_zero(pair,sizeof(struct AnodeECKeyPair));
/* Stuff the private key into priv.key */
len = BN_num_bytes(EC_KEY_get0_private_key(key));
if ((len > ANODE_EC_PRIME_BYTES)||(len < 0)) {
EC_KEY_free(key);
return 0;
}
BN_bn2bin(EC_KEY_get0_private_key(key),&(pair->priv.key[ANODE_EC_PRIME_BYTES - len]));
pair->priv.bytes = ANODE_EC_PRIME_BYTES;
len = EC_POINT_point2oct(AnodeEC_group,EC_KEY_get0_public_key(key),POINT_CONVERSION_COMPRESSED,pair->pub.key,sizeof(pair->pub.key),0);
if (len != ANODE_EC_PUBLIC_KEY_BYTES) {
EC_KEY_free(key);
return 0;
}
pair->pub.bytes = ANODE_EC_PUBLIC_KEY_BYTES;
/* Keep a copy of OpenSSL's structure around so we don't have to re-init
* it every time we use our key pair structure. */
pair->internal_key = key;
return 1;
}
int AnodeECKeyPair_init(struct AnodeECKeyPair *pair,const struct AnodeECKey *pub,const struct AnodeECKey *priv)
{
EC_KEY *key;
EC_POINT *kxy;
BIGNUM *pn;
if (!AnodeEC_group) {
AnodeEC_group = EC_GROUP_new_by_curve_name(ANODE_EC_GROUP);
if (!AnodeEC_group) return 0;
}
key = EC_KEY_new();
if (!key)
return 0;
if (!EC_KEY_set_group(key,AnodeEC_group)) {
EC_KEY_free(key);
return 0;
}
/* Grab the private key */
if (priv->bytes != ANODE_EC_PRIME_BYTES) {
EC_KEY_free(key);
return 0;
}
pn = BN_new();
if (!pn) {
EC_KEY_free(key);
return 0;
}
if (!BN_bin2bn(priv->key,ANODE_EC_PRIME_BYTES,pn)) {
BN_free(pn);
EC_KEY_free(key);
return 0;
}
if (!EC_KEY_set_private_key(key,pn)) {
BN_free(pn);
EC_KEY_free(key);
return 0;
}
BN_free(pn);
/* Set the public key */
if (pub->bytes != ANODE_EC_PUBLIC_KEY_BYTES) {
EC_KEY_free(key);
return 0;
}
kxy = EC_POINT_new(AnodeEC_group);
if (!kxy) {
EC_KEY_free(key);
return 0;
}
EC_POINT_oct2point(AnodeEC_group,kxy,pub->key,ANODE_EC_PUBLIC_KEY_BYTES,0);
if (!EC_KEY_set_public_key(key,kxy)) {
EC_POINT_free(kxy);
EC_KEY_free(key);
return 0;
}
EC_POINT_free(kxy);
Anode_zero(pair,sizeof(struct AnodeECKeyPair));
Anode_memcpy((void *)&(pair->pub),(const void *)pub,sizeof(struct AnodeECKey));
Anode_memcpy((void *)&(pair->priv),(const void *)priv,sizeof(struct AnodeECKey));
pair->internal_key = key;
return 1;
}
void AnodeECKeyPair_destroy(struct AnodeECKeyPair *pair)
{
if (pair) {
if (pair->internal_key)
EC_KEY_free((EC_KEY *)pair->internal_key);
}
}
int AnodeECKeyPair_agree(const struct AnodeECKeyPair *my_key_pair,const struct AnodeECKey *their_pub_key,unsigned char *key_buf,unsigned int key_len)
{
EC_POINT *pub;
int i;
if (!AnodeEC_group) {
AnodeEC_group = EC_GROUP_new_by_curve_name(ANODE_EC_GROUP);
if (!AnodeEC_group) return 0;
}
if (!my_key_pair->internal_key)
return 0;
if (their_pub_key->bytes != ANODE_EC_PUBLIC_KEY_BYTES)
return 0;
pub = EC_POINT_new(AnodeEC_group);
if (!pub)
return 0;
EC_POINT_oct2point(AnodeEC_group,pub,their_pub_key->key,ANODE_EC_PUBLIC_KEY_BYTES,0);
i = ECDH_compute_key(key_buf,key_len,pub,(EC_KEY *)my_key_pair->internal_key,&AnodeEC_KDF);
if (i != (int)key_len) {
EC_POINT_free(pub);
return 0;
}
EC_POINT_free(pub);
return 1;
}
void AnodeEC_random(unsigned char *buf,unsigned int len)
{
RAND_pseudo_bytes(buf,len);
}

View File

@ -0,0 +1,61 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Elliptic curve glue -- hides OpenSSL code behind this source module */
#ifndef _ANODE_EC_H
#define _ANODE_EC_H
#include "misc.h"
/* Right now, only one mode is supported: NIST-P-256. This is the only mode
* supported in the spec as well, and should be good for quite some time.
* If other modes are needed this code will need to be refactored. */
/* NIST-P-256 prime size in bytes */
#define ANODE_EC_PRIME_BYTES 32
/* Sizes of key fields */
#define ANODE_EC_GROUP NID_X9_62_prime256v1
#define ANODE_EC_PUBLIC_KEY_BYTES (ANODE_EC_PRIME_BYTES + 1)
#define ANODE_EC_PRIVATE_KEY_BYTES ANODE_EC_PRIME_BYTES
/* Larger of public or private key bytes, used for buffers */
#define ANODE_EC_MAX_BYTES ANODE_EC_PUBLIC_KEY_BYTES
struct AnodeECKey
{
unsigned char key[ANODE_EC_MAX_BYTES];
unsigned int bytes;
};
struct AnodeECKeyPair
{
struct AnodeECKey pub;
struct AnodeECKey priv;
void *internal_key;
};
/* Key management functions */
int AnodeECKeyPair_generate(struct AnodeECKeyPair *pair);
int AnodeECKeyPair_init(struct AnodeECKeyPair *pair,const struct AnodeECKey *pub,const struct AnodeECKey *priv);
void AnodeECKeyPair_destroy(struct AnodeECKeyPair *pair);
int AnodeECKeyPair_agree(const struct AnodeECKeyPair *my_key_pair,const struct AnodeECKey *their_pub_key,unsigned char *key_buf,unsigned int key_len);
/* Provides access to the secure PRNG used to generate keys */
void AnodeEC_random(unsigned char *buf,unsigned int len);
#endif

View File

@ -0,0 +1,118 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include "environment.h"
#ifdef WINDOWS
#include <windows.h>
#else
#include <sys/stat.h>
#include <string.h>
#endif
static char Anode_cache_base[1024] = { 0 };
const char *Anode_get_cache()
{
if (Anode_cache_base[0])
return Anode_cache_base;
#ifdef WINDOWS
#else
char tmp[1024];
char home[1024];
unsigned int i;
struct stat st;
const char *_home = getenv("HOME");
if (!_home)
return (const char *)0;
for(i=0;i<sizeof(home);++i) {
home[i] = _home[i];
if (!home[i]) {
if (i == 0)
return (const char *)0;
else if (home[i-1] == ANODE_PATH_SEPARATOR)
home[i-1] = (char)0;
break;
}
}
if (i == sizeof(home))
return (const char *)0;
#ifdef __APPLE__
snprintf(tmp,sizeof(tmp),"%s%cLibrary",home,ANODE_PATH_SEPARATOR);
tmp[sizeof(tmp)-1] = (char)0;
if (!stat(tmp,&st)) {
sprintf(tmp,"%s%cLibrary%cCaches",home,ANODE_PATH_SEPARATOR,ANODE_PATH_SEPARATOR);
if (stat(tmp,&st)) {
if (mkdir(tmp,0700))
return (const char *)0;
}
snprintf(Anode_cache_base,sizeof(Anode_cache_base),"%s%ccom.zerotier.anode",tmp,ANODE_PATH_SEPARATOR);
Anode_cache_base[sizeof(Anode_cache_base)-1] = (char)0;
if (stat(Anode_cache_base,&st)) {
if (mkdir(Anode_cache_base,0700)) {
Anode_cache_base[0] = (char)0;
return (const char *)0;
}
}
return Anode_cache_base;
}
#endif
snprintf(tmp,sizeof(tmp),"%s%c.anode",home,ANODE_PATH_SEPARATOR);
tmp[sizeof(tmp)-1] = (char)0;
if (stat(tmp,&st)) {
if (mkdir(tmp,0700)) {
Anode_cache_base[0] = (char)0;
return (const char *)0;
}
}
snprintf(Anode_cache_base,sizeof(Anode_cache_base),"%s%ccaches",tmp,ANODE_PATH_SEPARATOR);
Anode_cache_base[sizeof(Anode_cache_base)-1] = (char)0;
if (stat(Anode_cache_base,&st)) {
if (mkdir(Anode_cache_base,0700)) {
Anode_cache_base[0] = (char)0;
return (const char *)0;
}
}
return Anode_cache_base;
#endif
}
char *Anode_get_cache_sub(const char *cache_subdir,char *buf,unsigned int len)
{
struct stat st;
const char *cache_base = Anode_get_cache();
if (!len)
return (char *)0;
if (!cache_base)
return (char *)0;
snprintf(buf,len,"%s%c%s",cache_base,ANODE_PATH_SEPARATOR,cache_subdir);
buf[len-1] = (char)0;
if (stat(buf,&st)) {
if (mkdir(buf,0700))
return (char *)0;
}
return buf;
}

View File

@ -0,0 +1,30 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_ENVIRONMENT_H
#define _ANODE_ENVIRONMENT_H
#ifdef WINDOWS
#define ANODE_PATH_SEPARATOR '\\'
#else
#define ANODE_PATH_SEPARATOR '/'
#endif
const char *Anode_get_cache();
char *Anode_get_cache_sub(const char *cache_subdir,char *buf,unsigned int len);
#endif

View File

@ -0,0 +1,558 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include "http_client.h"
#include "misc.h"
#include "types.h"
/* How much to increment read buffer at each capacity top? */
#define ANODE_HTTP_CAPACITY_INCREMENT 4096
static void AnodeHttpClient_close_and_fail(struct AnodeHttpClient *client)
{
if (client->impl.tcp_connection) {
client->impl.transport_engine->tcp_close(client->impl.transport_engine,client->impl.tcp_connection);
client->impl.tcp_connection = (AnodeTransportTcpConnection *)0;
}
client->response.data_length = 0;
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CLOSED;
if (client->handler)
client->handler(client);
}
static void AnodeHttpClient_do_initiate_client(struct AnodeHttpClient *client)
{
const char *method = "";
long l,i;
switch(client->method) {
case ANODE_HTTP_GET: method = "GET"; break;
case ANODE_HTTP_HEAD: method = "HEAD"; break;
case ANODE_HTTP_POST: method = "POST"; break;
}
client->impl.outbuf_len = snprintf((char *)client->impl.outbuf,sizeof(client->impl.outbuf),
"%s %s%s%s HTTP/1.1\r\nHost: %s:%d\r\n%s",
method,
client->uri.path,
((client->uri.query[0]) ? "?" : ""),
client->uri.query,
client->uri.host,
((client->uri.port > 0) ? client->uri.port : 80),
((client->keepalive) ? "" : "Connection: close\r\n")
);
if (client->impl.outbuf_len >= (sizeof(client->impl.outbuf) - 2)) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_HEADERS_TOO_LARGE;
AnodeHttpClient_close_and_fail(client);
return;
}
if (client->method == ANODE_HTTP_POST) {
if ((client->data)&&(client->data_length)) {
client->impl.outbuf_len += snprintf((char *)client->impl.outbuf + client->impl.outbuf_len,sizeof(client->impl.outbuf) - client->impl.outbuf_len,
"Content-Type: %s\r\n",
(client->data_content_type ? client->data_content_type : "application/x-www-form-urlencoded")
);
if (client->impl.outbuf_len >= (sizeof(client->impl.outbuf) - 2)) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_HEADERS_TOO_LARGE;
AnodeHttpClient_close_and_fail(client);
return;
}
client->impl.outbuf_len += snprintf((char *)client->impl.outbuf + client->impl.outbuf_len,sizeof(client->impl.outbuf) - client->impl.outbuf_len,
"Content-Length: %u\r\n",
client->data_length
);
if (client->impl.outbuf_len >= (sizeof(client->impl.outbuf) - 2)) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_HEADERS_TOO_LARGE;
AnodeHttpClient_close_and_fail(client);
return;
}
} else {
client->impl.outbuf_len += snprintf((char *)client->impl.outbuf + client->impl.outbuf_len,sizeof(client->impl.outbuf) - client->impl.outbuf_len,
"Content-Length: 0\r\n"
);
if (client->impl.outbuf_len >= (sizeof(client->impl.outbuf) - 2)) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_HEADERS_TOO_LARGE;
AnodeHttpClient_close_and_fail(client);
return;
}
}
}
l = AnodeDictionary_write(&(client->headers),(char *)client->impl.outbuf + client->impl.outbuf_len,(long)(sizeof(client->impl.outbuf) - client->impl.outbuf_len - 2),"\r\n",": ");
if (l < 0) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_HEADERS_TOO_LARGE;
AnodeHttpClient_close_and_fail(client);
return;
}
client->impl.outbuf_len += (unsigned int)l;
if (client->impl.outbuf_len >= (sizeof(client->impl.outbuf) - 2)) { /* sanity check */
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_HEADERS_TOO_LARGE;
AnodeHttpClient_close_and_fail(client);
return;
}
client->impl.outbuf[client->impl.outbuf_len++] = '\r';
client->impl.outbuf[client->impl.outbuf_len++] = '\n';
if ((client->method == ANODE_HTTP_POST)&&(client->data)&&(client->data_length)) {
i = sizeof(client->impl.outbuf) - client->impl.outbuf_len;
if (i > client->data_length)
i = client->data_length;
Anode_memcpy((client->impl.outbuf + client->impl.outbuf_len),client->data,i);
client->impl.request_data_ptr += i;
client->impl.outbuf_len += i;
}
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_SEND;
client->impl.transport_engine->tcp_start_writing(client->impl.transport_engine,client->impl.tcp_connection);
}
static void AnodeHttpClient_tcp_outgoing_connect_handler(
AnodeTransportEngine *transport,
AnodeTransportTcpConnection *connection,
int error_code)
{
struct AnodeHttpClient *client;
if (!(client = (struct AnodeHttpClient *)(connection->ptr)))
return;
if ((client->impl.phase == ANODE_HTTP_REQUEST_PHASE_CONNECT)&&(!client->impl.freed)) {
if (error_code) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_CONNECT_FAILED;
AnodeHttpClient_close_and_fail(client);
} else {
client->impl.tcp_connection = connection;
AnodeHttpClient_do_initiate_client(client);
}
} else transport->tcp_close(transport,connection);
}
static void AnodeHttpClient_tcp_connection_terminated_handler(
AnodeTransportEngine *transport,
AnodeTransportTcpConnection *connection,
int error_code)
{
struct AnodeHttpClient *client;
if (!(client = (struct AnodeHttpClient *)(connection->ptr)))
return;
if (client->impl.freed)
return;
client->response.data_length = 0;
client->impl.tcp_connection = (AnodeTransportTcpConnection *)0;
if ((client->impl.phase != ANODE_HTTP_REQUEST_PHASE_KEEPALIVE)&&(client->impl.phase != ANODE_HTTP_REQUEST_PHASE_CLOSED)) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_SERVER_CLOSED_CONNECTION;
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CLOSED;
AnodeHttpClient_close_and_fail(client);
} else client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CLOSED;
}
static void AnodeHttpClient_tcp_receive_handler(
AnodeTransportEngine *transport,
AnodeTransportTcpConnection *connection,
void *data,
unsigned int data_length)
{
struct AnodeHttpClient *client;
char *p1,*p2;
unsigned int i;
long l;
if (!(client = (struct AnodeHttpClient *)(connection->ptr)))
return;
if (client->impl.freed) {
transport->tcp_close(transport,connection);
return;
}
if (!client->response.data)
client->response.data = malloc(client->impl.response_data_capacity = ANODE_HTTP_CAPACITY_INCREMENT);
i = 0;
while (i < data_length) {
switch(client->impl.read_mode) {
case ANODE_HTTP_READ_MODE_WAITING:
for(;i<data_length;++i) {
if (((const char *)data)[i] == '\n') {
((char *)client->response.data)[client->response.data_length] = (char)0;
client->response.data_length = 0;
p1 = (char *)Anode_strchr((char *)client->response.data,' ');
if (!p1)
p1 = (char *)Anode_strchr((char *)client->response.data,'\t');
if (p1) {
while ((*p1 == ' ')||(*p1 == '\t')) ++p1;
if (!*p1) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_INVALID_RESPONSE;
AnodeHttpClient_close_and_fail(client);
return;
}
p2 = p1 + 1;
while (*p2) {
if ((*p2 == ' ')||(*p2 == '\t')||(*p2 == '\r')||(*p2 == '\n')) {
*p2 = (char)0;
break;
} else ++p2;
}
client->response.code = (int)strtol(p1,(char **)0,10);
client->impl.read_mode = ANODE_HTTP_READ_MODE_HEADERS;
++i; break; /* Exit inner for() */
}
} else {
((char *)client->response.data)[client->response.data_length++] = ((const char *)data)[i];
if (client->response.data_length >= client->impl.response_data_capacity)
client->response.data = realloc(client->response.data,client->impl.response_data_capacity += ANODE_HTTP_CAPACITY_INCREMENT);
}
}
break;
case ANODE_HTTP_READ_MODE_HEADERS:
case ANODE_HTTP_READ_MODE_CHUNKED_FOOTER:
for(;i<data_length;++i) {
if (((const char *)data)[i] == '\n') {
client->impl.header_line_buf[client->impl.header_line_buf_ptr] = (char)0;
client->impl.header_line_buf_ptr = 0;
if ((!client->impl.header_line_buf[0])||((client->impl.header_line_buf[0] == '\r')&&(!client->impl.header_line_buf[1]))) {
/* If the line is empty (or is empty with \r\n as the
* line terminator), we're at the end. */
if (client->impl.read_mode == ANODE_HTTP_READ_MODE_CHUNKED_FOOTER) {
/* If this is a chunked footer, we finally end the
* chunked response. */
client->impl.read_mode = ANODE_HTTP_READ_MODE_WAITING;
if (client->keepalive)
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_KEEPALIVE;
else {
client->impl.transport_engine->tcp_close(client->impl.transport_engine,client->impl.tcp_connection);
client->impl.tcp_connection = (AnodeTransportTcpConnection *)0;
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CLOSED;
}
if (client->handler)
client->handler(client);
if (client->impl.freed)
return;
} else {
/* Otherwise, this is a regular header block */
if (client->response.code == 100) {
/* Ignore 100 Continue messages */
client->impl.read_mode = ANODE_HTTP_READ_MODE_WAITING;
++i; break; /* Exit inner for() */
} else if ((client->response.code == 200)&&(client->method != ANODE_HTTP_HEAD)) {
/* Other messages get their headers parsed to determine
* how to read them. */
p1 = (char *)AnodeDictionary_get(&(client->response.headers),"transfer-encoding");
if ((p1)&&(Anode_strcaseeq(p1,"chunked"))) {
/* Chunked encoding enters chunked mode */
client->impl.header_line_buf_ptr = 0;
client->impl.read_mode = ANODE_HTTP_READ_MODE_CHUNKED_CHUNK_SIZE;
++i; break; /* Exit inner for() */
} else {
/* Else we must have a Content-Length header */
p1 = (char *)AnodeDictionary_get(&(client->response.headers),"content-length");
if (!p1) {
/* No chunked or content length is not supported */
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_INVALID_RESPONSE;
AnodeHttpClient_close_and_fail(client);
return;
} else {
/* Enter block read mode with content length */
l = strtol(p1,(char **)0,10);
if (l <= 0) {
/* Zero length data is all done... */
client->impl.expecting_response_length = 0;
client->impl.read_mode = ANODE_HTTP_READ_MODE_WAITING;
if (client->keepalive)
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_KEEPALIVE;
else {
client->impl.transport_engine->tcp_close(client->impl.transport_engine,client->impl.tcp_connection);
client->impl.tcp_connection = (AnodeTransportTcpConnection *)0;
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CLOSED;
}
if (client->handler)
client->handler(client);
if (client->impl.freed)
return;
++i; break; /* Exit inner for() */
} else {
/* Else start reading... */
client->impl.expecting_response_length = (unsigned int)l;
client->impl.read_mode = ANODE_HTTP_READ_MODE_BLOCK;
++i; break; /* Exit inner for() */
}
}
}
} else {
/* HEAD clients or non-200 codes get headers only */
client->impl.expecting_response_length = 0;
client->impl.read_mode = ANODE_HTTP_READ_MODE_WAITING;
if (client->keepalive)
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_KEEPALIVE;
else {
client->impl.transport_engine->tcp_close(client->impl.transport_engine,client->impl.tcp_connection);
client->impl.tcp_connection = (AnodeTransportTcpConnection *)0;
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CLOSED;
}
if (client->handler)
client->handler(client);
if (client->impl.freed)
return;
++i; break; /* Exit inner for() */
}
}
} else {
/* Otherwise this is another header, add to dictionary */
AnodeDictionary_read(
&(client->response.headers),
client->impl.header_line_buf,
"\r\n",
": \t",
"",
(char)0,
1,
1
);
}
} else {
client->impl.header_line_buf[client->impl.header_line_buf_ptr++] = ((const char *)data)[i];
if (client->impl.header_line_buf_ptr >= sizeof(client->impl.header_line_buf)) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_INVALID_RESPONSE;
AnodeHttpClient_close_and_fail(client);
return;
}
}
}
break;
case ANODE_HTTP_READ_MODE_BLOCK:
if ((client->response.data_length + client->impl.expecting_response_length) > client->impl.response_data_capacity)
client->response.data = realloc(client->response.data,client->impl.response_data_capacity = (client->response.data_length + client->impl.expecting_response_length));
for(;((i<data_length)&&(client->impl.expecting_response_length));++i) {
((char *)client->response.data)[client->response.data_length++] = ((const char *)data)[i];
--client->impl.expecting_response_length;
}
if (!client->impl.expecting_response_length) {
client->impl.read_mode = ANODE_HTTP_READ_MODE_WAITING;
if (client->keepalive)
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_KEEPALIVE;
else {
client->impl.transport_engine->tcp_close(client->impl.transport_engine,client->impl.tcp_connection);
client->impl.tcp_connection = (AnodeTransportTcpConnection *)0;
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CLOSED;
}
if (client->handler)
client->handler(client);
if (client->impl.freed)
return;
}
break;
case ANODE_HTTP_READ_MODE_CHUNKED_CHUNK_SIZE:
for(;i<data_length;++i) {
if (((const char *)data)[i] == '\n') {
client->impl.header_line_buf[client->impl.header_line_buf_ptr] = (char)0;
client->impl.header_line_buf_ptr = 0;
p1 = client->impl.header_line_buf;
while (*p1) {
if ((*p1 == ';')||(*p1 == ' ')||(*p1 == '\r')||(*p1 == '\n')||(*p1 == '\t')) {
*p1 = (char)0;
break;
} else ++p1;
}
if (client->impl.header_line_buf[0]) {
l = strtol(client->impl.header_line_buf,(char **)0,16);
if (l <= 0) {
/* Zero length ends chunked and enters footer mode */
client->impl.expecting_response_length = 0;
client->impl.read_mode = ANODE_HTTP_READ_MODE_CHUNKED_FOOTER;
} else {
/* Otherwise the next chunk is to be read */
client->impl.expecting_response_length = (unsigned int)l;
client->impl.read_mode = ANODE_HTTP_READ_MODE_CHUNKED_DATA;
}
++i; break; /* Exit inner for() */
}
} else {
client->impl.header_line_buf[client->impl.header_line_buf_ptr++] = ((const char *)data)[i];
if (client->impl.header_line_buf_ptr >= sizeof(client->impl.header_line_buf)) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_INVALID_RESPONSE;
AnodeHttpClient_close_and_fail(client);
return;
}
}
}
break;
case ANODE_HTTP_READ_MODE_CHUNKED_DATA:
if ((client->response.data_length + client->impl.expecting_response_length) > client->impl.response_data_capacity)
client->response.data = realloc(client->response.data,client->impl.response_data_capacity = (client->response.data_length + client->impl.expecting_response_length));
for(;((i<data_length)&&(client->impl.expecting_response_length));++i) {
((char *)client->response.data)[client->response.data_length++] = ((const char *)data)[i];
--client->impl.expecting_response_length;
}
if (!client->impl.expecting_response_length)
client->impl.read_mode = ANODE_HTTP_READ_MODE_CHUNKED_CHUNK_SIZE;
break;
}
}
}
static void AnodeHttpClient_tcp_available_for_write_handler(
AnodeTransportEngine *transport,
AnodeTransportTcpConnection *connection)
{
struct AnodeHttpClient *client;
unsigned int i,j;
int n;
if (!(client = (struct AnodeHttpClient *)(connection->ptr)))
return;
if (client->impl.freed) {
transport->tcp_close(transport,connection);
return;
}
if (client->impl.phase == ANODE_HTTP_REQUEST_PHASE_SEND) {
n = client->impl.transport_engine->tcp_send(client->impl.transport_engine,client->impl.tcp_connection,(const void *)client->impl.outbuf,(int)client->impl.outbuf_len);
if (n < 0) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_SERVER_CLOSED_CONNECTION;
AnodeHttpClient_close_and_fail(client);
} else if (n > 0) {
for(i=0,j=(client->impl.outbuf_len - (unsigned int)n);i<j;++i)
client->impl.outbuf[i] = client->impl.outbuf[i + (unsigned int)n];
client->impl.outbuf_len -= (unsigned int)n;
if ((client->method == ANODE_HTTP_POST)&&(client->data)&&(client->data_length)) {
i = sizeof(client->impl.outbuf) - client->impl.outbuf_len;
j = client->data_length - client->impl.request_data_ptr;
if (i > j)
i = j;
Anode_memcpy((client->impl.outbuf + client->impl.outbuf_len),client->data,i);
client->impl.request_data_ptr += i;
client->impl.outbuf_len += i;
}
if (!client->impl.outbuf_len) {
client->impl.transport_engine->tcp_stop_writing(client->impl.transport_engine,client->impl.tcp_connection);
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_RECEIVE;
}
}
} else client->impl.transport_engine->tcp_stop_writing(client->impl.transport_engine,client->impl.tcp_connection);
}
static void AnodeHttpClient_dns_result_handler(
AnodeTransportEngine *transport,
void *ptr,
int error_code,
const char *name,
const AnodeTransportIpAddress *ip_addresses,
unsigned int ip_address_count,
const AnodeAddress *anode_address)
{
struct AnodeHttpClient *client;
AnodeTransportIpEndpoint to_endpoint;
if (!(client = (struct AnodeHttpClient *)ptr))
return;
if (client->impl.freed)
return;
if ((error_code)||(!ip_address_count)) {
if (client->impl.phase == ANODE_HTTP_REQUEST_PHASE_RESOLVE) {
client->response.code = ANODE_HTTP_SPECIAL_RESPONSE_DNS_RESOLVE_FAILED;
AnodeHttpClient_close_and_fail(client);
}
} else {
client->impl.phase = ANODE_HTTP_REQUEST_PHASE_CONNECT;
Anode_memcpy(&to_endpoint.address,ip_addresses,sizeof(AnodeTransportIpAddress));
to_endpoint.port = (client->uri.port > 0) ? client->uri.port : 80;
client->impl.transport_engine->tcp_connect(
client->impl.transport_engine,
client,
&AnodeHttpClient_tcp_outgoing_connect_handler,
&AnodeHttpClient_tcp_connection_terminated_handler,
&AnodeHttpClient_tcp_receive_handler,
&AnodeHttpClient_tcp_available_for_write_handler,
&to_endpoint);
}
}
struct AnodeHttpClient *AnodeHttpClient_new(AnodeTransportEngine *transport_engine)
{
struct AnodeHttpClient *req = malloc(sizeof(struct AnodeHttpClient));
Anode_zero(req,sizeof(struct AnodeHttpClient));
AnodeDictionary_init(&(req->headers),0);
AnodeDictionary_init(&(req->response.headers),0);
req->impl.transport_engine = transport_engine;
return req;
}
void AnodeHttpClient_send(struct AnodeHttpClient *client)
{
client->response.code = 0;
client->response.data_length = 0;
AnodeDictionary_clear(&(client->response.headers));
client->impl.request_data_ptr = 0;
client->impl.expecting_response_length = 0;
client->impl.read_mode = ANODE_HTTP_READ_MODE_WAITING;
client->impl.outbuf_len = 0;
if (!client->impl.tcp_connection) {
client->impl.transport_engine->dns_resolve(
client->impl.transport_engine,
&AnodeHttpClient_dns_result_handler,
client,
client->uri.host,
ANODE_TRANSPORT_DNS_QUERY_ALWAYS,
ANODE_TRANSPORT_DNS_QUERY_IF_NO_PREVIOUS,
ANODE_TRANSPORT_DNS_QUERY_NEVER);
} else AnodeHttpClient_do_initiate_client(client);
}
void AnodeHttpClient_free(struct AnodeHttpClient *client)
{
AnodeDictionary_destroy(&(client->headers));
AnodeDictionary_destroy(&(client->response.headers));
if (client->impl.tcp_connection) {
client->impl.transport_engine->tcp_close(client->impl.transport_engine,client->impl.tcp_connection);
client->impl.tcp_connection = (AnodeTransportTcpConnection *)0;
}
if (client->response.data)
free(client->response.data);
client->impl.freed = 1;
client->impl.transport_engine->run_later(client->impl.transport_engine,client,&free);
}

View File

@ -0,0 +1,200 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_HTTP_CLIENT_H
#define _ANODE_HTTP_CLIENT_H
#include <stdio.h>
#include <stdlib.h>
#include "dictionary.h"
#include "../anode.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* HTTP request type
*/
enum AnodeHttpClientRequestMethod
{
ANODE_HTTP_GET = 0,
ANODE_HTTP_HEAD = 1,
ANODE_HTTP_POST = 2
};
/*
* Special response codes to indicate I/O errors
*/
#define ANODE_HTTP_SPECIAL_RESPONSE_DNS_RESOLVE_FAILED -1
#define ANODE_HTTP_SPECIAL_RESPONSE_CONNECT_FAILED -2
#define ANODE_HTTP_SPECIAL_RESPONSE_HEADERS_TOO_LARGE -3
#define ANODE_HTTP_SPECIAL_RESPONSE_SERVER_CLOSED_CONNECTION -4
#define ANODE_HTTP_SPECIAL_RESPONSE_INVALID_RESPONSE -5
/**
* Simple HTTP client
*/
struct AnodeHttpClient
{
/**
* Request URI
*/
AnodeURI uri;
/**
* Request method: GET, PUT, HEAD, or POST
*/
enum AnodeHttpClientRequestMethod method;
/**
* Data for POST requests
*
* It is your responsibility to manage and/or free this pointer. The HTTP
* client only reads from it.
*/
const void *data;
unsigned int data_length;
/**
* Content type for data, or null for application/x-www-form-urlencoded
*/
const char *data_content_type;
/**
* Set to non-zero to use HTTP connection keepalive
*
* If keepalive is enabled, this request can be modified and re-used and
* its associated connection will stay open (being reopened if needed)
* until it is freed.
*
* Note that this client is too dumb to pool connections and pick them on
* the basis of host. Keepalive mode should only be set if the next request
* will be from the same host and port, otherwise you will get a '404'.
*/
int keepalive;
/**
* Function pointer to be called when request is complete (or fails)
*/
void (*handler)(struct AnodeHttpClient *);
/**
* Two arbitrary pointers that can be stored here for use by the handler.
* These are not accessed or modified by the client.
*/
void *ptr[2];
/**
* Request headers
*/
struct AnodeDictionary headers;
struct {
/**
* Response code, set on completion or failure before handler is called
*
* Also check for the special response codes defined in http_client.h as
* these negative codes indicate network or other errors.
*/
int code;
/**
* Response data, for GET and POST requests
*/
void *data;
/**
* Length of response data
*/
unsigned int data_length;
/**
* Response headers
*/
struct AnodeDictionary headers;
} response;
/**
* Internal fields used by implementation
*/
struct {
/* Transport engine being used by request */
AnodeTransportEngine *transport_engine;
/* Connection to which request has been sent, or null if none */
struct AnodeHttpConnection *connection;
/* Buffer for reading chunked mode chunk lines (can't use data buf) */
char header_line_buf[256];
unsigned int header_line_buf_ptr;
/* Where are we in sending request data? */
unsigned int request_data_ptr;
/* Capacity of response_data buffer */
unsigned int response_data_capacity;
/* How much response data are we currently expecting? */
/* This is content-length in block mode or chunk length in chunked mode */
unsigned int expecting_response_length;
/* Read mode */
enum {
ANODE_HTTP_READ_MODE_WAITING = 0,
ANODE_HTTP_READ_MODE_HEADERS = 1,
ANODE_HTTP_READ_MODE_BLOCK = 2,
ANODE_HTTP_READ_MODE_CHUNKED_CHUNK_SIZE = 3,
ANODE_HTTP_READ_MODE_CHUNKED_DATA = 4,
ANODE_HTTP_READ_MODE_CHUNKED_FOOTER = 5
} read_mode;
/* Connection from transport engine */
AnodeTransportTcpConnection *tcp_connection;
/* Write buffer */
unsigned char outbuf[16384];
unsigned int outbuf_len;
/* Phase of request state machine */
enum {
ANODE_HTTP_REQUEST_PHASE_RESOLVE = 0,
ANODE_HTTP_REQUEST_PHASE_CONNECT = 1,
ANODE_HTTP_REQUEST_PHASE_SEND = 2,
ANODE_HTTP_REQUEST_PHASE_RECEIVE = 3,
ANODE_HTTP_REQUEST_PHASE_KEEPALIVE = 4,
ANODE_HTTP_REQUEST_PHASE_CLOSED = 5
} phase;
/* Has request object been freed? */
int freed;
/**
* Pointer used internally for putting requests into linked lists
*/
struct AnodeHttpClient *next;
} impl;
};
struct AnodeHttpClient *AnodeHttpClient_new(AnodeTransportEngine *transport_engine);
void AnodeHttpClient_send(struct AnodeHttpClient *client);
void AnodeHttpClient_free(struct AnodeHttpClient *client);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,190 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc.h"
#include "types.h"
static const char Anode_hex_chars[16] = {
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'
};
static const char Anode_base32_chars[32] = {
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
'r','s','t','u','v','w','x','y','z','2','3','4','5','6','7'
};
static const unsigned char Anode_base32_bits[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,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,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
/* Table for converting ASCII chars to lower case */
const unsigned char Anode_ascii_tolower_table[256] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
void Anode_trim(char *s)
{
char *dest = s;
char *last;
while ((*s)&&((*s == ' ')||(*s == '\t')||(*s == '\r')||(*s == '\n')))
++s;
last = s;
while ((*dest = *s)) {
if ((*dest != ' ')&&(*dest != '\t')&&(*dest != '\r')&&(*dest != '\n'))
last = dest;
++dest;
++s;
}
if (*last)
*(++last) = (char)0;
}
unsigned int Anode_rand()
{
static volatile int need_seed = 1;
if (need_seed) {
need_seed = 0;
srandom((unsigned long)Anode_time64());
}
return (unsigned int)random();
}
void Anode_to_hex(const unsigned char *b,unsigned int len,char *h,unsigned int hlen)
{
unsigned int i;
if ((len * 2) >= hlen)
len = (hlen - 1) / 2;
for(i=0;i<len;++i) {
*(h++) = Anode_hex_chars[b[i] >> 4];
*(h++) = Anode_hex_chars[b[i] & 0xf];
}
*h = (char)0;
}
void Anode_from_hex(const char *h,unsigned char *b,unsigned int blen)
{
unsigned char *end = b + blen;
unsigned char v = (unsigned char)0;
while (b != end) {
switch(*(h++)) {
case '0': v = 0x00; break;
case '1': v = 0x10; break;
case '2': v = 0x20; break;
case '3': v = 0x30; break;
case '4': v = 0x40; break;
case '5': v = 0x50; break;
case '6': v = 0x60; break;
case '7': v = 0x70; break;
case '8': v = 0x80; break;
case '9': v = 0x90; break;
case 'a': v = 0xa0; break;
case 'b': v = 0xb0; break;
case 'c': v = 0xc0; break;
case 'd': v = 0xd0; break;
case 'e': v = 0xe0; break;
case 'f': v = 0xf0; break;
default: return;
}
switch(*(h++)) {
case '0': v |= 0x00; break;
case '1': v |= 0x01; break;
case '2': v |= 0x02; break;
case '3': v |= 0x03; break;
case '4': v |= 0x04; break;
case '5': v |= 0x05; break;
case '6': v |= 0x06; break;
case '7': v |= 0x07; break;
case '8': v |= 0x08; break;
case '9': v |= 0x09; break;
case 'a': v |= 0x0a; break;
case 'b': v |= 0x0b; break;
case 'c': v |= 0x0c; break;
case 'd': v |= 0x0d; break;
case 'e': v |= 0x0e; break;
case 'f': v |= 0x0f; break;
default: return;
}
*(b++) = v;
}
}
void Anode_base32_5_to_8(const unsigned char *in,char *out)
{
out[0] = Anode_base32_chars[(in[0]) >> 3];
out[1] = Anode_base32_chars[(in[0] & 0x07) << 2 | (in[1] & 0xc0) >> 6];
out[2] = Anode_base32_chars[(in[1] & 0x3e) >> 1];
out[3] = Anode_base32_chars[(in[1] & 0x01) << 4 | (in[2] & 0xf0) >> 4];
out[4] = Anode_base32_chars[(in[2] & 0x0f) << 1 | (in[3] & 0x80) >> 7];
out[5] = Anode_base32_chars[(in[3] & 0x7c) >> 2];
out[6] = Anode_base32_chars[(in[3] & 0x03) << 3 | (in[4] & 0xe0) >> 5];
out[7] = Anode_base32_chars[(in[4] & 0x1f)];
}
void Anode_base32_8_to_5(const char *in,unsigned char *out)
{
out[0] = ((Anode_base32_bits[(unsigned int)in[0]]) << 3) | (Anode_base32_bits[(unsigned int)in[1]] & 0x1C) >> 2;
out[1] = ((Anode_base32_bits[(unsigned int)in[1]] & 0x03) << 6) | (Anode_base32_bits[(unsigned int)in[2]]) << 1 | (Anode_base32_bits[(unsigned int)in[3]] & 0x10) >> 4;
out[2] = ((Anode_base32_bits[(unsigned int)in[3]] & 0x0F) << 4) | (Anode_base32_bits[(unsigned int)in[4]] & 0x1E) >> 1;
out[3] = ((Anode_base32_bits[(unsigned int)in[4]] & 0x01) << 7) | (Anode_base32_bits[(unsigned int)in[5]]) << 2 | (Anode_base32_bits[(unsigned int)in[6]] & 0x18) >> 3;
out[4] = ((Anode_base32_bits[(unsigned int)in[6]] & 0x07) << 5) | (Anode_base32_bits[(unsigned int)in[7]]);
}

View File

@ -0,0 +1,193 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This contains miscellaneous functions, including some re-implementations
* of some functions from string.h. This is to help us port to some platforms
* (cough Windows Mobile cough) that lack a lot of the basic C library. */
#ifndef _ANODE_MISC_H
#define _ANODE_MISC_H
#include <time.h>
#include <sys/time.h>
#include "types.h"
#ifndef ANODE_NO_STRING_H
#include <string.h>
#include <stdlib.h>
#endif
/* Table mapping ASCII characters to themselves or their lower case */
extern const unsigned char Anode_ascii_tolower_table[256];
/* Get the lower case version of an ASCII char */
#define Anode_tolower(c) ((char)Anode_ascii_tolower_table[((unsigned long)((unsigned char)(c)))])
/* Test strings for equality, return nonzero if equal */
static inline unsigned int Anode_streq(const char *restrict a,const char *restrict b)
{
if ((!a)||(!b))
return 0;
while (*a == *(b++)) {
if (!*(a++))
return 1;
}
return 0;
}
/* Equality test ignoring (ASCII) case */
static inline unsigned int Anode_strcaseeq(const char *restrict a,const char *restrict b)
{
if ((!a)||(!b))
return 0;
while (Anode_tolower(*a) == Anode_tolower(*(b++))) {
if (!*(a++))
return 1;
}
return 0;
}
/* Safe c-string copy, ensuring that dest[] always ends with zero */
static inline void Anode_str_copy(char *restrict dest,const char *restrict src,unsigned int dest_size)
{
char *restrict dest_end = dest + (dest_size - 1);
while ((*src)&&(dest != dest_end))
*(dest++) = *(src++);
*dest = (char)0;
}
/* Simple memcpy() */
#ifdef ANODE_NO_STRING_H
static inline void Anode_memcpy(void *restrict dest,const void *restrict src,unsigned int len)
{
unsigned int i;
for(i=0;i<len;++i)
((unsigned char *restrict)dest)[i] = ((const unsigned char *restrict)src)[i];
}
#else
#define Anode_memcpy(d,s,l) memcpy((d),(s),(l))
#endif
/* Memory test for equality */
#ifdef ANODE_NO_STRING_H
static inline unsigned int Anode_mem_eq(const void *restrict a,const void *restrict b,unsigned int len)
{
unsigned int i;
for(i=0;i<len;++i) {
if (((const unsigned char *restrict)a)[i] != ((const unsigned char *restrict)b)[i])
return 0;
}
return 1;
}
#else
#define Anode_mem_eq(a,b,l) (!memcmp((a),(b),(l)))
#endif
/* Zero memory */
#ifdef ANODE_NO_STRING_H
static inline void Anode_zero(void *restrict ptr,unsigned int len)
{
unsigned int i;
for(i=0;i<len;++i)
((unsigned char *restrict)ptr)[i] = (unsigned char)0;
}
#else
#define Anode_zero(p,l) memset((p),0,(l))
#endif
/* Get a pointer to the first occurrance of a character in a string */
#ifdef ANODE_NO_STRING_H
static inline const char *Anode_strchr(const char *s,char c)
{
while (*s) {
if (*s == c)
return s;
++s;
}
return (char *)0;
}
#else
#define Anode_strchr(s,c) strchr((s),(c))
#endif
static inline unsigned int Anode_count_char(const char *s,char c)
{
unsigned int cnt = 0;
while (s) {
if (*s == c)
++cnt;
++s;
}
return cnt;
}
/* Strip all of a given set of characters from a string */
static inline void Anode_strip_all(char *s,const char *restrict schars)
{
char *d = s;
while (*s) {
if (!Anode_strchr(schars,*s))
*(d++) = *s;
++s;
}
*d = (char)0;
}
/* Trim whitespace from beginning and end of string */
void Anode_trim(char *s);
/* Get the length of a string */
#ifdef ANODE_NO_STRING_H
static inline unsigned int Anode_strlen(const char *s)
{
const char *ptr = s;
while (*ptr) ++ptr;
return (unsigned int)(ptr - s);
}
#else
#define Anode_strlen(s) strlen((s))
#endif
/* Returns number of milliseconds since the epoch (Java-style) */
static inline uint64_t Anode_time64()
{
struct timeval tv;
gettimeofday(&tv,(void *)0);
return ( (((uint64_t)tv.tv_sec) / 1000ULL) + ((uint64_t)(tv.tv_usec / 1000ULL)) );
}
/* Returns number of seconds since the epoch (*nix style) */
static inline unsigned long Anode_time()
{
struct timeval tv;
gettimeofday(&tv,(void *)0);
return (unsigned long)tv.tv_sec;
}
/* Simple random function, not cryptographically safe */
unsigned int Anode_rand();
/* Fast hex/ascii conversion */
void Anode_to_hex(const unsigned char *b,unsigned int len,char *h,unsigned int hlen);
void Anode_from_hex(const char *h,unsigned char *b,unsigned int blen);
/* Convert back and forth from base32 encoding */
/* 5 bytes -> 8 base32 characters and vice versa */
void Anode_base32_5_to_8(const unsigned char *in,char *out);
void Anode_base32_8_to_5(const char *in,unsigned char *out);
#endif

View File

@ -0,0 +1,34 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_MUTEX_H
#define _ANODE_MUTEX_H
#ifdef WINDOWS
#else /* WINDOWS */
#include <pthread.h>
#define AnodeMutex pthread_mutex_t
#define AnodeMutex_init(m) pthread_mutex_init((m),(const pthread_mutexattr_t *)0)
#define AnodeMutex_destroy(m) pthread_mutex_destroy((m))
#define AnodeMutex_lock(m) pthread_mutex_lock((m))
#define AnodeMutex_unlock(m) pthread_mutex_unlock((m))
#endif /* WINDOWS */
#endif

View File

@ -0,0 +1,58 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "thread.h"
#include <stdlib.h>
#ifdef WINDOWS
#else /* not WINDOWS */
struct _AnodeThread
{
void (*func)(void *);
void *arg;
int wait_for_join;
pthread_t thread;
};
static void *_AnodeThread_main(void *arg)
{
((struct _AnodeThread *)arg)->func(((struct _AnodeThread *)arg)->arg);
if (!((struct _AnodeThread *)arg)->wait_for_join)
free(arg);
return (void *)0;
}
AnodeThread *AnodeThread_create(void (*func)(void *),void *arg,int wait_for_join)
{
struct _AnodeThread *t = malloc(sizeof(struct _AnodeThread));
t->func = func;
t->arg = arg;
t->wait_for_join = wait_for_join;
pthread_create(&t->thread,(const pthread_attr_t *)0,&_AnodeThread_main,(void *)t);
if (!wait_for_join)
pthread_detach(t->thread);
return (AnodeThread *)t;
}
void AnodeThread_join(AnodeThread *thread)
{
pthread_join(((struct _AnodeThread *)thread)->thread,(void **)0);
free((void *)thread);
}
#endif /* WINDOWS / not WINDOWS */

View File

@ -0,0 +1,65 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_THREAD_H
#define _ANODE_THREAD_H
#ifdef WINDOWS
#include <windows.h>
#include <thread.h>
typedef DWORD AnodeThreadId;
#else /* not WINDOWS */
#include <pthread.h>
typedef pthread_t AnodeThreadId;
#define AnodeThread_self() pthread_self()
#define AnodeThreadId_equal(a,b) pthread_equal((pthread_t)(a),(pthread_t)(b))
#endif
typedef void AnodeThread;
/**
* Create and launch a new thread
*
* If wait_for_join is true (nonzero), the thread can and must be joined. The
* thread object won't be freed until join is called and returns. If
* wait_for_join is false, the thread object frees itself automatically on
* termination.
*
* If wait_for_join is false (zero), there is really no need to keep track of
* the thread object.
*
* @param func Function to call as thread main
* @param arg Argument to pass to function
* @param wait_for_join If false, thread deletes itself when it terminates
*/
AnodeThread *AnodeThread_create(void (*func)(void *),void *arg,int wait_for_join);
/**
* Wait for a thread to terminate and delete thread object
*
* This can only be used for threads created with wait_for_join set to true.
* The thread object is no longer valid after this call.
*
* @param thread Thread to wait for termination and delete
*/
void AnodeThread_join(AnodeThread *thread);
#endif

View File

@ -0,0 +1,25 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ANODE_TYPES_H
#define _ANODE_TYPES_H
#ifdef WINDOWS
#else
#include <stdint.h>
#endif
#endif

View File

@ -0,0 +1,136 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <netinet/in.h>
#include <arpa/inet.h>
#include "impl/misc.h"
#include "impl/types.h"
#include "anode.h"
const AnodeNetworkAddress AnodeNetworkAddress_ANY4 = {
ANODE_NETWORK_ADDRESS_IPV4,
{ 0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
};
const AnodeNetworkAddress AnodeNetworkAddress_ANY6 = {
ANODE_NETWORK_ADDRESS_IPV6,
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
};
const AnodeNetworkAddress AnodeNetworkAddress_LOCAL4 = {
ANODE_NETWORK_ADDRESS_IPV4,
{ 127,0,0,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
};
const AnodeNetworkAddress AnodeNetworkAddress_LOCAL6 = {
ANODE_NETWORK_ADDRESS_IPV6,
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
};
int AnodeNetworkAddress_to_string(const AnodeNetworkAddress *address,char *buf,int len)
{
const char *s;
switch(address->type) {
case ANODE_NETWORK_ADDRESS_IPV4:
s = inet_ntop(AF_INET,(const void *)address->bits,buf,len);
if (s)
return Anode_strlen(s);
else return ANODE_ERR_INVALID_ARGUMENT;
break;
case ANODE_NETWORK_ADDRESS_IPV6:
s = inet_ntop(AF_INET6,address->bits,buf,len);
if (s)
return Anode_strlen(s);
else return ANODE_ERR_INVALID_ARGUMENT;
/*
case ANODE_NETWORK_ADDRESS_ETHERNET:
break;
case ANODE_NETWORK_ADDRESS_USB:
break;
case ANODE_NETWORK_ADDRESS_BLUETOOTH:
break;
case ANODE_NETWORK_ADDRESS_IPC:
break;
case ANODE_NETWORK_ADDRESS_80211S:
break;
case ANODE_NETWORK_ADDRESS_SERIAL:
break;
*/
case ANODE_NETWORK_ADDRESS_ANODE_256_40:
return AnodeAddress_to_string((const AnodeAddress *)address->bits,buf,len);
default:
return ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED;
}
}
int AnodeNetworkAddress_from_string(const char *str,AnodeNetworkAddress *address)
{
unsigned int dots = Anode_count_char(str,'.');
unsigned int colons = Anode_count_char(str,':');
if ((dots == 3)&&(!colons)) {
address->type = ANODE_NETWORK_ADDRESS_IPV4;
if (inet_pton(AF_INET,str,address->bits) > 0)
return 0;
else return ANODE_ERR_INVALID_ARGUMENT;
} else if ((colons)&&(!dots)) {
address->type = ANODE_NETWORK_ADDRESS_IPV6;
if (inet_pton(AF_INET6,str,address->bits) > 0)
return 0;
else return ANODE_ERR_INVALID_ARGUMENT;
} else {
address->type = ANODE_NETWORK_ADDRESS_ANODE_256_40;
return AnodeAddress_from_string(str,(AnodeAddress *)address->bits);
}
}
int AnodeNetworkEndpoint_from_sockaddr(const void *sockaddr,AnodeNetworkEndpoint *endpoint)
{
switch(((struct sockaddr_storage *)sockaddr)->ss_family) {
case AF_INET:
*((uint32_t *)endpoint->address.bits) = (uint32_t)(((struct sockaddr_in *)sockaddr)->sin_addr.s_addr);
endpoint->port = (int)ntohs(((struct sockaddr_in *)sockaddr)->sin_port);
return 0;
case AF_INET6:
Anode_memcpy(endpoint->address.bits,((struct sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr,16);
endpoint->port = (int)ntohs(((struct sockaddr_in6 *)sockaddr)->sin6_port);
return 0;
default:
return ANODE_ERR_INVALID_ARGUMENT;
}
}
int AnodeNetworkEndpoint_to_sockaddr(const AnodeNetworkEndpoint *endpoint,void *sockaddr,int sockaddr_len)
{
switch(endpoint->address.type) {
case ANODE_NETWORK_ADDRESS_IPV4:
if (sockaddr_len < (int)sizeof(struct sockaddr_in))
return ANODE_ERR_BUFFER_TOO_SMALL;
Anode_zero(sockaddr,sizeof(struct sockaddr_in));
((struct sockaddr_in *)sockaddr)->sin_family = AF_INET;
((struct sockaddr_in *)sockaddr)->sin_port = htons((uint16_t)endpoint->port);
((struct sockaddr_in *)sockaddr)->sin_addr.s_addr = *((uint32_t *)endpoint->address.bits);
return 0;
case ANODE_NETWORK_ADDRESS_IPV6:
if (sockaddr_len < (int)sizeof(struct sockaddr_in6))
return ANODE_ERR_BUFFER_TOO_SMALL;
Anode_zero(sockaddr,sizeof(struct sockaddr_in6));
((struct sockaddr_in6 *)sockaddr)->sin6_family = AF_INET6;
((struct sockaddr_in6 *)sockaddr)->sin6_port = htons((uint16_t)endpoint->port);
Anode_memcpy(((struct sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr,endpoint->address.bits,16);
return 0;
default:
return ANODE_ERR_INVALID_ARGUMENT;
}
}

View File

@ -0,0 +1,88 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <stdio.h>
#include "impl/aes.h"
#include "impl/misc.h"
#include "anode.h"
#ifdef WINDOWS
#include <windows.h>
#include <wincrypt.h>
#endif
struct AnodeSecureRandomImpl
{
AnodeAesExpandedKey key;
unsigned char state[ANODE_AES_BLOCK_SIZE];
unsigned char block[ANODE_AES_BLOCK_SIZE];
unsigned int ptr;
};
AnodeSecureRandom *AnodeSecureRandom_new()
{
unsigned char keybuf[ANODE_AES_KEY_SIZE + ANODE_AES_BLOCK_SIZE + ANODE_AES_BLOCK_SIZE];
unsigned int i;
struct AnodeSecureRandomImpl *srng;
#ifdef WINDOWS
HCRYPTPROV hProv;
if (CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT|CRYPT_SILENT)) {
CryptGenRandom(hProv,sizeof(keybuf),keybuf);
CryptReleaseContext(hProv,0);
}
#else
FILE *urandf = fopen("/dev/urandom","rb");
if (urandf) {
fread((void *)keybuf,sizeof(keybuf),1,urandf);
fclose(urandf);
}
#endif
for(i=0;i<sizeof(keybuf);++i)
keybuf[i] ^= (unsigned char)(Anode_rand() >> 5);
srng = malloc(sizeof(struct AnodeSecureRandomImpl));
Anode_aes256_expand_key(keybuf,&srng->key);
for(i=0;i<ANODE_AES_BLOCK_SIZE;++i)
srng->state[i] = keybuf[ANODE_AES_KEY_SIZE + i];
for(i=0;i<ANODE_AES_BLOCK_SIZE;++i)
srng->block[i] = keybuf[ANODE_AES_KEY_SIZE + ANODE_AES_KEY_SIZE + i];
srng->ptr = ANODE_AES_BLOCK_SIZE;
return (AnodeSecureRandom *)srng;
}
void AnodeSecureRandom_gen_bytes(AnodeSecureRandom *srng,void *buf,long count)
{
long i,j;
for(i=0;i<count;++i) {
if (((struct AnodeSecureRandomImpl *)srng)->ptr == ANODE_AES_BLOCK_SIZE) {
Anode_aes256_encrypt(&((struct AnodeSecureRandomImpl *)srng)->key,((struct AnodeSecureRandomImpl *)srng)->state,((struct AnodeSecureRandomImpl *)srng)->state);
for(j=0;j<ANODE_AES_KEY_SIZE;++j)
((struct AnodeSecureRandomImpl *)srng)->block[j] ^= ((struct AnodeSecureRandomImpl *)srng)->state[j];
((struct AnodeSecureRandomImpl *)srng)->ptr = 0;
}
((unsigned char *)buf)[i] = ((struct AnodeSecureRandomImpl *)srng)->block[((struct AnodeSecureRandomImpl *)srng)->ptr++];
}
}
void AnodeSecureRandom_delete(AnodeSecureRandom *srng)
{
free(srng);
}

View File

@ -0,0 +1,948 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <netdb.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "anode.h"
#include "impl/mutex.h"
#include "impl/thread.h"
#include "impl/misc.h"
#include "impl/dns_txt.h"
#ifdef WINDOWS
#include <windows.h>
#include <winsock2.h>
#define AnodeSystemTransport__close_socket(s) closesocket((s))
#define ANODE_USE_SELECT 1
#else
#include <poll.h>
#include <unistd.h>
#define AnodeSystemTransport__close_socket(s) close((s))
#endif
static const char *AnodeSystemTransport_CLASS = "SystemTransport";
/* ======================================================================== */
struct AnodeSystemTransport;
struct AnodeSystemTransport_AnodeSocket
{
AnodeSocket base; /* must be first */
unsigned int entry_idx;
};
#define ANODE_SYSTEM_TRANSPORT_DNS_MAX_RESULTS 16
struct AnodeSystemTransport__dns_request
{
struct AnodeSystemTransport__dns_request *next;
AnodeThread *thread;
struct AnodeSystemTransport *owner;
void (*event_handler)(const AnodeEvent *event);
char name[256];
enum AnodeTransportDnsIncludeMode ipv4_include_mode;
enum AnodeTransportDnsIncludeMode ipv6_include_mode;
enum AnodeTransportDnsIncludeMode anode_include_mode;
AnodeNetworkAddress addresses[ANODE_SYSTEM_TRANSPORT_DNS_MAX_RESULTS];
unsigned int address_count;
int error_code;
};
#ifdef ANODE_USE_SELECT
typedef int AnodeSystemTransport__poll_fd; /* for select() */
#else
typedef struct pollfd AnodeSystemTransport__poll_fd; /* for poll() */
#endif
struct AnodeSystemTransport
{
AnodeTransport interface; /* must be first */
AnodeTransport *base;
#ifdef ANODE_USE_SELECT
FD_SET readfds;
FD_SET writefds;
#endif
void (*default_event_handler)(const AnodeEvent *event);
AnodeSystemTransport__poll_fd *fds;
struct AnodeSystemTransport_AnodeSocket *sockets;
unsigned int fd_count;
unsigned int fd_capacity;
struct AnodeSystemTransport__dns_request *pending_dns_requests;
int invoke_pipe[2];
AnodeMutex invoke_pipe_m;
void *invoke_pipe_buf[2];
unsigned int invoke_pipe_buf_ptr;
};
/* ======================================================================== */
/* Internal helper methods */
static unsigned int AnodeSystemTransport__add_entry(struct AnodeSystemTransport *transport)
{
if ((transport->fd_count + 1) > transport->fd_capacity) {
transport->fd_capacity += 8;
transport->fds = realloc(transport->fds,sizeof(AnodeSystemTransport__poll_fd) * transport->fd_capacity);
transport->sockets = realloc(transport->sockets,sizeof(struct AnodeSystemTransport_AnodeSocket) * transport->fd_capacity);
}
return transport->fd_count++;
}
static void AnodeSystemTransport__remove_entry(struct AnodeSystemTransport *transport,const unsigned int idx)
{
unsigned int i;
--transport->fd_count;
for(i=idx;i<transport->fd_count;++i) {
Anode_memcpy(&transport->fds[i],&transport->fds[i+1],sizeof(AnodeSystemTransport__poll_fd));
Anode_memcpy(&transport->sockets[i],&transport->sockets[i+1],sizeof(struct AnodeSystemTransport_AnodeSocket));
}
if ((transport->fd_capacity - transport->fd_count) > 16) {
transport->fd_capacity -= 16;
transport->fds = realloc(transport->fds,sizeof(AnodeSystemTransport__poll_fd) * transport->fd_capacity);
transport->sockets = realloc(transport->sockets,sizeof(struct AnodeSystemTransport_AnodeSocket) * transport->fd_capacity);
}
}
static void AnodeSystemTransport__dns_invoke_on_completion(void *_dreq)
{
struct AnodeSystemTransport__dns_request *dreq = (struct AnodeSystemTransport__dns_request *)_dreq;
struct AnodeSystemTransport__dns_request *ptr,**lastnext;
AnodeThread_join(dreq->thread);
ptr = dreq->owner->pending_dns_requests;
lastnext = &dreq->owner->pending_dns_requests;
while (ptr) {
if (ptr == dreq) {
*lastnext = ptr->next;
break;
} else {
lastnext = &ptr->next;
ptr = ptr->next;
}
}
free(dreq);
}
static void AnodeSystemTransport__dns_thread_main(void *_dreq)
{
struct AnodeSystemTransport__dns_request *dreq = (struct AnodeSystemTransport__dns_request *)_dreq;
dreq->owner->interface.invoke((AnodeTransport *)dreq->owner,dreq,&AnodeSystemTransport__dns_invoke_on_completion);
}
static void AnodeSystemTransport__do_close(struct AnodeSystemTransport *transport,struct AnodeSystemTransport_AnodeSocket *sock,const int error_code,const int generate_event)
{
AnodeEvent evbuf;
int fd;
if (sock->base.class_name == AnodeSystemTransport_CLASS) {
#ifdef ANODE_USE_SELECT
fd = (int)(transport->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx]);
#else
fd = transport->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx].fd;
#endif
if ((sock->base.type == ANODE_SOCKET_STREAM_CONNECTION)&&(sock->base.state != ANODE_SOCKET_CLOSED)) {
sock->base.state = ANODE_SOCKET_CLOSED;
if (generate_event) {
evbuf.type = ANODE_TRANSPORT_EVENT_STREAM_CLOSED;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)sock;
evbuf.datagram_from = NULL;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = error_code;
evbuf.data_length = 0;
evbuf.data = NULL;
if (sock->base.event_handler)
sock->base.event_handler(&evbuf);
else if (transport->default_event_handler)
transport->default_event_handler(&evbuf);
}
}
AnodeSystemTransport__close_socket(fd);
AnodeSystemTransport__remove_entry(transport,((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx);
#ifdef ANODE_USE_SELECT
FD_CLR(sock,&THIS->readfds);
FD_CLR(sock,&THIS->writefds);
#endif
} else transport->base->close(transport->base,(AnodeSocket *)sock);
}
static int AnodeSystemTransport__populate_network_endpoint(const struct sockaddr_storage *saddr,AnodeNetworkEndpoint *ep)
{
switch(saddr->ss_family) {
case AF_INET:
ep->address.type = ANODE_NETWORK_ADDRESS_IPV4;
*((uint32_t *)ep->address.bits) = ((struct sockaddr_in *)saddr)->sin_addr.s_addr;
ep->port = ntohs(((struct sockaddr_in *)saddr)->sin_port);
return 1;
case AF_INET6:
ep->address.type = ANODE_NETWORK_ADDRESS_IPV6;
Anode_memcpy(ep->address.bits,((struct sockaddr_in6 *)saddr)->sin6_addr.s6_addr,16);
ep->port = ntohs(((struct sockaddr_in6 *)saddr)->sin6_port);
return 1;
}
return 0;
}
/* ======================================================================== */
#ifdef THIS
#undef THIS
#endif
#define THIS ((struct AnodeSystemTransport *)transport)
static void AnodeSystemTransport_invoke(AnodeTransport *transport,
void *ptr,
void (*func)(void *))
{
void *invoke_msg[2];
invoke_msg[0] = ptr;
invoke_msg[1] = (void *)func;
AnodeMutex_lock(&THIS->invoke_pipe_m);
write(THIS->invoke_pipe[1],(void *)(&invoke_msg),sizeof(invoke_msg));
AnodeMutex_unlock(&THIS->invoke_pipe_m);
}
static void AnodeSystemTransport_dns_resolve(AnodeTransport *transport,
const char *name,
void (*event_handler)(const AnodeEvent *),
enum AnodeTransportDnsIncludeMode ipv4_include_mode,
enum AnodeTransportDnsIncludeMode ipv6_include_mode,
enum AnodeTransportDnsIncludeMode anode_include_mode)
{
struct AnodeSystemTransport__dns_request *dreq = malloc(sizeof(struct AnodeSystemTransport__dns_request));
dreq->owner = THIS;
dreq->event_handler = event_handler;
Anode_str_copy(dreq->name,name,sizeof(dreq->name));
dreq->ipv4_include_mode = ipv4_include_mode;
dreq->ipv6_include_mode = ipv6_include_mode;
dreq->anode_include_mode = anode_include_mode;
dreq->address_count = 0;
dreq->error_code = 0;
dreq->next = THIS->pending_dns_requests;
THIS->pending_dns_requests = dreq;
dreq->thread = AnodeThread_create(&AnodeSystemTransport__dns_thread_main,dreq,0);
}
static AnodeSocket *AnodeSystemTransport_datagram_listen(AnodeTransport *transport,
const AnodeNetworkAddress *local_address,
int local_port,
int *error_code)
{
struct sockaddr_in sin4;
struct sockaddr_in6 sin6;
struct AnodeSystemTransport_AnodeSocket *sock;
unsigned int entry_idx;
int fd;
int tmp;
switch(local_address->type) {
case ANODE_NETWORK_ADDRESS_IPV4:
fd = socket(AF_INET,SOCK_DGRAM,0);
if (fd <= 0) {
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
tmp = 1;
setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&tmp,sizeof(tmp));
fcntl(fd,F_SETFL,O_NONBLOCK);
Anode_zero(&sin4,sizeof(struct sockaddr_in));
sin4.sin_family = AF_INET;
sin4.sin_port = htons(local_port);
sin4.sin_addr.s_addr = *((uint32_t *)local_address->bits);
if (bind(fd,(const struct sockaddr *)&sin4,sizeof(sin4))) {
AnodeSystemTransport__close_socket(fd);
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
break;
case ANODE_NETWORK_ADDRESS_IPV6:
fd = socket(AF_INET6,SOCK_DGRAM,0);
if (fd <= 0) {
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
tmp = 1; setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&tmp,sizeof(tmp));
fcntl(fd,F_SETFL,O_NONBLOCK);
#ifdef IPV6_V6ONLY
tmp = 1; setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,&tmp,sizeof(tmp));
#endif
Anode_zero(&sin6,sizeof(struct sockaddr_in6));
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(local_port);
Anode_memcpy(sin6.sin6_addr.s6_addr,local_address->bits,16);
if (bind(fd,(const struct sockaddr *)&sin6,sizeof(sin6))) {
AnodeSystemTransport__close_socket(fd);
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
break;
default:
if (THIS->base)
return THIS->base->datagram_listen(THIS->base,local_address,local_port,error_code);
else {
*error_code = ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED;
return (AnodeSocket *)0;
}
}
entry_idx = AnodeSystemTransport__add_entry(THIS);
sock = &(THIS->sockets[entry_idx]);
sock->base.type = ANODE_SOCKET_DATAGRAM;
sock->base.state = ANODE_SOCKET_OPEN;
Anode_memcpy(&sock->base.endpoint.address,local_address,sizeof(AnodeNetworkAddress));
sock->base.endpoint.port = local_port;
sock->base.class_name = AnodeSystemTransport_CLASS;
sock->base.user_ptr[0] = NULL;
sock->base.user_ptr[1] = NULL;
sock->base.event_handler = NULL;
sock->entry_idx = entry_idx;
THIS->fds[entry_idx].fd = fd;
THIS->fds[entry_idx].events = POLLIN;
THIS->fds[entry_idx].revents = 0;
*error_code = 0;
return (AnodeSocket *)sock;
}
static AnodeSocket *AnodeSystemTransport_stream_listen(AnodeTransport *transport,
const AnodeNetworkAddress *local_address,
int local_port,
int *error_code)
{
struct sockaddr_in sin4;
struct sockaddr_in6 sin6;
struct AnodeSystemTransport_AnodeSocket *sock;
unsigned int entry_idx;
int fd;
int tmp;
switch(local_address->type) {
case ANODE_NETWORK_ADDRESS_IPV4:
fd = socket(AF_INET,SOCK_STREAM,0);
if (fd < 0) {
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
fcntl(fd,F_SETFL,O_NONBLOCK);
Anode_zero(&sin4,sizeof(struct sockaddr_in));
sin4.sin_family = AF_INET;
sin4.sin_port = htons(local_port);
sin4.sin_addr.s_addr = *((uint32_t *)local_address->bits);
if (bind(fd,(const struct sockaddr *)&sin4,sizeof(sin4))) {
AnodeSystemTransport__close_socket(fd);
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
if (listen(fd,8)) {
AnodeSystemTransport__close_socket(fd);
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
break;
case ANODE_NETWORK_ADDRESS_IPV6:
fd = socket(AF_INET6,SOCK_STREAM,0);
if (fd < 0) {
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
fcntl(fd,F_SETFL,O_NONBLOCK);
#ifdef IPV6_V6ONLY
tmp = 1; setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,&tmp,sizeof(tmp));
#endif
Anode_zero(&sin6,sizeof(struct sockaddr_in6));
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(local_port);
Anode_memcpy(sin6.sin6_addr.s6_addr,local_address->bits,16);
if (bind(fd,(const struct sockaddr *)&sin6,sizeof(sin6))) {
AnodeSystemTransport__close_socket(fd);
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
if (listen(fd,8)) {
AnodeSystemTransport__close_socket(fd);
*error_code = ANODE_ERR_UNABLE_TO_BIND;
return (AnodeSocket *)0;
}
break;
default:
if (THIS->base)
return THIS->base->stream_listen(THIS->base,local_address,local_port,error_code);
else {
*error_code = ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED;
return (AnodeSocket *)0;
}
}
entry_idx = AnodeSystemTransport__add_entry(THIS);
sock = &(THIS->sockets[entry_idx]);
sock->base.type = ANODE_SOCKET_STREAM_LISTEN;
sock->base.state = ANODE_SOCKET_OPEN;
Anode_memcpy(&sock->base.endpoint.address,local_address,sizeof(AnodeNetworkAddress));
sock->base.endpoint.port = local_port;
sock->base.class_name = AnodeSystemTransport_CLASS;
sock->base.user_ptr[0] = NULL;
sock->base.user_ptr[1] = NULL;
sock->base.event_handler = NULL;
sock->entry_idx = entry_idx;
THIS->fds[entry_idx].fd = fd;
THIS->fds[entry_idx].events = POLLIN;
THIS->fds[entry_idx].revents = 0;
*error_code = 0;
return (AnodeSocket *)sock;
}
static int AnodeSystemTransport_datagram_send(AnodeTransport *transport,
AnodeSocket *sock,
const void *data,
int data_len,
const AnodeNetworkEndpoint *to_endpoint)
{
struct sockaddr_in sin4;
struct sockaddr_in6 sin6;
#ifdef ANODE_USE_SELECT
const int fd = (int)(THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx]);
#else
const int fd = THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx].fd;
#endif
switch(to_endpoint->address.type) {
case ANODE_NETWORK_ADDRESS_IPV4:
Anode_zero(&sin4,sizeof(struct sockaddr_in));
sin4.sin_family = AF_INET;
sin4.sin_port = htons((uint16_t)to_endpoint->port);
sin4.sin_addr.s_addr = *((uint32_t *)to_endpoint->address.bits);
sendto(fd,data,data_len,0,(struct sockaddr *)&sin4,sizeof(sin4));
return 0;
case ANODE_NETWORK_ADDRESS_IPV6:
Anode_zero(&sin6,sizeof(struct sockaddr_in6));
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons((uint16_t)to_endpoint->port);
Anode_memcpy(sin6.sin6_addr.s6_addr,to_endpoint->address.bits,16);
sendto(fd,data,data_len,0,(struct sockaddr *)&sin6,sizeof(sin6));
return 0;
default:
if (THIS->base)
return THIS->base->datagram_send(THIS->base,sock,data,data_len,to_endpoint);
else return ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED;
}
}
static AnodeSocket *AnodeSystemTransport_stream_connect(AnodeTransport *transport,
const AnodeNetworkEndpoint *to_endpoint,
int *error_code)
{
struct sockaddr_in sin4;
struct sockaddr_in6 sin6;
struct AnodeSystemTransport_AnodeSocket *sock;
unsigned int entry_idx;
int fd;
switch(to_endpoint->address.type) {
case ANODE_NETWORK_ADDRESS_IPV4:
Anode_zero(&sin4,sizeof(struct sockaddr_in));
sin4.sin_family = AF_INET;
sin4.sin_port = htons(to_endpoint->port);
sin4.sin_addr.s_addr = *((uint32_t *)to_endpoint->address.bits);
fd = socket(AF_INET,SOCK_STREAM,0);
if (fd < 0) {
*error_code = ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED;
return (AnodeSocket *)0;
}
fcntl(fd,F_SETFL,O_NONBLOCK);
if (connect(fd,(struct sockaddr *)&sin4,sizeof(sin4))) {
if (errno != EINPROGRESS) {
*error_code = ANODE_ERR_CONNECT_FAILED;
AnodeSystemTransport__close_socket(fd);
return (AnodeSocket *)0;
}
}
break;
case ANODE_NETWORK_ADDRESS_IPV6:
Anode_zero(&sin6,sizeof(struct sockaddr_in6));
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(to_endpoint->port);
Anode_memcpy(sin6.sin6_addr.s6_addr,to_endpoint->address.bits,16);
fd = socket(AF_INET6,SOCK_STREAM,0);
if (fd < 0) {
*error_code = ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED;
return (AnodeSocket *)0;
}
fcntl(fd,F_SETFL,O_NONBLOCK);
if (connect(fd,(struct sockaddr *)&sin6,sizeof(sin6))) {
if (errno == EINPROGRESS) {
*error_code = ANODE_ERR_CONNECT_FAILED;
AnodeSystemTransport__close_socket(fd);
return (AnodeSocket *)0;
}
}
break;
default:
if (THIS->base)
return THIS->base->stream_connect(THIS->base,to_endpoint,error_code);
else {
*error_code = ANODE_ERR_ADDRESS_TYPE_NOT_SUPPORTED;
return (AnodeSocket *)0;
}
}
entry_idx = AnodeSystemTransport__add_entry(THIS);
sock = &(THIS->sockets[entry_idx]);
sock->base.type = ANODE_SOCKET_STREAM_CONNECTION;
sock->base.state = ANODE_SOCKET_CONNECTING;
Anode_memcpy(&sock->base.endpoint,to_endpoint,sizeof(AnodeNetworkEndpoint));
sock->base.class_name = AnodeSystemTransport_CLASS;
sock->base.user_ptr[0] = NULL;
sock->base.user_ptr[1] = NULL;
sock->base.event_handler = NULL;
sock->entry_idx = entry_idx;
THIS->fds[entry_idx].fd = fd;
THIS->fds[entry_idx].events = POLLIN|POLLOUT;
THIS->fds[entry_idx].revents = 0;
return (AnodeSocket *)sock;
}
static void AnodeSystemTransport_stream_start_writing(AnodeTransport *transport,
AnodeSocket *sock)
{
if ((sock->type == ANODE_SOCKET_STREAM_CONNECTION)&&(((struct AnodeSystemTransport_AnodeSocket *)sock)->base.state == ANODE_SOCKET_OPEN)) {
if (sock->class_name == AnodeSystemTransport_CLASS) {
#ifdef ANODE_USE_SELECT
FD_SET((int)(THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx]),&THIS->writefds);
#else
THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx].events = (POLLIN|POLLOUT);
#endif
} else THIS->base->stream_start_writing(THIS->base,sock);
}
}
static void AnodeSystemTransport_stream_stop_writing(AnodeTransport *transport,
AnodeSocket *sock)
{
if ((sock->type == ANODE_SOCKET_STREAM_CONNECTION)&&(((struct AnodeSystemTransport_AnodeSocket *)sock)->base.state == ANODE_SOCKET_OPEN)) {
if (sock->class_name == AnodeSystemTransport_CLASS) {
#ifdef ANODE_USE_SELECT
FD_CLR((int)(THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx]),&THIS->writefds);
#else
THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx].events = POLLIN;
#endif
} else THIS->base->stream_stop_writing(THIS->base,sock);
}
}
static int AnodeSystemTransport_stream_send(AnodeTransport *transport,
AnodeSocket *sock,
const void *data,
int data_len)
{
int result;
if (sock->type == ANODE_SOCKET_STREAM_CONNECTION) {
if (sock->class_name == AnodeSystemTransport_CLASS) {
if (((struct AnodeSystemTransport_AnodeSocket *)sock)->base.state != ANODE_SOCKET_OPEN)
return ANODE_ERR_CONNECTION_CLOSED;
#ifdef ANODE_USE_SELECT
result = send((int)(THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx]),data,data_len,0);
#else
result = send(THIS->fds[((struct AnodeSystemTransport_AnodeSocket *)sock)->entry_idx].fd,data,data_len,0);
#endif
if (result >= 0)
return result;
else {
AnodeSystemTransport__do_close(THIS,(struct AnodeSystemTransport_AnodeSocket *)sock,ANODE_ERR_CONNECTION_CLOSED_BY_REMOTE,1);
return ANODE_ERR_CONNECTION_CLOSED;
}
} else return THIS->base->stream_send(THIS->base,sock,data,data_len);
} else return ANODE_ERR_INVALID_ARGUMENT;
}
static void AnodeSystemTransport_close(AnodeTransport *transport,
AnodeSocket *sock)
{
AnodeSystemTransport__do_close(THIS,(struct AnodeSystemTransport_AnodeSocket *)sock,0,1);
}
static void AnodeSystemTransport__poll_do_read_datagram(struct AnodeSystemTransport *transport,int fd,struct AnodeSystemTransport_AnodeSocket *sock)
{
char buf[16384];
struct sockaddr_storage fromaddr;
AnodeNetworkEndpoint tmp_ep;
AnodeEvent evbuf;
socklen_t addrlen;
int n;
addrlen = sizeof(struct sockaddr_storage);
n = recvfrom(fd,buf,sizeof(buf),0,(struct sockaddr *)&fromaddr,&addrlen);
if ((n >= 0)&&(AnodeSystemTransport__populate_network_endpoint(&fromaddr,&tmp_ep))) {
evbuf.type = ANODE_TRANSPORT_EVENT_DATAGRAM_RECEIVED;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)sock;
evbuf.datagram_from = &tmp_ep;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = 0;
evbuf.data_length = n;
evbuf.data = buf;
if (sock->base.event_handler)
sock->base.event_handler(&evbuf);
else if (transport->default_event_handler)
transport->default_event_handler(&evbuf);
}
}
static void AnodeSystemTransport__poll_do_accept_incoming_connection(struct AnodeSystemTransport *transport,int fd,struct AnodeSystemTransport_AnodeSocket *sock)
{
struct sockaddr_storage fromaddr;
AnodeNetworkEndpoint tmp_ep;
AnodeEvent evbuf;
struct AnodeSystemTransport_AnodeSocket *newsock;
socklen_t addrlen;
int n;
unsigned int entry_idx;
addrlen = sizeof(struct sockaddr_storage);
n = accept(fd,(struct sockaddr *)&fromaddr,&addrlen);
if ((n >= 0)&&(AnodeSystemTransport__populate_network_endpoint(&fromaddr,&tmp_ep))) {
entry_idx = AnodeSystemTransport__add_entry(transport);
newsock = &(transport->sockets[entry_idx]);
newsock->base.type = ANODE_SOCKET_STREAM_CONNECTION;
newsock->base.state = ANODE_SOCKET_OPEN;
Anode_memcpy(&newsock->base.endpoint,&tmp_ep,sizeof(AnodeNetworkEndpoint));
newsock->base.class_name = AnodeSystemTransport_CLASS;
newsock->base.user_ptr[0] = NULL;
newsock->base.user_ptr[1] = NULL;
newsock->base.event_handler = NULL;
newsock->entry_idx = entry_idx;
THIS->fds[entry_idx].fd = n;
THIS->fds[entry_idx].events = POLLIN;
THIS->fds[entry_idx].revents = 0;
evbuf.type = ANODE_TRANSPORT_EVENT_STREAM_INCOMING_CONNECT;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)newsock;
evbuf.datagram_from = NULL;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = 0;
evbuf.data_length = 0;
evbuf.data = NULL;
if (sock->base.event_handler)
sock->base.event_handler(&evbuf);
else if (transport->default_event_handler)
transport->default_event_handler(&evbuf);
}
}
static void AnodeSystemTransport__poll_do_read_stream(struct AnodeSystemTransport *transport,int fd,struct AnodeSystemTransport_AnodeSocket *sock)
{
char buf[65536];
AnodeEvent evbuf;
int n;
n = recv(fd,buf,sizeof(buf),0);
if (n > 0) {
evbuf.type = ANODE_TRANSPORT_EVENT_STREAM_DATA_RECEIVED;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)sock;
evbuf.datagram_from = NULL;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = 0;
evbuf.data_length = n;
evbuf.data = buf;
if (sock->base.event_handler)
sock->base.event_handler(&evbuf);
else if (transport->default_event_handler)
transport->default_event_handler(&evbuf);
} else AnodeSystemTransport__do_close(transport,sock,ANODE_ERR_CONNECTION_CLOSED_BY_REMOTE,1);
}
static void AnodeSystemTransport__poll_do_stream_available_for_write(struct AnodeSystemTransport *transport,int fd,struct AnodeSystemTransport_AnodeSocket *sock)
{
AnodeEvent evbuf;
evbuf.type = ANODE_TRANSPORT_EVENT_STREAM_DATA_RECEIVED;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)sock;
evbuf.datagram_from = NULL;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = 0;
evbuf.data_length = 0;
evbuf.data = NULL;
if (sock->base.event_handler)
sock->base.event_handler(&evbuf);
else if (transport->default_event_handler)
transport->default_event_handler(&evbuf);
}
static void AnodeSystemTransport__poll_do_outgoing_connect(struct AnodeSystemTransport *transport,int fd,struct AnodeSystemTransport_AnodeSocket *sock)
{
AnodeEvent evbuf;
int err_code;
socklen_t optlen;
optlen = sizeof(err_code);
if (getsockopt(fd,SOL_SOCKET,SO_ERROR,(void *)&err_code,&optlen)) {
/* Error getting result, so we assume a failure */
evbuf.type = ANODE_TRANSPORT_EVENT_STREAM_OUTGOING_CONNECT_FAILED;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)sock;
evbuf.datagram_from = NULL;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = ANODE_ERR_CONNECT_FAILED;
evbuf.data_length = 0;
evbuf.data = NULL;
AnodeSystemTransport__do_close(transport,sock,0,0);
} else if (err_code) {
/* Error code is nonzero, so connect failed */
evbuf.type = ANODE_TRANSPORT_EVENT_STREAM_OUTGOING_CONNECT_FAILED;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)sock;
evbuf.datagram_from = NULL;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = ANODE_ERR_CONNECT_FAILED;
evbuf.data_length = 0;
evbuf.data = NULL;
AnodeSystemTransport__do_close(transport,sock,0,0);
} else {
/* Connect succeeded */
evbuf.type = ANODE_TRANSPORT_EVENT_STREAM_OUTGOING_CONNECT_ESTABLISHED;
evbuf.transport = (AnodeTransport *)transport;
evbuf.sock = (AnodeSocket *)sock;
evbuf.datagram_from = NULL;
evbuf.dns_name = NULL;
evbuf.dns_addresses = NULL;
evbuf.dns_address_count = 0;
evbuf.error_code = 0;
evbuf.data_length = 0;
evbuf.data = NULL;
}
if (sock->base.event_handler)
sock->base.event_handler(&evbuf);
else if (transport->default_event_handler)
transport->default_event_handler(&evbuf);
}
static int AnodeSystemTransport_poll(AnodeTransport *transport)
{
int timeout = -1;
unsigned int fd_idx;
int event_count = 0;
int n;
if (poll((struct pollfd *)THIS->fds,THIS->fd_count,timeout) > 0) {
for(fd_idx=0;fd_idx<THIS->fd_count;++fd_idx) {
if ((THIS->fds[fd_idx].revents & (POLLERR|POLLHUP|POLLNVAL))) {
if (THIS->sockets[fd_idx].base.type == ANODE_SOCKET_STREAM_CONNECTION) {
if (THIS->sockets[fd_idx].base.state == ANODE_SOCKET_CONNECTING)
AnodeSystemTransport__poll_do_outgoing_connect(THIS,THIS->fds[fd_idx].fd,&THIS->sockets[fd_idx]);
else AnodeSystemTransport__do_close(THIS,&THIS->sockets[fd_idx],ANODE_ERR_CONNECTION_CLOSED_BY_REMOTE,1);
++event_count;
}
} else {
if ((THIS->fds[fd_idx].revents & POLLIN)) {
if (THIS->fds[fd_idx].fd == THIS->invoke_pipe[0]) {
n = read(THIS->invoke_pipe[0],&(((unsigned char *)(&(THIS->invoke_pipe_buf)))[THIS->invoke_pipe_buf_ptr]),sizeof(THIS->invoke_pipe_buf) - THIS->invoke_pipe_buf_ptr);
if (n > 0) {
THIS->invoke_pipe_buf_ptr += (unsigned int)n;
if (THIS->invoke_pipe_buf_ptr >= sizeof(THIS->invoke_pipe_buf)) {
THIS->invoke_pipe_buf_ptr -= sizeof(THIS->invoke_pipe_buf);
((void (*)(void *))(THIS->invoke_pipe_buf[1]))(THIS->invoke_pipe_buf[0]);
}
}
} else {
switch(THIS->sockets[fd_idx].base.type) {
case ANODE_SOCKET_DATAGRAM:
AnodeSystemTransport__poll_do_read_datagram(THIS,THIS->fds[fd_idx].fd,&THIS->sockets[fd_idx]);
break;
case ANODE_SOCKET_STREAM_LISTEN:
AnodeSystemTransport__poll_do_accept_incoming_connection(THIS,THIS->fds[fd_idx].fd,&THIS->sockets[fd_idx]);
break;
case ANODE_SOCKET_STREAM_CONNECTION:
if (THIS->sockets[fd_idx].base.state == ANODE_SOCKET_CONNECTING)
AnodeSystemTransport__poll_do_outgoing_connect(THIS,THIS->fds[fd_idx].fd,&THIS->sockets[fd_idx]);
else AnodeSystemTransport__poll_do_read_stream(THIS,THIS->fds[fd_idx].fd,&THIS->sockets[fd_idx]);
break;
}
++event_count;
}
}
if ((THIS->fds[fd_idx].revents & POLLOUT)) {
if (THIS->sockets[fd_idx].base.state == ANODE_SOCKET_CONNECTING)
AnodeSystemTransport__poll_do_outgoing_connect(THIS,THIS->fds[fd_idx].fd,&THIS->sockets[fd_idx]);
else AnodeSystemTransport__poll_do_stream_available_for_write(THIS,THIS->fds[fd_idx].fd,&THIS->sockets[fd_idx]);
++event_count;
}
}
}
}
return event_count;
}
static int AnodeSystemTransport_supports_address_type(const AnodeTransport *transport,
enum AnodeNetworkAddressType at)
{
switch(at) {
case ANODE_NETWORK_ADDRESS_IPV4:
return 1;
case ANODE_NETWORK_ADDRESS_IPV6:
return 1;
default:
if (THIS->base)
return THIS->base->supports_address_type(THIS->base,at);
return 0;
}
}
static AnodeTransport *AnodeSystemTransport_base_instance(const AnodeTransport *transport)
{
return THIS->base;
}
static const char *AnodeSystemTransport_class_name(AnodeTransport *transport)
{
return AnodeSystemTransport_CLASS;
}
static void AnodeSystemTransport_delete(AnodeTransport *transport)
{
close(THIS->invoke_pipe[0]);
close(THIS->invoke_pipe[1]);
AnodeMutex_destroy(&THIS->invoke_pipe_m);
if (THIS->fds) free(THIS->fds);
if (THIS->sockets) free(THIS->sockets);
if (THIS->base) THIS->base->delete(THIS->base);
free(transport);
}
/* ======================================================================== */
AnodeTransport *AnodeSystemTransport_new(AnodeTransport *base)
{
struct AnodeSystemTransport *t;
unsigned int entry_idx;
t = malloc(sizeof(struct AnodeSystemTransport));
if (!t) return (AnodeTransport *)0;
Anode_zero(t,sizeof(struct AnodeSystemTransport));
t->interface.invoke = &AnodeSystemTransport_invoke;
t->interface.dns_resolve = &AnodeSystemTransport_dns_resolve;
t->interface.datagram_listen = &AnodeSystemTransport_datagram_listen;
t->interface.stream_listen = &AnodeSystemTransport_stream_listen;
t->interface.datagram_send = &AnodeSystemTransport_datagram_send;
t->interface.stream_connect = &AnodeSystemTransport_stream_connect;
t->interface.stream_start_writing = &AnodeSystemTransport_stream_start_writing;
t->interface.stream_stop_writing = &AnodeSystemTransport_stream_stop_writing;
t->interface.stream_send = &AnodeSystemTransport_stream_send;
t->interface.close = &AnodeSystemTransport_close;
t->interface.poll = &AnodeSystemTransport_poll;
t->interface.supports_address_type = &AnodeSystemTransport_supports_address_type;
t->interface.base_instance = &AnodeSystemTransport_base_instance;
t->interface.class_name = &AnodeSystemTransport_class_name;
t->interface.delete = &AnodeSystemTransport_delete;
t->base = base;
pipe(t->invoke_pipe);
fcntl(t->invoke_pipe[0],F_SETFL,O_NONBLOCK);
entry_idx = AnodeSystemTransport__add_entry(t);
t->fds[entry_idx].fd = t->invoke_pipe[0];
t->fds[entry_idx].events = POLLIN;
t->fds[entry_idx].revents = 0;
AnodeMutex_init(&t->invoke_pipe_m);
return (AnodeTransport *)t;
}

View File

@ -0,0 +1,25 @@
all: force clean anode-utils-test anode-zone-test aes-test ec-test
aes-test:
gcc -Wall -O6 -ftree-vectorize -std=c99 -o aes-test aes-test.c ../aes_digest.c -lcrypto
http_client-test:
gcc -O0 -g -std=c99 -o http_client-test http_client-test.c ../anode-utils.c ../misc.c ../http_client.c ../dictionary.c ../iptransport.c ../anode-transport.c -lcrypto
anode-utils-test:
gcc -O0 -g -std=c99 -o anode-utils-test anode-utils-test.c ../anode-utils.c ../misc.c
ec-test:
gcc -O0 -g -std=c99 -o ec-test ec-test.c ../impl/ec.c ../impl/misc.c -lcrypto
anode-zone-test:
gcc -O0 -g -std=c99 -o anode-zone-test anode-zone-test.c ../anode-zone.c ../http_client.c ../dictionary.c ../misc.c ../anode-transport.c ../iptransport.c ../environment.c
system_transport-test:
gcc -O0 -g -std=c99 -o system_transport-test system_transport-test.c ../system_transport.c ../network_address.c ../address.c ../aes_digest.c ../impl/misc.c ../impl/thread.c ../impl/dns_txt.c ../impl/aes.c -lresolv -lcrypto
clean: force
rm -rf *.dSYM
rm -f http_client-test anode-utils-test anode-zone-test ec-test aes-test system_transport-test
force: ;

View File

@ -0,0 +1,191 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../impl/aes.h"
#include "../anode.h"
static const unsigned char AES_TEST_KEY[32] = {
0x08,0x09,0x0A,0x0B,0x0D,0x0E,0x0F,0x10,0x12,0x13,0x14,0x15,0x17,0x18,0x19,0x1A,
0x1C,0x1D,0x1E,0x1F,0x21,0x22,0x23,0x24,0x26,0x27,0x28,0x29,0x2B,0x2C,0x2D,0x2E
};
static const unsigned char AES_TEST_IN[16] = {
0x06,0x9A,0x00,0x7F,0xC7,0x6A,0x45,0x9F,0x98,0xBA,0xF9,0x17,0xFE,0xDF,0x95,0x21
};
static const unsigned char AES_TEST_OUT[16] = {
0x08,0x0e,0x95,0x17,0xeb,0x16,0x77,0x71,0x9a,0xcf,0x72,0x80,0x86,0x04,0x0a,0xe3
};
static const unsigned char CMAC_TEST_KEY[32] = {
0x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,0x81,
0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,0xdf,0xf4
};
static const unsigned char CMAC_TEST1_OUT[16] = {
0x02,0x89,0x62,0xf6,0x1b,0x7b,0xf8,0x9e,0xfc,0x6b,0x55,0x1f,0x46,0x67,0xd9,0x83
};
static const unsigned char CMAC_TEST2_IN[16] = {
0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a
};
static const unsigned char CMAC_TEST2_OUT[16] = {
0x28,0xa7,0x02,0x3f,0x45,0x2e,0x8f,0x82,0xbd,0x4b,0xf2,0x8d,0x8c,0x37,0xc3,0x5c
};
static const unsigned char CMAC_TEST3_IN[40] = {
0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,
0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51,
0x30,0xc8,0x1c,0x46,0xa3,0x5c,0xe4,0x11
};
static const unsigned char CMAC_TEST3_OUT[16] = {
0xaa,0xf3,0xd8,0xf1,0xde,0x56,0x40,0xc2,0x32,0xf5,0xb1,0x69,0xb9,0xc9,0x11,0xe6
};
static const unsigned char CMAC_TEST4_IN[64] = {
0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,
0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,0x9e,0xb7,0x6f,0xac,0x45,0xaf,0x8e,0x51,
0x30,0xc8,0x1c,0x46,0xa3,0x5c,0xe4,0x11,0xe5,0xfb,0xc1,0x19,0x1a,0x0a,0x52,0xef,
0xf6,0x9f,0x24,0x45,0xdf,0x4f,0x9b,0x17,0xad,0x2b,0x41,0x7b,0xe6,0x6c,0x37,0x10
};
static const unsigned char CMAC_TEST4_OUT[16] = {
0xe1,0x99,0x21,0x90,0x54,0x9f,0x6e,0xd5,0x69,0x6a,0x2c,0x05,0x6c,0x31,0x54,0x10
};
static void test_cmac(const AnodeAesExpandedKey *expkey,const unsigned char *in,unsigned int inlen,const unsigned char *expected)
{
unsigned int i;
unsigned char out[16];
printf("Testing CMAC with %u byte input:\n",inlen);
printf(" IN: ");
for(i=0;i<inlen;++i)
printf("%.2x",(int)in[i]);
printf("\n");
printf(" EXP: ");
for(i=0;i<16;++i)
printf("%.2x",(int)expected[i]);
printf("\n");
Anode_cmac_aes256(expkey,in,inlen,out);
printf(" OUT: ");
for(i=0;i<16;++i)
printf("%.2x",(int)out[i]);
printf("\n");
if (memcmp(expected,out,16)) {
printf("FAILED!\n");
exit(1);
} else printf("Passed.\n");
}
static void test_cfb(const AnodeAesExpandedKey *expkey,const unsigned char *in,unsigned int inlen,unsigned char *iv,const unsigned char *expected)
{
unsigned char tmp[131072];
unsigned char tmp2[131072];
unsigned char tmpiv[16];
printf("Testing AES-256 CFB mode with %u bytes: ",inlen);
fflush(stdout);
memcpy(tmpiv,iv,16);
Anode_aes256_cfb_encrypt(expkey,in,tmp,tmpiv,inlen);
if (!memcmp(tmp,expected,inlen)) {
printf("FAILED (didn't encrypt)!\n");
exit(1);
}
memcpy(tmpiv,iv,16);
Anode_aes256_cfb_decrypt(expkey,tmp,tmp2,tmpiv,inlen);
if (memcmp(tmp2,expected,inlen)) {
printf("FAILED (didn't encrypt)!\n");
exit(1);
} else printf("Passed.\n");
}
static const char *AES_DIGEST_TEST_1 = "test";
static const char *AES_DIGEST_TEST_2 = "supercalifragilisticexpealidocious";
static const char *AES_DIGEST_TEST_3 = "12345678";
static const char *AES_DIGEST_TEST_4 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
int main(int argc,char **argv)
{
AnodeAesExpandedKey expkey;
unsigned int i;
unsigned char aestestbuf[16];
unsigned char cfbin[131072];
unsigned char iv[16];
printf("Testing AES-256:");
Anode_aes256_expand_key(AES_TEST_KEY,&expkey);
printf(" IN: ");
for(i=0;i<16;++i)
printf("%.2x",(int)AES_TEST_IN[i]);
printf("\n");
printf(" EXP: ");
for(i=0;i<16;++i)
printf("%.2x",(int)AES_TEST_OUT[i]);
printf("\n");
Anode_aes256_encrypt(&expkey,AES_TEST_IN,aestestbuf);
printf(" OUT: ");
for(i=0;i<16;++i)
printf("%.2x",(int)aestestbuf[i]);
printf("\n");
if (memcmp(AES_TEST_OUT,aestestbuf,16)) {
printf("FAILED!\n");
return 1;
} else printf("Passed.\n");
printf("\n");
Anode_aes256_expand_key(CMAC_TEST_KEY,&expkey);
test_cmac(&expkey,(unsigned char *)0,0,CMAC_TEST1_OUT);
test_cmac(&expkey,CMAC_TEST2_IN,16,CMAC_TEST2_OUT);
test_cmac(&expkey,CMAC_TEST3_IN,40,CMAC_TEST3_OUT);
test_cmac(&expkey,CMAC_TEST4_IN,64,CMAC_TEST4_OUT);
printf("\n");
for(i=0;i<131072;++i)
cfbin[i] = (unsigned char)(i & 0xff);
for(i=0;i<16;++i)
iv[i] = (unsigned char)(i & 0xff);
for(i=12345;i<131072;i+=7777)
test_cfb(&expkey,cfbin,i,iv,cfbin);
printf("\nTesting AES-DIGEST...\n");
printf("0 bytes: ");
Anode_aes_digest(cfbin,0,iv);
for(i=0;i<16;++i) printf("%.2x",(unsigned int)iv[i]);
printf("\n");
printf("%d bytes: ",(int)strlen(AES_DIGEST_TEST_1));
Anode_aes_digest(AES_DIGEST_TEST_1,strlen(AES_DIGEST_TEST_1),iv);
for(i=0;i<16;++i) printf("%.2x",(unsigned int)iv[i]);
printf("\n");
printf("%d bytes: ",(int)strlen(AES_DIGEST_TEST_2));
Anode_aes_digest(AES_DIGEST_TEST_2,strlen(AES_DIGEST_TEST_2),iv);
for(i=0;i<16;++i) printf("%.2x",(unsigned int)iv[i]);
printf("\n");
printf("%d bytes: ",(int)strlen(AES_DIGEST_TEST_3));
Anode_aes_digest(AES_DIGEST_TEST_3,strlen(AES_DIGEST_TEST_3),iv);
for(i=0;i<16;++i) printf("%.2x",(unsigned int)iv[i]);
printf("\n");
printf("%d bytes: ",(int)strlen(AES_DIGEST_TEST_4));
Anode_aes_digest(AES_DIGEST_TEST_4,strlen(AES_DIGEST_TEST_4),iv);
for(i=0;i<16;++i) printf("%.2x",(unsigned int)iv[i]);
printf("\n");
return 0;
}

View File

@ -0,0 +1,38 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <stdio.h>
#include "../anode.h"
#include "../misc.h"
int main(int argc,char **argv)
{
unsigned char test[10005];
unsigned int i;
AnodeSecureRandom srng;
AnodeSecureRandom_init(&srng);
AnodeSecureRandom_gen_bytes(&srng,test,sizeof(test));
for(i=0;i<sizeof(test);++i) {
printf("%.2x",(unsigned int)test[i]);
if ((i % 20) == 19)
printf("\n");
}
printf("\n");
}

View File

@ -0,0 +1,75 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <stdio.h>
#include "../anode.h"
#include "../misc.h"
static const char *testuris[22] = {
"http://www.test.com",
"http://www.test.com/",
"http://www.test.com/path/to/something",
"http://user@www.test.com",
"http://user@www.test.com/path/to/something",
"http://user:password@www.test.com/path/to/something",
"http://www.test.com/path/to/something?query=foo&bar=baz",
"http://www.test.com/path/to/something#fragment",
"http://www.test.com/path/to/something?query=foo&bar=baz#fragment",
"http://user:password@www.test.com/path/to/something#fragment",
"http://user:password@www.test.com/path/to/something?query=foo&bar=baz#fragment",
"http://@www.test.com/",
"http://:@www.test.com/",
"http://www.test.com:8080/path/to/something",
"http://user:password@www.test.com:8080/path/to/something?query=foo#fragment",
"http://",
"http://www.test.com/path/to/something?#",
"http://www.test.com/path/to/something?#fragment",
"http:",
"http",
"mailto:this_is_a_urn@somedomain.com",
""
};
int main(int argc,char **argv)
{
int i,r;
char reconstbuf[2048];
char *reconst;
AnodeURI uri;
for(i=0;i<22;++i) {
printf("\"%s\":\n",testuris[i]);
r = AnodeURI_parse(&uri,testuris[i]);
if (r) {
printf(" error: %d\n",r);
} else {
printf(" scheme: %s\n",uri.scheme);
printf(" username: %s\n",uri.username);
printf(" password: %s\n",uri.password);
printf(" host: %s\n",uri.host);
printf(" port: %d\n",uri.port);
printf(" path: %s\n",uri.path);
printf(" query: %s\n",uri.query);
printf(" fragment: %s\n",uri.fragment);
}
reconst = AnodeURI_to_string(&uri,reconstbuf,sizeof(reconstbuf));
printf("Reconstituted URI: %s\n",reconst ? reconst : "(null)");
printf("\n");
}
return 0;
}

View File

@ -0,0 +1,47 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../anode.h"
#include "../dictionary.h"
static int got_it = 0;
static void zone_lookup_handler(void *ptr,long zone_id,AnodeZone *zone)
{
if (zone)
printf("got %.8lx: %d entries\n",(unsigned long)zone_id & 0xffffffff,((struct AnodeDictionary *)zone)->size);
else printf("failed.\n");
got_it = 1;
}
int main(int argc,char **argv)
{
AnodeTransportEngine transport;
Anode_init_ip_transport_engine(&transport);
AnodeZone_lookup(&transport,0,0,&zone_lookup_handler);
while (!got_it)
transport.poll(&transport);
transport.destroy(&transport);
return 0;
}

View File

@ -0,0 +1,149 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include "../dictionary.h"
static const char *HASH_TESTS[16] = {
"test",
"testt",
"",
"foo",
"fooo",
"1",
"2",
"3",
"4",
"11",
"22",
"33",
"44",
"adklfjklejrer",
"erngnetbekjrq",
"erklerqqqqre"
};
int diterate(void *arg,const char *key,const char *value)
{
printf(" %s: %s\n",key ? key : "(null)",value ? value : "(null)");
return 1;
}
int main(int argc,char **argv)
{
char tmp[1024];
char fuzzparam1[16],fuzzparam2[16],fuzzparam3[16];
struct AnodeDictionary d;
unsigned int i,j,k,cs;
srandom(time(0));
printf("Trying out hash function a little...\n");
for(i=0;i<16;++i)
printf(" %s: %u\n",HASH_TESTS[i],(unsigned int)AnodeDictionary__get_bucket(HASH_TESTS[i]));
for(cs=0;cs<2;++cs) {
printf("\nTesting with case sensitivity = %d\n",cs);
AnodeDictionary_init(&d,cs);
printf("\nTesting dictionary by adding and retrieving some keys...\n");
AnodeDictionary_put(&d,"test1","This is the first test");
AnodeDictionary_put(&d,"test2","This is the second test");
AnodeDictionary_put(&d,"test3","This is the third test (lower case)");
AnodeDictionary_put(&d,"TEST3","This is the third test (UPPER CASE)");
AnodeDictionary_iterate(&d,(void *)0,&diterate);
if (d.size != (cs ? 4 : 3)) {
printf("Failed (size).\n");
return 1;
}
AnodeDictionary_clear(&d);
if (d.size||(AnodeDictionary_get(&d,"test1"))) {
printf("Failed (clear).\n");
return 1;
}
printf("\nTesting read, trial 1: simple key=value with unterminated line\n");
strcpy(tmp,"foo=bar\nbar=baz\ntest1=Happy happy joyjoy!\ntest2=foobarbaz\nlinewithnocr=thisworked");
AnodeDictionary_read(&d,tmp,"\r\n","=","",'\\',0,0);
printf("Results:\n");
AnodeDictionary_iterate(&d,(void *)0,&diterate);
AnodeDictionary_clear(&d);
printf("\nTesting read, trial 2: key=value with escape chars, escaped CRs\n");
strcpy(tmp,"foo=bar\r\nbar==baz\nte\\=st1=\\=Happy happy joyjoy!\ntest2=foobarbaz\\\nfoobarbaz on next line\r\n");
AnodeDictionary_read(&d,tmp,"\r\n","=","",'\\',0,0);
printf("Results:\n");
AnodeDictionary_iterate(&d,(void *)0,&diterate);
AnodeDictionary_clear(&d);
printf("\nTesting read, trial 3: HTTP header-like dictionary\n");
strcpy(tmp,"Host: some.host.net\r\nX-Some-Header: foo bar\r\nX-Some-Other-Header: y0y0y0y0y0\r\n");
AnodeDictionary_read(&d,tmp,"\r\n",": ","",0,0,0);
printf("Results:\n");
AnodeDictionary_iterate(&d,(void *)0,&diterate);
AnodeDictionary_clear(&d);
printf("\nTesting read, trial 4: single line key/value\n");
strcpy(tmp,"Header: one line only");
AnodeDictionary_read(&d,tmp,"\r\n",": ","",0,0,0);
printf("Results:\n");
AnodeDictionary_iterate(&d,(void *)0,&diterate);
AnodeDictionary_clear(&d);
printf("\nFuzzing dictionary reader...\n"); fflush(stdout);
for(i=0;i<200000;++i) {
j = random() % (sizeof(tmp) - 1);
for(k=0;k<j;++k) {
tmp[k] = (char)((unsigned int)random() >> 3);
if (!tmp[k]) tmp[k] = 1;
}
tmp[j] = (char)0;
j = random() % (sizeof(fuzzparam1) - 1);
for(k=0;k<j;++k) {
fuzzparam1[k] = (char)((unsigned int)random() >> 3);
if (!fuzzparam1[k]) fuzzparam1[k] = 1;
}
fuzzparam1[j] = (char)0;
j = random() % (sizeof(fuzzparam2) - 1);
for(k=0;k<j;++k) {
fuzzparam1[k] = (char)((unsigned int)random() >> 3);
if (!fuzzparam2[k]) fuzzparam2[k] = 1;
}
fuzzparam2[j] = (char)0;
j = random() % (sizeof(fuzzparam3) - 1);
for(k=0;k<j;++k) {
fuzzparam3[k] = (char)((unsigned int)random() >> 3);
if (!fuzzparam3[k]) fuzzparam3[k] = 1;
}
fuzzparam3[j] = (char)0;
AnodeDictionary_read(&d,tmp,fuzzparam1,fuzzparam2,fuzzparam3,random() & 3,random() & 1,random() & 1);
AnodeDictionary_clear(&d);
}
AnodeDictionary_destroy(&d);
}
return 0;
}

View File

@ -0,0 +1,97 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../impl/ec.h"
#include "../impl/misc.h"
#define TEST_KEY_LEN 128
#define AnodeEC_key_to_hex(k,b,l) Anode_to_hex((k)->key,(k)->bytes,(b),l)
int main(int argc,char **argv)
{
struct AnodeECKeyPair pair1;
struct AnodeECKeyPair pair2;
struct AnodeECKeyPair pair3;
unsigned char key[TEST_KEY_LEN];
char str[16384];
printf("Creating key pair #1...\n");
if (!AnodeECKeyPair_generate(&pair1)) {
printf("Could not create key pair.\n");
return 1;
}
AnodeEC_key_to_hex(&pair1.pub,str,sizeof(str));
printf("Public: %s\n",str);
AnodeEC_key_to_hex(&pair1.priv,str,sizeof(str));
printf("Private: %s\n\n",str);
printf("Creating key pair #2...\n");
if (!AnodeECKeyPair_generate(&pair2)) {
printf("Could not create key pair.\n");
return 1;
}
AnodeEC_key_to_hex(&pair2.pub,str,sizeof(str));
printf("Public: %s\n",str);
AnodeEC_key_to_hex(&pair2.priv,str,sizeof(str));
printf("Private: %s\n\n",str);
printf("Key agreement between public #2 and private #1...\n");
if (!AnodeECKeyPair_agree(&pair1,&pair2.pub,key,TEST_KEY_LEN)) {
printf("Agreement failed.\n");
return 1;
}
Anode_to_hex(key,TEST_KEY_LEN,str,sizeof(str));
printf("Agreed secret: %s\n\n",str);
printf("Key agreement between public #1 and private #2...\n");
if (!AnodeECKeyPair_agree(&pair2,&pair1.pub,key,TEST_KEY_LEN)) {
printf("Agreement failed.\n");
return 1;
}
Anode_to_hex(key,TEST_KEY_LEN,str,sizeof(str));
printf("Agreed secret: %s\n\n",str);
printf("Testing key pair init function (init #3 from #2's parts)...\n");
if (!AnodeECKeyPair_init(&pair3,&(pair2.pub),&(pair2.priv))) {
printf("Init failed.\n");
return 1;
}
printf("Key agreement between public #1 and private #3...\n");
if (!AnodeECKeyPair_agree(&pair3,&pair1.pub,key,TEST_KEY_LEN)) {
printf("Agreement failed.\n");
return 1;
}
Anode_to_hex(key,TEST_KEY_LEN,str,sizeof(str));
printf("Agreed secret: %s\n\n",str);
printf("Key agreement between public #1 and private #1...\n");
if (!AnodeECKeyPair_agree(&pair1,&pair1.pub,key,TEST_KEY_LEN)) {
printf("Agreement failed.\n");
return 1;
}
Anode_to_hex(key,TEST_KEY_LEN,str,sizeof(str));
printf("Agreed secret (should not match): %s\n\n",str);
AnodeECKeyPair_destroy(&pair1);
AnodeECKeyPair_destroy(&pair2);
AnodeECKeyPair_destroy(&pair3);
return 0;
}

View File

@ -0,0 +1,28 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include "../environment.h"
int main(int argc,char **argv)
{
const char *cache = Anode_get_cache();
printf("Cache folder: %s\n",cache ? cache : "(null)");
return 0;
}

View File

@ -0,0 +1,233 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
#include "../anode.h"
#include "../misc.h"
#include "../http_client.h"
#include "../dictionary.h"
struct TestCase
{
int method;
AnodeURI uri;
const void *client_data;
unsigned int client_data_len;
const char *expected_sha1;
char actual_sha1[64];
int got_it;
int keepalive;
struct TestCase *next;
};
#define NUM_TEST_CASES 7
static struct TestCase test_cases[NUM_TEST_CASES];
static void init_test_cases(int keepalive)
{
AnodeURI_parse(&(test_cases[0].uri),"http://zerotier.com/for_unit_tests/test1.txt");
test_cases[0].method = ANODE_HTTP_GET;
test_cases[0].client_data_len = 0;
test_cases[0].expected_sha1 = "0828324174b10cc867b7255a84a8155cf89e1b8b";
test_cases[0].actual_sha1[0] = (char)0;
test_cases[0].got_it = 0;
test_cases[0].keepalive = keepalive;
test_cases[0].next = &(test_cases[1]);
AnodeURI_parse(&(test_cases[1].uri),"http://zerotier.com/for_unit_tests/test2.bin");
test_cases[1].method = ANODE_HTTP_GET;
test_cases[1].client_data_len = 0;
test_cases[1].expected_sha1 = "6b67c635786ab52666211d02412c0d0f0372980d";
test_cases[1].actual_sha1[0] = (char)0;
test_cases[1].got_it = 0;
test_cases[1].keepalive = keepalive;
test_cases[1].next = &(test_cases[2]);
AnodeURI_parse(&(test_cases[2].uri),"http://zerotier.com/for_unit_tests/test3.bin");
test_cases[2].method = ANODE_HTTP_GET;
test_cases[2].client_data_len = 0;
test_cases[2].expected_sha1 = "efa7722029fdbb6abd0e3ed32a0b44bfb982cff0";
test_cases[2].actual_sha1[0] = (char)0;
test_cases[2].got_it = 0;
test_cases[2].keepalive = keepalive;
test_cases[2].next = &(test_cases[3]);
AnodeURI_parse(&(test_cases[3].uri),"http://zerotier.com/for_unit_tests/test4.bin");
test_cases[3].method = ANODE_HTTP_GET;
test_cases[3].client_data_len = 0;
test_cases[3].expected_sha1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
test_cases[3].actual_sha1[0] = (char)0;
test_cases[3].got_it = 0;
test_cases[3].keepalive = keepalive;
test_cases[3].next = &(test_cases[4]);
AnodeURI_parse(&(test_cases[4].uri),"http://zerotier.com/for_unit_tests/echo.php?echo=foobar");
test_cases[4].method = ANODE_HTTP_GET;
test_cases[4].client_data_len = 0;
test_cases[4].expected_sha1 = "8843d7f92416211de9ebb963ff4ce28125932878";
test_cases[4].actual_sha1[0] = (char)0;
test_cases[4].got_it = 0;
test_cases[4].keepalive = keepalive;
test_cases[4].next = &(test_cases[5]);
AnodeURI_parse(&(test_cases[5].uri),"http://zerotier.com/for_unit_tests/echo.php");
test_cases[5].method = ANODE_HTTP_POST;
test_cases[5].client_data = "echo=foobar";
test_cases[5].client_data_len = strlen((char *)test_cases[5].client_data);
test_cases[5].expected_sha1 = "8843d7f92416211de9ebb963ff4ce28125932878";
test_cases[5].actual_sha1[0] = (char)0;
test_cases[5].got_it = 0;
test_cases[5].keepalive = keepalive;
test_cases[5].next = &(test_cases[6]);
AnodeURI_parse(&(test_cases[6].uri),"http://zerotier.com/for_unit_tests/test3.bin");
test_cases[6].method = ANODE_HTTP_HEAD;
test_cases[6].client_data_len = 0;
test_cases[6].expected_sha1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
test_cases[6].actual_sha1[0] = (char)0;
test_cases[6].got_it = 0;
test_cases[6].keepalive = keepalive;
test_cases[6].next = 0;
}
static int http_handler_dump_headers(void *arg,const char *key,const char *value)
{
printf(" H %s: %s\n",key,value);
return 1;
}
static void http_handler(struct AnodeHttpClient *client)
{
const char *method = "???";
char buf[1024];
unsigned char sha[20];
struct TestCase *test = (struct TestCase *)client->ptr[0];
switch(client->method) {
case ANODE_HTTP_GET:
method = "GET";
break;
case ANODE_HTTP_HEAD:
method = "HEAD";
break;
case ANODE_HTTP_POST:
method = "POST";
break;
}
if (client->response.code == 200) {
SHA1((unsigned char *)client->response.data,client->response.data_length,sha);
Anode_to_hex(sha,20,test->actual_sha1,sizeof(test->actual_sha1));
printf("%s %s\n * SHA1: %s exp: %s\n",method,AnodeURI_to_string(&(test->uri),buf,sizeof(buf)),test->actual_sha1,test->expected_sha1);
if (strcmp(test->actual_sha1,test->expected_sha1))
printf(" ! SHA1 MISMATCH!\n");
AnodeDictionary_iterate(&(client->response.headers),0,&http_handler_dump_headers);
} else printf("%s %s: ERROR: %d\n",method,AnodeURI_to_string(&(test->uri),buf,sizeof(buf)),client->response.code);
test->got_it = 1;
if (!test->keepalive)
AnodeHttpClient_free(client);
else {
test = test->next;
if (test) {
memcpy((void *)&(client->uri),(const void *)&(test->uri),sizeof(AnodeURI));
client->data = test->client_data;
client->data_length = test->client_data_len;
client->ptr[0] = test;
client->keepalive = test->keepalive;
client->method = test->method;
client->handler = &http_handler;
AnodeHttpClient_send(client);
} else {
AnodeHttpClient_free(client);
}
}
}
int main(int argc,char **argv)
{
struct AnodeHttpClient *client;
AnodeTransportEngine transport_engine;
int i;
if (Anode_init_ip_transport_engine(&transport_engine)) {
printf("Failed (transport engine init)\n");
return 1;
}
printf("Testing without keepalive...\n\n");
init_test_cases(0);
for(i=0;i<NUM_TEST_CASES;++i) {
client = AnodeHttpClient_new(&transport_engine);
memcpy((void *)&(client->uri),(const void *)&(test_cases[i].uri),sizeof(AnodeURI));
client->data = test_cases[i].client_data;
client->data_length = test_cases[i].client_data_len;
client->ptr[0] = &test_cases[i];
client->keepalive = test_cases[i].keepalive;
client->method = test_cases[i].method;
client->handler = &http_handler;
AnodeHttpClient_send(client);
}
for(;;) {
for(i=0;i<NUM_TEST_CASES;++i) {
if (!test_cases[i].got_it)
break;
}
if (i == NUM_TEST_CASES)
break;
transport_engine.poll(&transport_engine);
}
printf("\n\n");
printf("Testing with keepalive...\n\n");
init_test_cases(1);
client = AnodeHttpClient_new(&transport_engine);
i = 0;
memcpy((void *)&(client->uri),(const void *)&(test_cases[i].uri),sizeof(AnodeURI));
client->data = test_cases[i].client_data;
client->data_length = test_cases[i].client_data_len;
client->ptr[0] = &test_cases[i];
client->keepalive = test_cases[i].keepalive;
client->method = test_cases[i].method;
client->handler = &http_handler;
AnodeHttpClient_send(client);
for(;;) {
for(i=0;i<NUM_TEST_CASES;++i) {
if (!test_cases[i].got_it)
break;
}
if (i == NUM_TEST_CASES)
break;
transport_engine.poll(&transport_engine);
}
transport_engine.destroy(&transport_engine);
return 0;
}

View File

@ -0,0 +1,137 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include "../misc.h"
int main(int argc,char **argv)
{
const char *base32TestStr = "asdf";
char *fields[16];
char buf[1024];
char buf2[1024];
char buf3[4096];
unsigned int i;
unsigned long tmpl,tmpl2;
unsigned long long tmp64;
srand(time(0));
Anode_base32_5_to_8((const unsigned char *)base32TestStr,buf);
printf("Base32 from test string: %s\n",buf);
Anode_base32_8_to_5("MFZWIZQA",(unsigned char *)buf2);
printf("Test string from Base32 (upper case): %s\n",buf2);
Anode_base32_8_to_5("mfzwizqa",(unsigned char *)buf2);
printf("Test string from Base32 (lower case): %s\n",buf2);
printf("Testing variable length encoding/decoded with pad5 functions...\n");
for(i=0;i<1024;++i) {
tmpl = rand() % (sizeof(buf) - 8);
if (!tmpl)
tmpl = 1;
for(tmpl2=0;tmpl2<tmpl;++tmpl2)
buf[tmpl2] = (buf2[tmpl2] = (char)(rand() >> 3));
if (!Anode_base32_encode_pad5(buf2,tmpl,buf3,sizeof(buf3))) {
printf("Failed (encode failed).\n");
return 1;
}
memset(buf2,0,sizeof(buf2));
if (!Anode_base32_decode_pad5(buf3,buf2,sizeof(buf2))) {
printf("Failed (decode failed).\n");
return 1;
}
if (memcmp(buf,buf2,tmpl)) {
printf("Failed (compare failed).\n");
return 1;
}
}
printf("Anode_htonll(0x0102030405060708) == 0x%.16llx\n",tmp64 = Anode_htonll(0x0102030405060708ULL));
printf("Anode_ntohll(0x%.16llx) == 0x%.16llx\n",tmp64,Anode_ntohll(tmp64));
if (Anode_ntohll(tmp64) != 0x0102030405060708ULL) {
printf("Failed.\n");
return 1;
}
strcpy(buf,"foo bar baz");
Anode_trim(buf);
printf("Testing string trim: 'foo bar baz' -> '%s'\n",buf);
strcpy(buf,"foo bar baz ");
Anode_trim(buf);
printf("Testing string trim: 'foo bar baz ' -> '%s'\n",buf);
strcpy(buf," foo bar baz");
Anode_trim(buf);
printf("Testing string trim: ' foo bar baz' -> '%s'\n",buf);
strcpy(buf," foo bar baz ");
Anode_trim(buf);
printf("Testing string trim: ' foo bar baz ' -> '%s'\n",buf);
strcpy(buf,"");
Anode_trim(buf);
printf("Testing string trim: '' -> '%s'\n",buf);
strcpy(buf," ");
Anode_trim(buf);
printf("Testing string trim: ' ' -> '%s'\n",buf);
printf("Testing string split.\n");
strcpy(buf,"66.246.138.121,5323,0");
i = Anode_split(buf,';',fields,16);
if (i != 1) {
printf("Failed.\n");
return 1;
} else printf("Fields: %s\n",fields[0]);
strcpy(buf,"a;b;c");
i = Anode_split(buf,';',fields,16);
if (i != 3) {
printf("Failed.\n");
return 1;
} else printf("Fields: %s %s %s\n",fields[0],fields[1],fields[2]);
strcpy(buf,";;");
i = Anode_split(buf,';',fields,16);
if (i != 3) {
printf("Failed.\n");
return 1;
} else printf("Fields: %s %s %s\n",fields[0],fields[1],fields[2]);
strcpy(buf,"a;b;");
i = Anode_split(buf,';',fields,16);
if (i != 3) {
printf("Failed.\n");
return 1;
} else printf("Fields: %s %s %s\n",fields[0],fields[1],fields[2]);
strcpy(buf,"a;;c");
i = Anode_split(buf,';',fields,16);
if (i != 3) {
printf("Failed.\n");
return 1;
} else printf("Fields: %s %s %s\n",fields[0],fields[1],fields[2]);
strcpy(buf,";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;");
i = Anode_split(buf,';',fields,16);
if (i != 16) {
printf("Failed.\n");
return 1;
}
strcpy(buf,"");
i = Anode_split(buf,';',fields,16);
if (i != 0) {
printf("Failed.\n");
return 1;
}
printf("Passed.\n");
return 0;
}

View File

@ -0,0 +1,70 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include "../anode.h"
#include "../impl/thread.h"
static int do_client()
{
AnodeTransport *st;
AnodeSocket *udp_sock;
int run = 1;
st = AnodeSystemTransport_new(NULL);
if (!st) {
printf("FAILED: unable to construct AnodeSystemTransport.\n");
return -1;
}
printf("Created AnodeSystemTransport.\n");
while (run)
st->poll(st);
}
static int do_server()
{
AnodeTransport *st;
AnodeSocket *udp_sock;
AnodeSocket *tcp_sock;
int run = 1;
st = AnodeSystemTransport_new(NULL);
if (!st) {
printf("FAILED: unable to construct AnodeSystemTransport.\n");
return -1;
}
printf("Created AnodeSystemTransport.\n");
while (run)
st->poll(st);
}
int main(int argc,char **argv)
{
if (argc == 2) {
if (!strcmp(argv[1],"client"))
return do_client();
else if (!strcmp(argv[1],"server"))
return do_server();
}
printf("Usage: system_transport-test <client / server>\n");
return -1;
}

View File

@ -0,0 +1,185 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include "impl/misc.h"
#include "anode.h"
int AnodeURI_parse(AnodeURI *parsed_uri,const char *uri_string)
{
char buf[sizeof(AnodeURI)];
unsigned long ptr = 0;
char c;
char *p1,*p2;
Anode_zero((void *)parsed_uri,sizeof(AnodeURI));
/* Get the scheme */
for(;;) {
c = *(uri_string++);
if (!c) {
parsed_uri->scheme[ptr] = (char)0;
return ANODE_ERR_INVALID_URI;
} else if (c == ':') {
parsed_uri->scheme[ptr] = (char)0;
break;
} else {
parsed_uri->scheme[ptr++] = c;
if (ptr == sizeof(parsed_uri->scheme))
return ANODE_ERR_BUFFER_TOO_SMALL;
}
}
if (*uri_string == '/') {
/* If it starts with /, it's a URL */
/* Skip double slash */
if (!(*(++uri_string)))
return 0; /* Scheme with no path */
if (*uri_string == '/') {
if (!(*(++uri_string)))
return 0; /* Scheme with no path */
}
/* Get the host section and put it in buf[] */
ptr = 0;
while ((*uri_string)&&(*uri_string != '/')) {
buf[ptr++] = *(uri_string++);
if (ptr == sizeof(buf))
return ANODE_ERR_BUFFER_TOO_SMALL;
}
buf[ptr] = (char)0;
/* Parse host section for host, username, password, and port */
if (buf[0]) {
p1 = (char *)Anode_strchr(buf,'@');
if (p1) {
*(p1++) = (char)0;
if (*p1) {
p2 = (char *)Anode_strchr(buf,':');
if (p2) {
*(p2++) = (char)0;
Anode_str_copy(parsed_uri->password,p2,sizeof(parsed_uri->password));
}
Anode_str_copy(parsed_uri->username,buf,sizeof(parsed_uri->username));
} else return ANODE_ERR_INVALID_URI;
} else p1 = buf;
p2 = (char *)Anode_strchr(p1,':');
if (p2) {
*(p2++) = (char)0;
if (*p2)
parsed_uri->port = (int)strtoul(p2,(char **)0,10);
}
Anode_str_copy(parsed_uri->host,p1,sizeof(parsed_uri->host));
}
/* Get the path, query, and fragment section and put it in buf[] */
ptr = 0;
while ((buf[ptr++] = *(uri_string++))) {
if (ptr == sizeof(buf))
return ANODE_ERR_BUFFER_TOO_SMALL;
}
/* Parse path section for path, query, and fragment */
if (buf[0]) {
p1 = (char *)Anode_strchr(buf,'?');
if (p1) {
*(p1++) = (char)0;
p2 = (char *)Anode_strchr(p1,'#');
if (p2) {
*(p2++) = (char)0;
Anode_str_copy(parsed_uri->fragment,p2,sizeof(parsed_uri->fragment));
}
Anode_str_copy(parsed_uri->query,p1,sizeof(parsed_uri->query));
} else {
p2 = (char *)Anode_strchr(buf,'#');
if (p2) {
*(p2++) = (char)0;
Anode_str_copy(parsed_uri->fragment,p2,sizeof(parsed_uri->fragment));
}
}
Anode_str_copy(parsed_uri->path,buf,sizeof(parsed_uri->path));
}
} else {
/* Otherwise, it's a URN and what remains is all path */
ptr = 0;
while ((parsed_uri->path[ptr++] = *(uri_string++))) {
if (ptr == sizeof(parsed_uri->path))
return ANODE_ERR_BUFFER_TOO_SMALL;
}
}
return 0;
}
char *AnodeURI_to_string(const AnodeURI *uri,char *buf,int len)
{
int i = 0;
char portbuf[16];
const char *p;
p = uri->scheme;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
buf[i++] = ':'; if (i >= len) return (char *)0;
if (uri->host[0]) {
buf[i++] = '/'; if (i >= len) return (char *)0;
buf[i++] = '/'; if (i >= len) return (char *)0;
if (uri->username[0]) {
p = uri->username;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
if (uri->password[0]) {
buf[i++] = ':'; if (i >= len) return (char *)0;
p = uri->password;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
}
buf[i++] = '@'; if (i >= len) return (char *)0;
}
p = uri->host;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
if ((uri->port > 0)&&(uri->port <= 0xffff)) {
buf[i++] = ':'; if (i >= len) return (char *)0;
snprintf(portbuf,sizeof(portbuf),"%d",uri->port);
p = portbuf;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
}
}
p = uri->path;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
if (uri->query[0]) {
buf[i++] = '?'; if (i >= len) return (char *)0;
p = uri->query;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
}
if (uri->fragment[0]) {
buf[i++] = '#'; if (i >= len) return (char *)0;
p = uri->fragment;
while (*p) { buf[i++] = *(p++); if (i >= len) return (char *)0; }
}
buf[i] = (char)0;
return buf;
}

View File

@ -0,0 +1,50 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include "../anode.h"
#include "../impl/misc.h"
#include "../impl/types.h"
int main(int argc,char **argv)
{
char str[1024];
AnodeZone zone;
AnodeIdentity identity;
if (argc < 2) {
printf("Usage: anode-make-identity <32-bit zone ID hex>\n");
return 0;
}
*((uint32_t *)zone.bits) = htonl((uint32_t)strtoul(argv[1],(char **)0,16));
if (AnodeIdentity_generate(&identity,&zone,ANODE_ADDRESS_ANODE_256_40)) {
fprintf(stderr,"Error: identity key pair generation failed (check build settings).\n");
return 1;
}
if (AnodeIdentity_to_string(&identity,str,sizeof(str)) <= 0) {
fprintf(stderr,"Error: internal error converting identity to string.\n");
return -1;
}
printf("%s\n",str);
return 0;
}

View File

@ -0,0 +1,184 @@
/* libanode: the Anode C reference implementation
* Copyright (C) 2009-2010 Adam Ierymenko <adam.ierymenko@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "impl/types.h"
#include "impl/misc.h"
#include "impl/dictionary.h"
#include "impl/environment.h"
#include "impl/http_client.h"
#include "anode.h"
static const char *_MONTHS[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
static const char *_DAYS_OF_WEEK[7] = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" };
static inline unsigned long get_file_time_for_http(const char *path,char *buf,unsigned int len)
{
struct stat st;
struct tm *gmt;
if (!stat(path,(struct stat *)&st)) {
gmt = gmtime(&st.st_mtime);
if (gmt) {
snprintf(buf,len,"%s, %d %s %d %d:%d:%d GMT",
_DAYS_OF_WEEK[gmt->tm_wday],
gmt->tm_mday,
_MONTHS[gmt->tm_mon],
(1900 + gmt->tm_year),
gmt->tm_hour,
gmt->tm_min,
gmt->tm_sec);
buf[len - 1] = (char)0;
return (unsigned long)st.st_size;
}
}
return 0;
}
struct AnodeZoneLookupJob
{
char cached_zone_file[2048];
struct AnodeDictionary *zone_dict;
AnodeZone zone;
void *ptr;
void (*zone_lookup_handler)(void *,const AnodeZone *,AnodeZoneFile *);
int had_cached_zone;
};
static void AnodeZone_lookup_http_handler(struct AnodeHttpClient *client)
{
char *data_tmp;
struct AnodeZoneLookupJob *job = (struct AnodeZoneLookupJob *)client->ptr[0];
FILE *zf;
if ((client->response.code == 200)&&(client->response.data_length > 0)) {
zf = fopen(job->cached_zone_file,"w");
if (zf) {
fwrite(client->response.data,1,client->response.data_length,zf);
fclose(zf);
}
data_tmp = (char *)malloc(client->response.data_length + 1);
Anode_memcpy((void *)data_tmp,client->response.data,client->response.data_length);
data_tmp[client->response.data_length] = (char)0;
AnodeDictionary_clear(job->zone_dict);
AnodeDictionary_read(
job->zone_dict,
data_tmp,
"\r\n",
"=",
";",
'\\',
1,1);
free((void *)data_tmp);
job->zone_lookup_handler(job->ptr,&job->zone,(AnodeZoneFile *)job->zone_dict);
} else if (job->had_cached_zone)
job->zone_lookup_handler(job->ptr,&job->zone,(AnodeZoneFile *)job->zone_dict);
else {
AnodeDictionary_destroy(job->zone_dict);
free((void *)job->zone_dict);
job->zone_lookup_handler(job->ptr,&job->zone,(AnodeZoneFile *)0);
}
free((void *)job);
AnodeHttpClient_free(client);
}
void AnodeZone_lookup(
AnodeTransportEngine *transport,
const AnodeZone *zone,
void *ptr,
void (*zone_lookup_handler)(void *,const AnodeZone *,AnodeZone *))
{
char cached_zones_folder[2048];
char cached_zone_file[2048];
char if_modified_since[256];
unsigned long file_size;
struct AnodeZoneLookupJob *job;
struct AnodeHttpClient *client;
char *file_data;
FILE *zf;
if (Anode_get_cache_sub("zones",cached_zones_folder,sizeof(cached_zones_folder))) {
snprintf(cached_zone_file,sizeof(cached_zone_file),"%s%c%.2x%.2x%.2x%.2x.z",cached_zones_folder,ANODE_PATH_SEPARATOR,(unsigned int)zone->bits[0],(unsigned int)zone->bits[1],(unsigned int)zone->bits[2],(unsigned int)zone->bits[3]);
cached_zone_file[sizeof(cached_zone_file)-1] = (char)0;
job = (struct AnodeZoneLookupJob *)malloc(sizeof(struct AnodeZoneLookupJob));
Anode_str_copy(job->cached_zone_file,cached_zone_file,sizeof(job->cached_zone_file));
job->zone_dict = (struct AnodeDictionary *)malloc(sizeof(struct AnodeDictionary));
AnodeDictionary_init(job->zone_dict,0);
job->zone.bits[0] = zone->bits[0];
job->zone.bits[1] = zone->bits[1];
job->zone.bits[2] = zone->bits[2];
job->zone.bits[3] = zone->bits[3];
job->ptr = ptr;
job->zone_lookup_handler = zone_lookup_handler;
job->had_cached_zone = 0;
client = AnodeHttpClient_new(transport);
Anode_str_copy(client->uri.scheme,"http",sizeof(client->uri.scheme));
snprintf(client->uri.host,sizeof(client->uri.host),"a--%.2x%.2x%.2x%.2x.net",(unsigned int)zone->bits[0],(unsigned int)zone->bits[1],(unsigned int)zone->bits[2],(unsigned int)zone->bits[3]);
client->uri.host[sizeof(client->uri.host)-1] = (char)0;
Anode_str_copy(client->uri.path,"/z",sizeof(client->uri.path));
client->handler = &AnodeZone_lookup_http_handler;
client->ptr[0] = job;
if ((file_size = get_file_time_for_http(cached_zone_file,if_modified_since,sizeof(if_modified_since)))) {
zf = fopen(cached_zone_file,"r");
if (zf) {
AnodeDictionary_put(&client->headers,"If-Modified-Since",if_modified_since);
file_data = (char *)malloc(file_size + 1);
if (fread((void *)file_data,1,file_size,zf)) {
file_data[file_size] = (char)0;
AnodeDictionary_read(
job->zone_dict,
file_data,
"\r\n",
"=",
";",
'\\',
1,1);
job->had_cached_zone = 1;
}
free((void *)file_data);
fclose(zf);
}
}
AnodeHttpClient_send(client);
} else zone_lookup_handler(ptr,zone,(AnodeZone *)0);
}
const char *AnodeZoneFile_get(AnodeZoneFile *zone,const char *key)
{
return AnodeDictionary_get((struct AnodeDictionary *)zone,key);
}
void AnodeZoneFile_free(AnodeZoneFile *zone)
{
AnodeDictionary_destroy((struct AnodeDictionary *)zone);
free((void *)zone);
}

Some files were not shown because too many files have changed in this diff Show More