diff --git a/Makefile b/Makefile index 77ea515..c5be365 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ update: # Patch submodules (issue update first) patch: - -cd ext/lwip; git apply ../lwip.patch; - -cd ext/lwip-contrib; git apply ../lwip-contrib.patch; + #-cd ext/lwip; git apply ../lwip.patch; + #-cd ext/lwip-contrib; git apply ../lwip-contrib.patch; #-cd ext/ZeroTierOne; git apply ../ZeroTierOne.patch; # Target-specific clean diff --git a/README.md b/README.md index 99adf66..c74e2d4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,26 @@ The ZeroTier SDK is composed of two libraries: `libztcore` which is the platfor
-For a complete example, see [test/simple.cpp](test/simple.cpp) or [test/example.cpp](test/example.cpp). With no error checking, a paraphrased example is as follows: +## Downloads / Installation + + Tarballs: + + - [libzt-release.tar.gz](https://download.zerotier.com/dist/sdk/libzt-1.3.0-release.tar.gz) // [libzt-debug.tar.gz](https://download.zerotier.com/dist/sdk/libzt-1.3.0-debug.tar.gz) // [libzt-source.tar.gz](https://download.zerotier.com/dist/sdk/libzt-1.3.0-source.tar.gz) + +Homebrew + +``` +brew install libzt +``` + +*** + +
+ +## Example + + - Complete example: [test/simple.cpp](test/simple.cpp) + - Slightly more thorough example: [test/example.cpp](test/example.cpp) ``` #include "ZeroTier.h" @@ -38,11 +57,18 @@ int main() ... ``` +After you've created a virtual network and added its `nwid` to the sample code, run: + +``` +clang++ example.cpp -o example -lzt +./example +``` + The complete API specification can be found here: [API.md](API.md) *** -## Build +## Build from source Build scripts use a combination of make, and cmake. To retrieve sources for all submodules, patch them, and build all targets (debug and release) for your host machine, issue the following: diff --git a/test/simple.cpp b/test/simple.cpp index 7f0bdbd..6c39833 100644 --- a/test/simple.cpp +++ b/test/simple.cpp @@ -1,10 +1,10 @@ +#include + #include #include #include #include -#include "ZeroTier.h" - bool node_ready = false; bool network_ready = false; @@ -49,20 +49,21 @@ int main() // Set up ZeroTier service and wai for callbacks int port = 9994; - int nwid = 0x0123456789abcdef; - zts_start("test/path", &myZeroTierEventCallback, port); + uint64_t nwid = 0x0123456789abcdef; + zts_start("zt_config/path", &myZeroTierEventCallback, port); printf("Waiting for node to come online...\n"); while (!node_ready) { sleep(1); } zts_join(nwid); printf("Joined virtual network. Requesting configuration...\n"); while (!network_ready) { sleep(1); } + printf("I am %llx\n", zts_get_node_id()); // Socket API example if ((fd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("error creating socket\n"); } if ((err = zts_connect(fd, (const struct sockaddr *)&addr, sizeof(addr))) < 0) { - printf("error connecting to remote host\n"); + printf("error connecting to remote host (%s)\n", remoteIp); } if ((err = zts_write(fd, str, strlen(str))) < 0) { printf("error writing to socket\n"); @@ -70,4 +71,4 @@ int main() zts_close(fd); zts_stop(); return 0; -} \ No newline at end of file +}