README updates, misc filename changes, debug trace fixes, introduction of libzt moniker

This commit is contained in:
Joseph Henry
2017-06-14 16:53:59 -07:00
parent 06682e049e
commit d3351dd2ce
16 changed files with 83 additions and 128 deletions

View File

@@ -1,8 +1,8 @@
## **ZeroTier SDK**: Embed ZeroTier directly into your app
## **libzt**: Embed ZeroTier directly into your app
<a href="https://www.zerotier.com"><img src="https://github.com/zerotier/ZeroTierOne/raw/master/artwork/AppIcon_87x87.png" align="left" hspace="20" vspace="6"></a>
<a href="https://www.zerotier.com"><img src="https://github.com/zerotier/ZeroTierOne/raw/master/artwork/ztapp100.png" align="left" hspace="20" vspace="6"></a>
**ZeroTier** makes it easy to securely connect devices, servers, cloud VMs, containers, and apps everywhere and manage them at scale. Now, with the SDK you can bake this ability directly into your application or service using your preferred language. We provide a BSD socket-like API to make the integration simple.
**ZeroTier** makes it easy to securely connect devices, servers, cloud VMs, containers, and apps everywhere and manage them at scale. Now, with *libzt* you can bake this ability directly into your app or service using your preferred language or framework. We provide a BSD socket-like API to make the integration simple.
<hr>
@@ -13,6 +13,8 @@ Pre-Built Binaries Here: [zerotier.com/download.shtml](https://zerotier.com/down
### Example
```
#include "libzt.h"
char *str = "welcome to the machine";
char *nwid = "c7cd7c9e1b0f52a2";
@@ -35,20 +37,16 @@ All build targets will output to `build/`.
### Static Library
- `make static_lib SDK_IPV4=1`
- `make static_lib`
### iOS App Framework
- `make ios_app_framework SDK_IPV4=1`
- `make ios_app_framework`
### macOS App Framework
- `make macos_app_framework SDK_IPV4=1`
- `make macos_app_framework`
***
## IP version flags
- `SDK_IPV4=1`
- `SDK_IPV6=1`
## Using Language Bindings
- `SDK_LANG_JNI=1`: Enable JNI bindings for Java (produces a shared library)
- `SDK_LANG_CSHARP=1`

BIN
artwork/ztapp100.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -10,7 +10,7 @@
#include <netinet/in.h>
#include <netdb.h>
#include "ZeroTierSDK.h"
#include "libzt.h"
int main()
{
@@ -121,7 +121,6 @@ int main()
// End Socket API calls
// Get the ipv4 address assigned for this network
char addr_str[ZT_MAX_IPADDR_LEN];
zts_get_ipv4_address(nwid, addr_str, ZT_MAX_IPADDR_LEN);
@@ -132,53 +131,10 @@ int main()
printf("peer_count = %lu\n", zts_get_peer_count());
while(1)
{
while(1) {
sleep(1);
}
// ---
/*
"Tap Multiplexer"
- socket() [BEFORE JOIN]: take requests for new sockets
- Create them, and store them in a temporary holding space until we find out where we should assign them
- connect():
- Search SocketTaps for tap with a relevant route
- None? -> ENETUNREACH
- Found?
- Assign previously-held socket to this tap
- Attempt connection
- bind():
- bind on all Interfaces?
Join Semantics
- Create : SocketTap
- Create : rpc.d/nwid unix domain socket (if intercept mode?)
- Create : Stack Interface
- Provide : IPs to Interface
/--- int0: 10. 9.0.0
stack ---- int1: 172.27.0.0
\--- int2: ?
*/
// zts_join("other_network"); // 10.9.0.0
// zts_join("whatever"); // 172.27.0.0
//zts_socket(AF, STREAM, 0);
//zts_connect("10.9.9.5");
// ---
// Stop service, delete tap interfaces, and network stack
zts_stop();
return 0;

View File

@@ -137,12 +137,12 @@ CXXFLAGS+=-DSDK_IPV6
STACK_DRIVER_FILES:=src/picoTCP.cpp
TAP_FILES:=src/SocketTap.cpp \
src/ZeroTierSDK.cpp \
src/libzt.cpp \
src/Utilities.cpp
SDK_OBJS+= SocketTap.o \
picoTCP.o \
ZeroTierSDK.o \
libzt.o \
Utilities.o
PICO_OBJS+= ext/picotcp/build/lib/pico_device.o \

View File

@@ -137,12 +137,12 @@ CXXFLAGS+=-DSDK_IPV6
STACK_DRIVER_FILES:=src/picoTCP.cpp
TAP_FILES:=src/SocketTap.cpp \
src/ZeroTierSDK.cpp \
src/libzt.cpp \
src/Utilities.cpp
SDK_OBJS+= SocketTap.o \
picoTCP.o \
ZeroTierSDK.o \
libzt.o \
Utilities.o
PICO_OBJS+= ext/picotcp/build/lib/pico_device.o \

View File

@@ -136,12 +136,12 @@ CXXFLAGS+=-DSDK_IPV6
STACK_DRIVER_FILES:=src/picoTCP.cpp
TAP_FILES:=src/SocketTap.cpp \
src/ZeroTierSDK.cpp \
src/libzt.cpp \
src/Utilities.cpp
SDK_OBJS+= SocketTap.o \
picoTCP.o \
ZeroTierSDK.o \
libzt.o \
Utilities.o
PICO_OBJS+= ext/picotcp/build/lib/pico_device.o \

View File

@@ -37,7 +37,7 @@
#include "Phy.hpp"
// SDK
#include "ZeroTierSDK.h"
#include "libzt.h"
#include "SocketTap.hpp"
//#include "RingBuffer.hpp"
@@ -72,7 +72,7 @@ namespace ZeroTier {
std::queue<Connection*> _AcceptedConnections;
SocketTap *tap; // Reference to SocketTap
int state; // See ZeroTierSDK.h for (ZT_SOCK_STATE_*)
int state; // See libzt.h for (ZT_SOCK_STATE_*)
// timestamp for closure event
std::time_t closure_ts;

View File

@@ -37,7 +37,7 @@
// SDK
#include "SocketTap.hpp"
#include "ZeroTierSDK.h"
#include "libzt.h"
#include "picoTCP.hpp"
// ZT

View File

@@ -43,7 +43,7 @@
#include "Thread.hpp"
#include "Phy.hpp"
#include "ZeroTierSDK.h"
#include "libzt.h"
#include "picoTCP.hpp"
#include "Connection.hpp"
@@ -181,7 +181,7 @@ namespace ZeroTier {
/*
* Timestamp of last run of housekeeping
* SEE: ZT_HOUSEKEEPING_INTERVAL in ZeroTierSDK.h
* SEE: ZT_HOUSEKEEPING_INTERVAL in libzt.h
*/
std::time_t last_housekeeping_ts;

View File

@@ -42,53 +42,3 @@ void zt_dump_stacktrace(int sig) {
exit(1);
}
*/
/*
char *beautify_pico_error(int err)
{
switch(err){
PICO_ERR_NOERR = 0,
PICO_ERR_EPERM = 1,
PICO_ERR_ENOENT = 2,
PICO_ERR_EINTR = 4,
PICO_ERR_EIO = 5,
PICO_ERR_ENXIO = 6,
PICO_ERR_EAGAIN = 11,
PICO_ERR_ENOMEM = 12,
PICO_ERR_EACCESS = 13,
PICO_ERR_EFAULT = 14,
PICO_ERR_EBUSY = 16,
PICO_ERR_EEXIST = 17,
PICO_ERR_EINVAL = 22,
PICO_ERR_ENONET = 64,
PICO_ERR_EPROTO = 71,
PICO_ERR_ENOPROTOOPT = 92,
PICO_ERR_EPROTONOSUPPORT = 93,
PICO_ERR_EOPNOTSUPP = 95,
PICO_ERR_EADDRINUSE = 98,
PICO_ERR_EADDRNOTAVAIL = 99,
PICO_ERR_ENETDOWN = 100,
PICO_ERR_ENETUNREACH = 101,
PICO_ERR_ECONNRESET = 104,
PICO_ERR_EISCONN = 106,
PICO_ERR_ENOTCONN = 107,
PICO_ERR_ESHUTDOWN = 108,
PICO_ERR_ETIMEDOUT = 110,
PICO_ERR_ECONNREFUSED = 111,
PICO_ERR_EHOSTDOWN = 112,
PICO_ERR_EHOSTUNREACH = 113,
}
return err_text;
}
*/

View File

@@ -49,7 +49,7 @@
// SDK
#include "SocketTap.hpp"
#include "ZeroTierSDK.h"
#include "libzt.h"
#ifdef __cplusplus
extern "C" {
@@ -434,7 +434,7 @@ int zts_connect(ZT_CONNECT_SIG) {
if(fd < 0) {
errno = EBADF;
DEBUG_ERROR("EBADF");
err = -1;
return -1;
}
if(!zt1Service) {
DEBUG_ERROR("Service not started. Call zts_start(path) first");

View File

@@ -38,7 +38,7 @@
#include "pico_ipv6.h"
// SDK
#include "ZeroTierSDK.h"
#include "libzt.h"
#include "Utilities.hpp"
#include "SocketTap.hpp"
#include "picoTCP.hpp"
@@ -692,4 +692,55 @@ namespace ZeroTier {
}
return err;
}
int beautify_pico_error(int err)
{
return 0;
/*
switch(err){
PICO_ERR_NOERR = 0,
PICO_ERR_EPERM = 1,
PICO_ERR_ENOENT = 2,
PICO_ERR_EINTR = 4,
PICO_ERR_EIO = 5,
PICO_ERR_ENXIO = 6,
PICO_ERR_EAGAIN = 11,
PICO_ERR_ENOMEM = 12,
PICO_ERR_EACCESS = 13,
PICO_ERR_EFAULT = 14,
PICO_ERR_EBUSY = 16,
PICO_ERR_EEXIST = 17,
PICO_ERR_EINVAL = 22,
PICO_ERR_ENONET = 64,
PICO_ERR_EPROTO = 71,
PICO_ERR_ENOPROTOOPT = 92,
PICO_ERR_EPROTONOSUPPORT = 93,
PICO_ERR_EOPNOTSUPP = 95,
PICO_ERR_EADDRINUSE = 98,
PICO_ERR_EADDRNOTAVAIL = 99,
PICO_ERR_ENETDOWN = 100,
PICO_ERR_ENETUNREACH = 101,
PICO_ERR_ECONNRESET = 104,
PICO_ERR_EISCONN = 106,
PICO_ERR_ENOTCONN = 107,
PICO_ERR_ESHUTDOWN = 108,
PICO_ERR_ETIMEDOUT = 110,
PICO_ERR_ECONNREFUSED = 111,
PICO_ERR_EHOSTDOWN = 112,
PICO_ERR_EHOSTUNREACH = 113,
}
return err_text;
*/
}
}

View File

@@ -40,7 +40,7 @@
#include "SocketTap.hpp"
/****************************************************************************/
/* PicoTCP API Signatures (See ZeroTierSDK.h for the API an app should use) */
/* PicoTCP API Signatures (See libzt.h for the API an app should use) */
/****************************************************************************/
#define PICO_IPV4_TO_STRING_SIG char *ipbuf, const uint32_t ip

View File

@@ -45,7 +45,7 @@
#include <fstream>
#include <map>
#include "ZeroTierSDK.h"
#include "libzt.h"
#define PASSED 0
#define FAILED -1

View File

@@ -24,9 +24,6 @@
* of your own application.
*/
#include "ztproxy.hpp"
#include "ZeroTierSDK.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
@@ -49,6 +46,9 @@
#include <fstream>
#include <map>
#include "ztproxy.hpp"
#include "libzt.h"
namespace ZeroTier {
typedef void PhySocket;
@@ -242,7 +242,7 @@ namespace ZeroTier {
void ZTProxy::phyOnTcpAccept(PhySocket *sockL,PhySocket *sockN,void **uptrL,void **uptrN,const struct sockaddr *from)
{
DEBUG_INFO("phyOnTcpAccept, sockL=%d, sockN=%d", sockL, sockN);
DEBUG_INFO("phyOnTcpAccept, sockL=%p, sockN=%p", sockL, sockN);
TcpConnection *conn;
// try to recycle TcpConnection objects instead of allocating new ones
if(cqueue.size()) {
@@ -292,13 +292,13 @@ namespace ZeroTier {
}
void ZTProxy::phyOnUnixWritable(PhySocket *sock,void **uptr,bool lwip_invoked)
{
DEBUG_INFO("phyOnUnixWritable, sock=%d", sock);
DEBUG_INFO("phyOnUnixWritable, sock=%p", sock);
exit(0);
}
void ZTProxy::phyOnTcpClose(PhySocket *sock,void **uptr)
{
DEBUG_INFO("phyOnTcpClose, sock=%d", sock);
DEBUG_INFO("phyOnTcpClose, sock=%p", sock);
TcpConnection *conn = cmap[sock];
if(conn)