zerotier / libzt Goto Github PK
View Code? Open in Web Editor NEWEncrypted P2P sockets over ZeroTier
Home Page: https://zerotier.com
License: Other
Encrypted P2P sockets over ZeroTier
Home Page: https://zerotier.com
License: Other
OSX 10.11.6 El Capitan, amd64, I tried compiling the sdk
jaten@jatens-MacBook-Pro ~/go/src/github.com/zerotier $ jaten@jatens-MacBook-Pro ~/go/src/github.com/zerotier/ZeroTierSDK (master) $ make apple SDK_PICOTCP=1 SDK_IPV4=1 SDK_DEBUG=1;
make apple SDK_PICOTCP=1 SDK_IPV4=1 SDK_DEBUG=1;
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/controller/EmbeddedNetworkController.o zto/controller/EmbeddedNetworkController.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/controller/JSONDB.o zto/controller/JSONDB.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/C25519.o zto/node/C25519.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Capability.o zto/node/Capability.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/CertificateOfMembership.o zto/node/CertificateOfMembership.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/CertificateOfOwnership.o zto/node/CertificateOfOwnership.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Cluster.o zto/node/Cluster.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Identity.o zto/node/Identity.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/IncomingPacket.o zto/node/IncomingPacket.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/InetAddress.o zto/node/InetAddress.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Membership.o zto/node/Membership.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Multicaster.o zto/node/Multicaster.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Network.o zto/node/Network.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/NetworkConfig.o zto/node/NetworkConfig.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Node.o zto/node/Node.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/OutboundMulticast.o zto/node/OutboundMulticast.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Packet.o zto/node/Packet.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Path.o zto/node/Path.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Peer.o zto/node/Peer.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Poly1305.o zto/node/Poly1305.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Revocation.o zto/node/Revocation.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Salsa20.o zto/node/Salsa20.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/SelfAwareness.o zto/node/SelfAwareness.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/SHA512.o zto/node/SHA512.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Switch.o zto/node/Switch.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Tag.o zto/node/Tag.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Topology.o zto/node/Topology.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/node/Utils.o zto/node/Utils.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/osdep/ManagedRoute.o zto/osdep/ManagedRoute.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/osdep/Http.o zto/osdep/Http.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/osdep/OSUtils.o zto/osdep/OSUtils.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/service/ClusterGeoIpService.o zto/service/ClusterGeoIpService.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/service/SoftwareUpdater.o zto/service/SoftwareUpdater.cpp
cc -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -c -o zto/ext/http-parser/http_parser.o zto/ext/http-parser/http_parser.c
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/service/OneService.o zto/service/OneService.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/one.o zto/one.cpp
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -c -o zto/osdep/OSXEthernetTap.o zto/osdep/OSXEthernetTap.cpp
mkdir -p build
c++ -Wall -fPIE -fvisibility=hidden -pthread -Iext -Izto/osdep -Izto/node -Izto/service -I../zto/osdep -I../zto/node -I../zto/service -I. -Isrc -Isrc/stack_drivers -Iext/picotcp/include -Iext/picotcp/build/include -Isrc/stack_drivers/picotcp -DSDK_DEBUG -g -fno-rtti -std=c++11 -DZT_SDK -o build/zerotier-one zto/controller/EmbeddedNetworkController.o zto/controller/JSONDB.o zto/node/C25519.o zto/node/Capability.o zto/node/CertificateOfMembership.o zto/node/CertificateOfOwnership.o zto/node/Cluster.o zto/node/Identity.o zto/node/IncomingPacket.o zto/node/InetAddress.o zto/node/Membership.o zto/node/Multicaster.o zto/node/Network.o zto/node/NetworkConfig.o zto/node/Node.o zto/node/OutboundMulticast.o zto/node/Packet.o zto/node/Path.o zto/node/Peer.o zto/node/Poly1305.o zto/node/Revocation.o zto/node/Salsa20.o zto/node/SelfAwareness.o zto/node/SHA512.o zto/node/Switch.o zto/node/Tag.o zto/node/Topology.o zto/node/Utils.o zto/osdep/ManagedRoute.o zto/osdep/Http.o zto/osdep/OSUtils.o zto/service/ClusterGeoIpService.o zto/service/SoftwareUpdater.o zto/ext/http-parser/http_parser.o zto/service/OneService.o zto/one.o zto/osdep/OSXEthernetTap.o
clang: warning: argument unused during compilation: '-pthread'
Undefined symbols for architecture x86_64:
"ZeroTier::NetconEthernetTap::scanMulticastGroups(std::__1::vector<ZeroTier::MulticastGroup, std::__1::allocator<ZeroTier::MulticastGroup> >&, std::__1::vector<ZeroTier::MulticastGroup, std::__1::allocator<ZeroTier::MulticastGroup> >&)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::run() in OneService.o
"ZeroTier::NetconEthernetTap::put(ZeroTier::MAC const&, ZeroTier::MAC const&, unsigned int, void const*, unsigned int)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::nodeVirtualNetworkFrameFunction(unsigned long long, void**, unsigned long long, unsigned long long, unsigned int, unsigned int, void const*, unsigned int) in OneService.o
"ZeroTier::NetconEthernetTap::addIp(ZeroTier::InetAddress const&)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::syncManagedStuff(ZeroTier::(anonymous namespace)::OneServiceImpl::NetworkState&, bool, bool) in OneService.o
"ZeroTier::NetconEthernetTap::removeIp(ZeroTier::InetAddress const&)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::syncManagedStuff(ZeroTier::(anonymous namespace)::OneServiceImpl::NetworkState&, bool, bool) in OneService.o
"ZeroTier::NetconEthernetTap::NetconEthernetTap(char const*, ZeroTier::MAC const&, unsigned int, unsigned int, unsigned long long, char const*, void (*)(void*, unsigned long long, ZeroTier::MAC const&, ZeroTier::MAC const&, unsigned int, unsigned int, void const*, unsigned int), void*)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::nodeVirtualNetworkConfigFunction(unsigned long long, void**, ZT_VirtualNetworkConfigOperation, ZT_VirtualNetworkConfig const*) in OneService.o
"ZeroTier::NetconEthernetTap::~NetconEthernetTap()", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::run() in OneService.o
ZeroTier::(anonymous namespace)::OneServiceImpl::nodeVirtualNetworkConfigFunction(unsigned long long, void**, ZT_VirtualNetworkConfigOperation, ZT_VirtualNetworkConfig const*) in OneService.o
"ZeroTier::NetconEthernetTap::deviceName() const", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::portDeviceName(unsigned long long) const in OneService.o
ZeroTier::(anonymous namespace)::OneServiceImpl::syncManagedStuff(ZeroTier::(anonymous namespace)::OneServiceImpl::NetworkState&, bool, bool) in OneService.o
"ZeroTier::NetconEthernetTap::ips() const", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::syncManagedStuff(ZeroTier::(anonymous namespace)::OneServiceImpl::NetworkState&, bool, bool) in OneService.o
ZeroTier::(anonymous namespace)::OneServiceImpl::nodePathCheckFunction(unsigned long long, sockaddr_storage const*, sockaddr_storage const*) in OneService.o
ZeroTier::(anonymous namespace)::OneServiceImpl::shouldBindInterface(char const*, ZeroTier::InetAddress const&) in OneService.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [one] Error 1
jaten@jatens-MacBook-Pro ~/go/src/github.com/zerotier/ZeroTierSDK (master) $
When integrating the API into other projects, it would be quite nice to be able to integrate them with CMake. Having this project deliver a CMake file, and use of CMake, may solve other challenges that the project has as well (like detecting platforms, compiler options, etc. etc.)
And possibly other useful network/state management features
Hi again!
I tried running an http service in a Network Container (docker). I can ping the container and connect to the port (telnet), but I can't seem to get any http traffic through. Just hangs 😕
Any idea why this might be?
Regards,
Asbjørn
Hello! I have a very basic proxy server sort of working, but one issue that is proving difficult to figure out is getting the IP address of the virtual socket. This code runs after zts_startjoin() succeeds.
I've never seen zts_has_address() return anything other than a 1.
Like all good bugs, its harder to get it to happen when debugging the code, but the few times it has happened it seems to die at the call to Marhal.PtrToStructure.
Any help is greatly appreciated!
static IPAddress GetAddress(ulong nwid)
{
int err = 0;
IntPtr addressPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(libzt.SockAddrIn)));
int hasAddress = 0;
while((hasAddress = libzt.zts_has_address(nwid)) != 1)
{
Console.WriteLine("No address assigned yet...");
Thread.Sleep(500);
}
if ((err = libzt.zts_get_address(nwid, addressPtr, 2)) < 0)
{
throw new Exception("Failed to get IP address");
}
var address = Marshal.PtrToStructure<libzt.SockAddrIn>(addressPtr);
byte[] ipbytes = BitConverter.GetBytes(address.Addr);
Marshal.FreeHGlobal(addressPtr);
return new IPAddress(ipbytes);
}
I am building a mesh network using libzt
and wanna give nodes the ability to choose a moon as the gateway to access other networks. I have considered SNAT and DNAT on moons but the application will be unable to know its peers so I want to stick with the route way.
I discover that ZT1Service.hpp
has a zts_get_network_routes
function, and the source code does have functions to synchronize managed routes, but I don't know how it will take effects and whether they will work if I modify the routes later.
Would you mind giving me some instructions about it? Thanks in advance.
I have a use case where I want to use the layer 2 stuff directly, without needing the L3/4 stuff (i.e. no IP, TCP, etc.)
I can build this using libzerotiercore, but it seems like it would be nicer if the SDK offered an AF_PACKET style support.
I do not believe it is necessary to support all the Linux options there (e.g. no need for rings in first version, or fanout, or some of the other socket options -- I think only the socket options for managing multicast are really necessary for full functionality, and initially even those could be elided (I don't need them for example).
The details of the AF_PACKET family on Linux are here:
http://man7.org/linux/man-pages/man7/packet.7.html
I think this is an excellent starting point for offering L2 style capabilities to userland.
Lack of support for select/epoll-like call in the API makes it really hard to use for non-trivial usages.
WIndows/NET/C#版本的SDK什么时候发布?作为.NET工程师表示很期待。
The downloads in the README no longer work; it looks like the entire sdk
directory is gone.
There is a folder with a readme in /examples/python, yet there is no code example given.
We're experiencing an issue with zts_select which results in semaphore exhaustion in lwip, which results in an assertion because the number of semaphores overflows.
Code to reproduce the issue can be found in ztserver on the "semaphore-broken" branch here: https://github.com/HiveMP/ztserver/blob/semaphore-broken/main.cpp#L240-L252
Once running the application, you can replicate it with:
curl -X PUT \
http://localhost:8080/join \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 9350f4c5-4f53-c05d-4c3f-165a31f3f376' \
-d '{
"nwid": "8bd5124fd6206336",
"path": "ztidentity2"
}'
Wait for ztserver to join the network, then run:
curl -X PUT \
http://localhost:8080/forward \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 6080dc26-719e-0199-0fbf-4a64a9014c46' \
-d '{
"localport": 55000
}'
After a little while in the ztserver output, you'll see the following:
INFO [0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\ZT1Service.cpp: 225: zts_start_service: binding to port=9995
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\ZT1Service.cpp: 454: zts_start: waiting for node address assignment
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\ZT1Service.cpp: 512: zts_get_node_id:
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\ZT1Service.cpp: 458: zts_start: node=abba16d2f6
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\ZT1Service.cpp: 459: zts_start: waiting for node to come online
INFO [0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\VirtualTap.cpp: 86: VirtualTap::VirtualTap: set VirtualTap interface name to: libzt0-8bd5124fd6206336
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 218: lwip_driver_init:
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 117: tcpip_init_done: tcpip-thread
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 200: main_thread: stack thread init complete
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\ZT1Service.cpp: 380: zts_join:
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\VirtualTap.cpp: 138: VirtualTap::addIp: addr=172.25.1.66/16, nwid=8bd5124fd6206336
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 345: lwip_init_interface: lwipInterfacesCount=0
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 347: lwip_init_interface: netif=00EA0778
INFO [0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 373: lwip_init_interface: initialized netif as [mac=36:c8:9a:c0:9d:e4, addr=172.25.1.66/16, nm=255.255.0.0/16]
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\VirtualTap.cpp: 138: VirtualTap::addIp: addr=fc5d:f571:79ab:ba16:d2f6:0000:0000:0001/40, nwid=8bd5124fd6206336
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 345: lwip_init_interface: lwipInterfacesCount=1
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 347: lwip_init_interface: netif=00EA0828
INFO [0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 396: lwip_init_interface: initialized netif as [mac=36:c8:9a:c0:9d:e4, addr=fc5d:f571:79ab:ba16:d2f6:0000:0000:0001/40]
TRANS[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 266: lwip_eth_tx: len= 78 dst=33:33:ff:c0:9d:e4 [50df16d2f6 TX <-- abba16d2f6] proto=0x86dd IPv6
TRANS[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 266: lwip_eth_tx: len= 78 dst=33:33:ff:00:00:01 [50dfd64f13 TX <-- abba16d2f6] proto=0x86dd IPv6
TRANS[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 266: lwip_eth_tx: len= 62 dst=33:33:00:00:00:02 [5020d64f10 TX <-- abba16d2f6] proto=0x86dd IPv6
TRANS[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 266: lwip_eth_tx: len= 70 dst=33:33:00:00:00:02 [5020d64f10 TX <-- abba16d2f6] proto=0x86dd IPv6
TRANS[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 266: lwip_eth_tx: len= 70 dst=33:33:00:00:00:02 [5020d64f10 TX <-- abba16d2f6] proto=0x86dd IPv6
TRANS[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\lwIP.cpp: 266: lwip_eth_tx: len= 70 dst=33:33:00:00:00:02 [5020d64f10 TX <-- abba16d2f6] proto=0x86dd IPv6
creating zerotier socket...
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\libzt.cpp: 63: zts_socket: family=2, type=2, proto=0
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\libzt.cpp: 63: zts_socket: family=23, type=2, proto=0
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\libzt.cpp: 110: zts_bind: fd=0
EXTRA[0]: C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\src\libzt.cpp: 110: zts_bind: fd=1
Assertion "sys_sem_free() closed more than created" failed at line 198 in C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\ext\lwip-contrib\ports\win32\sys_arch.c
Assertion "sys_sem_new() counter overflow" failed at line 176 in C:\RedpointJenkinsOSS\workspace\masteraf7ce1af@2\libzt\ext\lwip-contrib\ports\win32\sys_arch.c
and debugging in Visual Studio shows the breakpoint here:
Building failed when executing cmake --build build
.
[ 25%] Building CXX object CMakeFiles/zto_obj.dir/ext/ZeroTierOne/controller/EmbeddedNetworkController.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/JavaVM.framework/Headers -I/tmp/libzt/src -I/tmp/libzt/ext/ZeroTierOne/include -I/tmp/libzt/ext/ZeroTierOne/osdep -I/tmp/libzt/ext/ZeroTierOne/node -I/tmp/libzt/ext/ZeroTierOne/service -I/tmp/libzt/include -I/tmp/libzt/ext/lwip/src/include -I/tmp/libzt/ext/lwip-contrib/ports/unix/port/include -DZT_SDK=1 -Wno-unused-parameter -Wno-unused-variable -Wno-missing-field-initializers -O3 -Wall -Wextra -std=c++11 -O3 -DNDEBUG -DZT_SDK=1 -Wno-unused-parameter -Wno-unused-variable -Wno-missing-field-initializers -O3 -std=c++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -o CMakeFiles/zto_obj.dir/ext/ZeroTierOne/controller/EmbeddedNetworkController.cpp.o -c /tmp/libzt/ext/ZeroTierOne/controller/EmbeddedNetworkController.cpp
In file included from /tmp/libzt/ext/ZeroTierOne/controller/EmbeddedNetworkController.cpp:40:
In file included from /tmp/libzt/ext/ZeroTierOne/controller/EmbeddedNetworkController.hpp:39:
In file included from /tmp/libzt/ext/ZeroTierOne/controller/../osdep/OSUtils.hpp:58:
/tmp/libzt/ext/ZeroTierOne/controller/../ext/json/json.hpp:1360:9: error: static_assert failed
"could not find from_json() method in T's namespace"
static_assert(sizeof(BasicJsonType) == 0,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/libzt/ext/ZeroTierOne/controller/../ext/json/json.hpp:1375:16: note: in instantiation of function template
specialization 'nlohmann::detail::from_json_fn::call<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned
long long, double, std::allocator, adl_serializer>, std::__1::basic_string_view<char, std::__1::char_traits<char> > >' requested here
return call(j, val, priority_tag<1> {});
^
/tmp/libzt/ext/ZeroTierOne/controller/../ext/json/json.hpp:6923:9: note: in instantiation of function template
specialization 'nlohmann::detail::from_json_fn::operator()<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long,
unsigned long long, double, std::allocator, adl_serializer>, std::__1::basic_string_view<char, std::__1::char_traits<char> > >' requested here
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
^
/tmp/libzt/ext/ZeroTierOne/controller/../ext/json/json.hpp:9678:36: note: in instantiation of function template
specialization 'nlohmann::adl_serializer<std::__1::basic_string_view<char, std::__1::char_traits<char> >, void>::from_json<const
nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer> &,
std::__1::basic_string_view<char, std::__1::char_traits<char> > >' requested here
JSONSerializer<ValueType>::from_json(*this, ret);
^
/tmp/libzt/ext/ZeroTierOne/controller/../ext/json/json.hpp:9939:16: note: in instantiation of function template
specialization 'nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator,
adl_serializer>::get<std::__1::basic_string_view<char, std::__1::char_traits<char> >, std::__1::basic_string_view<char, std::__1::char_traits<char> >, 0>'
requested here
return get<ValueType>();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:875:29: note: in instantiation of function template
specialization 'nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator,
adl_serializer>::operator basic_string_view<std::__1::basic_string_view<char, std::__1::char_traits<char> >, 0>' requested here
{__self_view __sv = __t; return assign(__sv);}
^
/tmp/libzt/ext/ZeroTierOne/controller/EmbeddedNetworkController.cpp:552:13: note: in instantiation of function
template specialization 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::operator=<nlohmann::basic_json<std::map,
std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer>, void>' requested here
mid = (*member)["id"];
^
1 error generated.
make[2]: *** [CMakeFiles/zto_obj.dir/ext/ZeroTierOne/controller/EmbeddedNetworkController.cpp.o] Error 1
make[1]: *** [CMakeFiles/zto_obj.dir/all] Error 2
make: *** [all] Error 2
My application calling libzt
keeps growing its memory usage, and here is the output of top -l 1
on macOS using the UDP server example:
PID COMMAND %CPU TIME #TH #WQ #PORTS MEM
94251 ZeroTier One 0.0 13:40.13 8 6 324+ 26M+
42678 ipv4client_udp 0.0 00:52.05 5 0 14+ 6188K+
42674 ipv4server_udp 0.0 00:10.45 5 0 14+ 770M+
I modified ipv4client_udp.cpp#L93 to usleep(50)
to produce it quickly.
EDIT:
LWIP_GUARDED_BUF_CHECK_INTERVAL
to 3
for rapid packet handling beforehand.ipv4server_udp
and by looking into the traces, I want to know when and where will lwIP.cpp#L321 be deallocated./usr/bin/c++ -fvisibility=hidden -fstack-protector -DZT_SDK=1 -std=c++11 -O3 -DNDEBUG -fvisibility=hidden -fstack-protector -DZT_SDK=1 -std=c++11 CMakeFiles/ipv6adhocclient.dir/examples/bindings/cpp/ipv6adhoc/ipv6adhocclient.cpp.o -o ../bin/ipv6adhocclient -rdynamic -lpthread ../bin/lib/liblwip.a ../bin/lib/libzto.a ../bin/lib/libzt.a ../bin/lib/libzto.a ../bin/lib/libzt.a ../bin/lib/libhttp.a ../bin/lib/liblwip.a
../bin/lib/libzt.a(ZT1Service.cpp.o): In function `zts_start.part.9':
ZT1Service.cpp:(.text+0x3d): undefined reference to `pthread_create'
../bin/lib/libzto.a(EmbeddedNetworkController.cpp.o): In function `ZeroTier::EmbeddedNetworkController::_startThreads()':
EmbeddedNetworkController.cpp:(.text+0xca5): undefined reference to `pthread_create'
EmbeddedNetworkController.cpp:(.text+0xde7): undefined reference to `pthread_create'
../bin/lib/libzt.a(VirtualTap.cpp.o): In function `VirtualTap::~VirtualTap()':
VirtualTap.cpp:(.text+0xbfa): undefined reference to `pthread_join'
../bin/lib/libzt.a(VirtualTap.cpp.o): In function `VirtualTap::VirtualTap(char const*, ZeroTier::MAC const&, unsigned int, unsigned int, unsigned long, char const*, void (*)(void*, void*, unsigned long, ZeroTier::MAC const&, ZeroTier::MAC const&, unsigned int, unsigned int, void const*, unsigned int), void*)':
VirtualTap.cpp:(.text+0x159c): undefined reference to `pthread_attr_setstacksize'
VirtualTap.cpp:(.text+0x15b3): undefined reference to `pthread_create'
../bin/lib/liblwip.a(sys_arch.c.o): In function `sys_thread_new':
sys_arch.c:(.text+0x16): undefined reference to `pthread_create'
../bin/lib/liblwip.a(sys_arch.c.o): In function `sys_mbox_new':
sys_arch.c:(.text+0x11d): undefined reference to `pthread_condattr_setclock'
sys_arch.c:(.text+0x16c): undefined reference to `pthread_condattr_setclock'
sys_arch.c:(.text+0x1bb): undefined reference to `pthread_condattr_setclock'
../bin/lib/liblwip.a(sys_arch.c.o): In function `sys_sem_new':
sys_arch.c:(.text+0x987): undefined reference to `pthread_condattr_setclock'
collect2: error: ld returned 1 exit status
CMakeFiles/ipv6adhocclient.dir/build.make:104: recipe for target '../bin/ipv6adhocclient' failed
make[2]: *** [../bin/ipv6adhocclient] Error 1
make[2]: Leaving directory '/srv/maverick/software/libzt/build'
CMakeFiles/Makefile2:150: recipe for target 'CMakeFiles/ipv6adhocclient.dir/all' failed
make[1]: *** [CMakeFiles/ipv6adhocclient.dir/all] Error 2
make[1]: Leaving directory '/srv/maverick/software/libzt/build'
Makefile:86: recipe for target 'all' failed
make: *** [all] Error 2
Ubuntu 16.04
uname -a Linux www.maverick.one 4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.6' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.6)
I notice that the top-level Makefile does not seem to deal with Windows. Would be nice to fix this.
So one of the issues with libzt on Windows is that libzt.h
includes the Winsock headers, but the Windows structures for types like fd_set
and sockaddr_in
are incompatible with the lwIP structures. However, libzt just passes the pointer through to lwIP assuming the structure is the same, and this causes things to break in subtle ways.
It means we're currently having to do workarounds like this in order to actually use zts_*
functions:
https://github.com/HiveMP/ztserver/blob/semaphore-broken/forwardzt.cpp#L11-L31
https://github.com/HiveMP/ztserver/blob/semaphore-broken/forwardzt.cpp#L181 (this is a forced cast because the Winsock sockaddr_in6 and the lwIP sockaddr_in6 are colliding)
This impacts functions like zts_select
which use fd_set
and zts_recvfrom
which write the received address back into a sockaddr
pointer.
For example, this is the Windows (Winsock) definition of fd_set:
typedef struct fd_set {
u_int fd_count; /* how many are SET? */
SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
} fd_set;
And this is the lwIP definition of fd_set:
typedef struct fd_set
{
unsigned char fd_bits [(FD_SETSIZE+7)/8];
} fd_set;
This also impacts macros like FD_ZERO
, FD_SET
and FD_ISSET
which are defined differently as well.
This is the Windows (Winsock) definition of struct sockaddr_in6
(used in zts_recvfrom
):
typedef struct sockaddr_in6 {
ADDRESS_FAMILY sin6_family; // AF_INET6.
USHORT sin6_port; // Transport level port number.
ULONG sin6_flowinfo; // IPv6 flow information.
IN6_ADDR sin6_addr; // IPv6 address.
union {
ULONG sin6_scope_id; // Set of interfaces for a scope.
SCOPE_ID sin6_scope_struct;
};
} SOCKADDR_IN6_LH, *PSOCKADDR_IN6_LH, FAR *LPSOCKADDR_IN6_LH;
Yet this is the lwIP definition of struct sockaddr_in6
:
struct sockaddr_in6 {
u8_t sin6_len; /* length of this structure */
sa_family_t sin6_family; /* AF_INET6 */
in_port_t sin6_port; /* Transport layer port # */
u32_t sin6_flowinfo; /* IPv6 flow information */
struct in6_addr sin6_addr; /* IPv6 address */
u32_t sin6_scope_id; /* Set of interfaces for scope */
};
Even the definition of struct in6_addr
varies in terms of accessing the data between Windows:
typedef struct in6_addr {
union {
UCHAR Byte[16];
USHORT Word[8];
} u;
} IN6_ADDR, *PIN6_ADDR, FAR *LPIN6_ADDR;
and lwIP:
struct ip6_addr {
u32_t addr[4];
};
Anyway, you get the point. The difference in data structures causes everything to misbehave when data is being passed between the libzt APIs (using Winsock) and the underlying lwIP code.
I think the correct fix here is either:
This issue probably doesn't occur on Linux/Mac because the lwIP structures probably match what sys/socket.h
defines.
I downloaded libzt.dll and used FFI to load the library, but received the following logs:
0009:err:module:import_dll Library MSVCP140D.dll (which is needed by L"\\libzt-1.2.0r1-win10-x86-release.dll") not found
0009:err:module:import_dll Library VCRUNTIME140D.dll (which is needed by L"\\libzt-1.2.0r1-win10-x86-release.dll") not found
0009:err:module:import_dll Library ucrtbased.dll (which is needed by L"\\libzt-1.2.0r1-win10-x86-release.dll") not found
panic: Module not found.
After switching to MinSizeRel
in Visual Studio and build, the result is around 700KB and is successfully loaded.
EDIT: fix the link, x86 version was used.
/usr/bin/ld: obj/Capability.o: relocation R_X86_64_PC32 against symbol `_ZNK8ZeroTier10Capability9serializeILj5728EEEvRNS_6BufferIXT_EEEb' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:319: recipe for target 'shared_lib' failed
make: *** [shared_lib] Error 1
Debian 9 (Ubilinux 4) x86_64
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18)
A mismerge broke my earlier fixes, which means that compiling with PICO is now busted -- here's my fix:
Also, the changes now force you to define STACK_PICO=1 to compile, otherwise static_lib has no default stack option.
diff --git a/src/libzt.cpp b/src/libzt.cpp
index d97cd9a..01b59f2 100644
--- a/src/libzt.cpp
+++ b/src/libzt.cpp
@@ -1510,7 +1510,7 @@ namespace ZeroTier {
/****************************************************************************/
#if defined(STACK_PICO)
-int zts_get_pico_socket(int fd, struct pico_socket *s)
+int zts_get_pico_socket(int fd, struct pico_socket **s)
{
int err = 0;
if(!zt1Service) {
😎
Not sure how one goes about hooking a c library to javascript.
All the projects in my node_modules that use external c libraries use
https://github.com/nodejs/node-gyp
and there's this thing which may or may not help
https://github.com/charto/nbind
I'm going to give it a shot on the weekend and see how far I get.
I'm running 2 copies of the following program on the same machine:
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include "libzt.h"
int main(int argc, char **argv) {
const char kMsg[] = "SSH-2.0-t1server\n";
const int port = 22;
char buf[256];
struct sockaddr_in6 addr;
int fd, connfd, err;
#if 0
const int enable = 1;
#endif
const uint64_t nwid = 0x8056c2e21c000001ULL;
struct sockaddr_storage storaddr;
socklen_t addrlen;
(void)argc;
if (argv[1]) {
fprintf(stderr, "error: Usage: %s\n", argv[0]);
return 1;
}
#if 0
ip6 = argv[1];
addr.sin6_family = AF_INET6;
if (!inet_pton(AF_INET6, ip6, &addr.sin6_addr)) {
fprintf(stderr, "error converting IPv6 address: %s\n", ip6);
return 1;
}
addr.sin6_port = htons(port);
#endif
if (zts_startjoin("path", nwid)) { /* Earth */
fprintf(stderr, "error joining the network\n");
return 1;
}
printf(": joined\n");
fflush(stdout);
/* !! Why does it take >30 seconds (and more) s? */
printf("naddr=%d\n", zts_get_num_assigned_addresses(nwid));
if (0 != zts_get_address(nwid, &storaddr, AF_INET6)) {
fprintf(stderr, "error getting IPv6 address\n");
return 1;
}
if (!inet_ntop(AF_INET6, &((const struct sockaddr_in6*)&storaddr)->sin6_addr, buf, sizeof(buf))) {
fprintf(stderr, "error serializing IPv6 address\n");
return 1;
}
/* Usually starts with fd80: */
printf("SERVER_IPV6=%s\n", buf);
if ((fd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "error creating socket\n");
return 1;
}
#if 0
if (zts_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) != 0) {
/* !! error in setsockopt(SO_REUSEADDR): Protocol not available */
fprintf(stderr, "error in setsockopt(SO_REUSEADDR): %s\n", strerror(errno));
return 1;
}
#endif
memset(&addr, '\0', sizeof addr);
addr.sin6_family = AF_INET6;
addr.sin6_port = htons(port);
if (zts_bind(fd, (const struct sockaddr *)&addr, sizeof(addr)) != 0) {
fprintf(stderr, "error binding: %s\n", strerror(errno));
return 1;
}
if (zts_listen(fd, 16) != 0) { /* SOMAXCONN */
fprintf(stderr, "error in listen\n");
return 1;
}
printf(": listening\n");
fflush(stdout);
addrlen = sizeof(addr);
if ((connfd = zts_accept(fd, (struct sockaddr*)&addr, &addrlen))) {
fprintf(stderr, "error accepting connection\n");
return 1;
}
if ((err = zts_write(connfd, kMsg, sizeof(kMsg) - 1)) < 0) {
fprintf(stderr, "error reading from socket\n");
return 1;
}
if (err == 0) {
fprintf(stderr, "no data from remote host\n");
return 1;
}
if ((err = zts_close(connfd)) < 0) {
fprintf(stderr, "error closing socket\n");
return 1;
}
if ((err = zts_close(fd)) < 0) {
fprintf(stderr, "error closing server socket\n");
return 1;
}
zts_stop();
return 0;
}
The first instance joins the network successfully in a few seconds:
$ gcc -s -O2 -W -Wall -Werror -o t1server6 t1server6.c -Ilibzt/include libzt/bin/lib/libzt.a -lpthread -lstdc++
$ /t1server6
: joined
naddr=2
SERVER_IPV6=fd80:????:????:????:????:????:????:????
: listening
If I start another instance, it hangs for more than a minute (zts_join
never succeeds), even after I stop the first instance.
I'm running the two instances in different directories, thus they use a different path, thus they use different cryptographic identities.
Expected behavior: both instances connect successfully in a few seconds, they get different IP addresses, and they are able to talk to each other.
The expected behavior is similar to TCP sockets on 127.0.0.1.
I am building the libzt project in windows os(I have the full code eg lwip). I start a command from vs2017 ,then cd to libzt directroy, execute the dist.sh but there are some error .
1 CMake Error at CMakeLists.txt:518 (install):
install Library TARGETS given no DESTINATION!
I fix this error by deleting the related following rule at CMakeLists.txt:518
//the following rule looks like for dll
install (TARGETS ${DYNAMIC_LIB_NAME}
LIBRARY DESTINATION lib
)
2 then ,I rebuild libzt ,and get many errors ,and the error contains the following information
D:\share\libzt_f1\src\VirtualTap.cpp(82): error C2039: 'pipe': is not a member of 'global namespace'' [D:\share\libz
t_f1\WinBuild64\libzt_obj.vcxproj]
D:\share\libzt_f1\src\VirtualTap.cpp(82): error C3861: 'pipe': identifier not found [D:\share\libzt_f1\WinBuild64\lib
zt_obj.vcxproj]
D:\share\libzt_f1\src\VirtualTap.cpp(93): error C2039: 'write': is not a member of 'global namespace'' [D:\share\lib
zt_f1\WinBuild64\libzt_obj.vcxproj]
D:\share\libzt_f1\src\VirtualTap.cpp(93): error C3861: 'write': identifier not found [D:\share\libzt_f1\WinBuild64\li
bzt_obj.vcxproj]
D:\share\libzt_f1\src\VirtualTap.cpp(98): error C2039: 'close': is not a member of 'global namespace'' [D:\share\lib
zt_f1\WinBuild64\libzt_obj.vcxproj]
D:\share\libzt_f1\src\VirtualTap.cpp(98): error C3861: 'close': identifier not found [D:\share\libzt_f1\WinBuild64\li
bzt_obj.vcxproj]
D:\share\libzt_f1\src\VirtualTap.cpp(99): error C2039: 'close': is not a member of 'global namespace'' [D:\share\lib
zt_f1\WinBuild64\libzt_obj.vcxproj]
D:\share\libzt_f1\src\VirtualTap.cpp(99): error C3861: 'close': identifier not found [D:\share\libzt_f1\WinBuild64\li
bzt_obj.vcxproj]
as your know ,the pipe and write api are the linux apis. and the pipe is a simplex ,Ok .now how can I build the libzt for windows ?If can I get the .lib library without modifying any code or modiying less code?
Thank you!
I never receive any events other than ZTS_EVENT_STACK_UP and ZTS_EVENT_STACK_DOWN. I have tried from homebrew build and building it from source but nothing ever comes through. Am I missing something?
It seems that sometimes lwIP will report that there are too many files open on the system ENFILE
, but this seems to be only from lwIP's connection allocator and not a system-wide issue.
I suspect a maximum number of descriptors is being issued to a lwIP netconn
and they aren't being freed properly by free_socket()
.
My C is super rusty, but this doesn't seem right -
This makes a scratch buffer of length INET_ADDRSTRLEN
to pass to InetAddress::toString
:
Line 273 in 4f6908b
INET_ADDRSTRLEN
is 16, since an IPv4 address can be at most 15 characters.
But toString
also adds the "port" - which I think is the CIDR mask of the ZT network - onto the end of the string, which means it can be 3 bytes longer, e.g. "/24":
https://github.com/zerotier/ZeroTierOne/blob/ee4783e3fb975d73aabeaa433c346aea043908a9/node/InetAddress.cpp#L132
Unless I'm missing something, that'd be writing 18 bytes into a 16 byte buffer :(
We are using the ipv4server_udp
demo included in libzt
, and the ZeroTier One installed by curl | bash
. Both of them run inside an Ubuntu 18.04.1 VM, then we ping from the host and notice the performance difference.
The table attached is transformed from mtr --report
:
ZeroTier Library:
Loss% | Snt | Last | Avg | Best | Wrst | StDev |
---|---|---|---|---|---|---|
0.0% | 10 | 49.3 | 33.2 | 7.6 | 50.5 | 15.1 |
ZeroTier One:
Loss% | Snt | Last | Avg | Best | Wrst | StDev |
---|---|---|---|---|---|---|
0.0% | 10 | 1.1 | 0.7 | 0.4 | 1.1 | 0.2 |
I'm experiencing IPv6 TCP connection timeouts when connecting shortly after client and server have joined the ZeroTier network Earth. By expectation is that TCP connections succeed right after zerotier-one -q listnetwork
has indicated that the join was OK.
For the record, here are the terminal window dumps.
On the client:
$ telnet PUBLIC_IP_ADDRESS_OF_SERVER # Gets the SSH-2.0- in <0.3 seconds.
Trying PUBLIC_IP_ADDRESS_OF_SERVER...
Connected to PUBLIC_IP_ADDRESS_OF_SERVER.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u3
^C
Connection closed by foreign host.
On the server:
$ telnet 127.0.0.1 22
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u3
^C
Connection closed by foreign host.
$ zerotier-one -q join 8056c2e21c000001
200 join OK
$ while ! zerotier-one -q listnetworks |
grep -q ' earth[.]zerotier[.]net .* OK PUBLIC '; do echo .; sleep 1; done
.
.
.
.
$ zerotier-one -q listnetworks | grep ' earth[.]zerotier[.]net .* OK PUBLIC '
200 listnetworks 8056c2e21c000001 earth.zerotier.net ??:??:??:??:??:?? OK PUBLIC ztmjfmfyq5 fd80:????:????:????:????:????:????:????/88,28.???.???.???/7
On the client:
$ zerotier-one -q join 8056c2e21c000001
200 join OK
$ while ! zerotier-one -q listnetworks |
grep -q ' earth[.]zerotier[.]net .* OK PUBLIC '; do echo .; sleep 1; done
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
$ telnet fd80:????:????:????:????:????:????:???? 22 # Takes about 10 seconds to time out.
Trying fd80:????:????:????:????:????:????:????...
telnet: Unable to connect to remote host: Connection timed out
$ telnet fd80:????:????:????:????:????:????:???? 22
Trying fd80:????:????:????:????:????:????:????...
Connected to fd80:????:????:????:????:????:????:????.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u3
The bug is indicated by the telnet: Unable to connect to remote host: Connection timed out
line. By this time this connection should succeed, because both the client and the server have joined the ZeroTier network Earth with status OK PUBLIC
.
This is also happening if the client is using libzt to connect to the ZeroTier network Earth, and the server has been connected for >10 minutes (see the details in #31 (comment)):
$ ./a.out
error connecting to remote host: -1 Software caused connection abort
Hi! Finally found some time to try out the SDK 😁 I get this while trying to build on linux:
libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl
SDK_Sockets.c: In function ‘zts_recvfrom’:
SDK_Sockets.c:290:41: warning: passing argument 3 of ‘memcpy’ makes integer from pointer without a cast
memcpy(address, buffer, address_len);
^
In file included from /usr/include/features.h:364:0,
from /usr/include/unistd.h:25,
from SDK_Sockets.c:37:
/usr/include/x86_64-linux-gnu/bits/string3.h:50:1: note: expected ‘size_t’ but argument is of type ‘socklen_t *’
__NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
^
SDK_Sockets.c: In function ‘zts_accept4’:
SDK_Sockets.c:613:23: warning: initialization makes integer from pointer without a cast
int len = !addr ? 0 : addrlen;
^
SDK_Sockets.c:614:41: warning: passing argument 3 of ‘accept’ makes pointer from integer without a cast
return accept(sockfd, addr, len);
^
In file included from /usr/include/netinet/in.h:23:0,
from /usr/include/netdb.h:27,
from SDK_Sockets.c:45:
/usr/include/x86_64-linux-gnu/sys/socket.h:243:12: note: expected ‘socklen_t *’ but argument is of type ‘int’
extern int accept (int __fd, __SOCKADDR_ARG __addr,
^
SDK_Sockets.c: In function ‘zts_getsockname’:
SDK_Sockets.c:768:17: warning: assignment makes pointer from integer without a cast
addrlen = sizeof(struct sockaddr_in);
^
SDK_Sockets.c: In function ‘zts_getpeername’:
SDK_Sockets.c:831:17: warning: assignment makes pointer from integer without a cast
addrlen = sizeof(struct sockaddr_in);
^
SDK_Sockets.c: In function ‘zts_recvfrom’:
SDK_Sockets.c:296:13: warning: ‘tmpsz’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return tmpsz;
^
SDK_Intercept.c: In function ‘setsockopt’:
SDK_Intercept.c:236:50: error: ‘option_name’ undeclared (first use in this function)
return realsetsockopt(socket, level, option_name, option_value, option_len);
^
SDK_Intercept.c:236:50: note: each undeclared identifier is reported only once for each function it appears in
SDK_Intercept.c:236:63: error: ‘option_value’ undeclared (first use in this function)
return realsetsockopt(socket, level, option_name, option_value, option_len);
^
SDK_Intercept.c:236:77: error: ‘option_len’ undeclared (first use in this function)
return realsetsockopt(socket, level, option_name, option_value, option_len);
^
SDK_Intercept.c:248:5: warning: control reaches end of non-void function [-Wreturn-type]
}
^
SDK_RPC.c: In function ‘sock_fd_write’:
SDK_RPC.c:289:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*((int *) CMSG_DATA(cmsg)) = fd;
^
SDK_RPC.c: In function ‘sock_fd_read’:
SDK_RPC.c:337:7: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
*fd = *((int *) CMSG_DATA(cmsg));
^
make-linux.mk:83: recipe for target 'linux_shared_lib' failed
make: *** [linux_shared_lib] Error 1
Am I missing some buildflags or something? I'm on Ubuntu 15.04
with gcc 4.9.2
.
https://github.com/zerotier/libzt/blob/master/BUILDING.md says to run `make static_lib', but that doesn't work:
make: *** No rule to make target 'static_lib'. Stop.
Could you please update the instructions?
I'd like to use the gcc optimization flag -Os
. Where can I specify it?
Hello,I'm using libzt demo on Windows10.I found that if there is no my own moon, the delay of tow devices is so high that I think If there is an operation like "orbit" in Zerotier-cli of Linux,it will have a better performance. And I had read the document for serval times.But I still no found it.If there was ,could you guide me where is it?Thank you!
I tried compiling the library to android, C/CPP without a problem, but android part - failes all of times. I already used one week to try to compile the aar file, and it is still failing.
Issues from start
finding all of this, downloading proper sdk and ndk (trying almost every combination) still fails.
Would it be possible to get library we will be able to compile properly on modern java and systems? Please
Hi, is there a simple config or command-line option which will allow cross-compiling (the entire project) from an x86_64 linux host for an ARM64 linux target? Thanks.
The Readme currently points to:
https://download.zerotier.com/RELEASES/1.2.12/dist/libzt/win/libzt-1.2.0r1-win10-x64-release.dll
All other links work fine.
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: controller/EmbeddedNetworkController.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file controller/EmbeddedNetworkController.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: controller/JSONDB.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file controller/JSONDB.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/C25519.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/C25519.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Capability.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Capability.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/CertificateOfMembership.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/CertificateOfMembership.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/CertificateOfOwnership.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/CertificateOfOwnership.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Cluster.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Cluster.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Identity.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Identity.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/IncomingPacket.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/IncomingPacket.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/InetAddress.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/InetAddress.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Membership.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Membership.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Multicaster.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Multicaster.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Network.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Network.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/NetworkConfig.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/NetworkConfig.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Node.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Node.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/OutboundMulticast.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/OutboundMulticast.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Packet.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Packet.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Path.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Path.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Peer.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Peer.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Poly1305.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Poly1305.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Revocation.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Revocation.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Salsa20.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Salsa20.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/SelfAwareness.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/SelfAwareness.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/SHA512.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/SHA512.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Switch.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Switch.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Tag.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Tag.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Topology.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Topology.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: node/Utils.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file node/Utils.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: osdep/ManagedRoute.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file osdep/ManagedRoute.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: osdep/Http.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file osdep/Http.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: osdep/OSUtils.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file osdep/OSUtils.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: service/ClusterGeoIpService.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file service/ClusterGeoIpService.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: service/SoftwareUpdater.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file service/SoftwareUpdater.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/http-parser/http_parser.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/http-parser/http_parser.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: osdep/PortMapper.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file osdep/PortMapper.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/connecthostport.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/connecthostport.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/igd_desc_parse.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/igd_desc_parse.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/minisoap.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/minisoap.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/minissdpc.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/minissdpc.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/miniupnpc.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/miniupnpc.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/miniwget.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/miniwget.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/minixml.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/minixml.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/portlistingparse.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/portlistingparse.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/receivedata.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/receivedata.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/upnpcommands.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/upnpcommands.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/upnpdev.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/upnpdev.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/upnperrors.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/upnperrors.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/miniupnpc/upnpreplyparse.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/miniupnpc/upnpreplyparse.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/libnatpmp/natpmp.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/libnatpmp/natpmp.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: ext/libnatpmp/getgateway.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file ext/libnatpmp/getgateway.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: service/OneService.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file service/OneService.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: one.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file one.o
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: error: osdep/LinuxEthernetTap.o uses VFP register arguments, zerotier-one does not
/mmc/lib/gcc/arm-buildroot-linux-uclibcgnueabi/6.1.0/../../../../arm-buildroot-linux-uclibcgnueabi/bin/ld: failed to merge target specific data of file osdep/LinuxEthernetTap.o
collect2: error: ld returned 1 exit status
make: *** [make-linux.mk:134: one] Error 1
Hey there again. I have created a start of my own libzt interop sample here:
https://github.com/bbatchelder/libzt-interop
Right now it demos how to write a simple single-threaded server. I'd love any feedback you have in general. I have not done socket programming in quite a while. Next up is a multi-threaded example.
Anyways, my understanding is that without setting O_NONBLOCK on the main listening socket, there is a potential race condition where a client connects but drops before the accept() runs.
You can see around line 64 I try calling zts_fcntl() to set O_NONBLOCK, but it fails.
https://github.com/bbatchelder/libzt-interop/blob/master/libzt.Interop.DemoServer/Program.cs#L64
I am getting the value 0 for F_SETFL and 0 for O_NONBLOCK from the libzt.h header (line 475). It seems those are being defined there and overriding what would be the normal lwip values.
https://github.com/zerotier/libzt/blob/master/include/libzt.h#L475
I also see in libzt.cpp you're doing some translation of flags anyways...and I can't say I quite understand the logic there...its either going to be 0 or on Apple or Linux maybe a 1.
https://github.com/zerotier/libzt/blob/master/src/libzt.cpp#L155
Anyways, any help would be greatly appreciated!
Do you plan on adding a pure Java integration? Java is already in use with with Android and ZeroTierSynology... I haven't looked at the latter, but %-wise it's a substantial amount of Java code.
Ideally, I'd like a Clojure library. I guess that's too far-fetched to ask for at this point in time...
I'm trying to use libzt (at this commit: 5ec7d5b) to connect to a TCP port on an IPv4 and IPv6 peer, but the connect never succeeds.
To make sure that it's not a network connectivity issue, I'm able to use zerotier-cli to join the ad-hoc SSH network:
$ zerotier-cli join ff00160016000000
200 join OK
Then connecting works:
$ gcc -s -O2 -W -Wall -Wextra t1nativex.c
$ ./a.out
SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u3
However, when I'm doing it with libzt, it doesn't work:
$ g++ -s -O2 -W -Wall -Wextra t1x.c -l... -lpthread
$ ./a.out
...
STACK[32465]: sys_arch.c: 270: sys_mbox_post: sys_mbox_post: mbox 0x7f80a4000a80 msg 0x7ffc588b0010
STACK[32469]: sys_arch.c: 361: sys_arch_mbox_fetch: sys_mbox_fetch: mbox 0x7f80a4000a80 msg 0x7f80a4000a20
error connecting to remote host: -1 No route to host
Am I doing something wrong? How can I fix it in t1x.c?
Source file t1nativex.c (finishes successfully and quickly after zerotier-one -q join ff00160016000000
) with part of the IP address redacted:
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
int main() {
const char *ip6 = "fce9:0016:00??:????:????:0000:0000:0001";
int port = 22;
char buf[256];
struct sockaddr_in6 addr;
int fd, err = 0;
addr.sin6_family = AF_INET6;
if (!inet_pton(AF_INET6, ip6, &(addr.sin6_addr))) {
fprintf(stderr, "error converting address\n");
return 1;
}
addr.sin6_port = htons(port);
if ((fd = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
fprintf(stderr, "error creating socket\n");
return 1;
}
if ((err = connect(fd, (const struct sockaddr *)&addr, sizeof(addr))) < 0) {
fprintf(stderr, "error connecting to remote host: %d (%s)\n", err, strerror(errno));
return 1;
}
if ((err = read(fd, buf, sizeof(buf))) < 0) {
fprintf(stderr, "error reading from socket\n");
return 1;
}
write(1, buf, err);
if ((err = close(fd)) < 0) {
fprintf(stderr, "error closing socket\n");
return 1;
}
return 0;
}
Source file t1x.c (IPv6 over ZeroTier, zts_connect fails) with part of the IP address redacted:
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/socket.h>
#include "libzt.h"
int main() {
const char *ip6 = "fce9:0016:00??:????:????:0000:0000:0001";
int port = 22;
char buf[256];
struct sockaddr_in6 addr;
int fd, err = 0;
addr.sin6_family = AF_INET6;
if (!inet_pton(AF_INET6, ip6, &(addr.sin6_addr))) {
printf("error converting address\n");
return 1;
}
addr.sin6_port = htons(port);
if (zts_startjoin("path", 0xff00160016000000ULL)) {
printf("error joining the network\n");
return 1;
}
if ((fd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
printf("error creating socket\n");
return 1;
}
if ((err = zts_connect(fd, (const struct sockaddr *)&addr, sizeof(addr))) < 0) {
/* No route to host -- is it a real error message? */
printf("error connecting to remote host: %d %s\n", err, strerror(errno));
return 1;
}
if ((err = zts_read(fd, buf, sizeof(buf))) < 0) {
fprintf(stderr, "error reading from socket\n");
return 1;
}
write(1, buf, err);
if ((err = zts_close(fd)) < 0) {
printf("error closing socket\n");
return 1;
}
zts_stop();
return 0;
}
Source file t4x.c (IPv4 over ZeroTier, zts_connect doesn't return for several minutes) with part of the IP address redacted:
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/socket.h>
#include "libzt.h"
int main() {
const char *ip = "172.25.???.???";
int port = 22;
char buf[256];
struct sockaddr_in addr;
int fd, err = 0;
addr.sin_family = AF_INET;
if (!inet_pton(AF_INET, ip, &(addr.sin_addr))) {
printf("error converting address\n");
return 1;
}
addr.sin_port = htons(port);
if (zts_startjoin("path", 0x??????ULL)) {
printf("error joining the network\n");
return 1;
}
if ((fd = zts_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("error creating socket\n");
return 1;
}
if ((err = zts_connect(fd, (const struct sockaddr *)&addr, sizeof(addr))) < 0) {
/* No route to host -- is it a real error message? */
printf("error connecting to remote host: %d %s\n", err, strerror(errno));
return 1;
}
if ((err = zts_read(fd, buf, sizeof(buf))) < 0) {
fprintf(stderr, "error reading from socket\n");
return 1;
}
write(1, buf, err);
if ((err = zts_close(fd)) < 0) {
printf("error closing socket\n");
return 1;
}
zts_stop();
return 0;
}
This command works, with part of the IP address redacted:
$ telnet 172.25.???.??? 22
Trying 172.25.???.???...
Connected to 172.25.???.???.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u3
^C
Connection closed by foreign host.
At first the when make ios_app_framework,it not works,about 20 compile error.
I add #define ZT_SDK and change some code
Now there is no complie errors.
But some Link command error happend.
Undefined symbols for architecture arm64:
"ZeroTier::Membership::Membership()", referenced from:
ZeroTier::Hashtable<ZeroTier::Address, ZeroTier::Membership>::_Bucket::_Bucket(ZeroTier::Address const&) in Network.o
"ZeroTier::CertificateOfOwnership::_owns(ZeroTier::CertificateOfOwnership::Thing const&, void const*, unsigned int) const", referenced from:
ZeroTier::CertificateOfOwnership::owns(ZeroTier::InetAddress const&) const in Network.o
ZeroTier::CertificateOfOwnership::owns(ZeroTier::MAC const&) const in Network.o
"ZeroTier::Membership::addCredential(ZeroTier::RuntimeEnvironment const*, ZeroTier::NetworkConfig const&, ZeroTier::Revocation const&)", referenced from:
ZeroTier::Network::addCredential(ZeroTier::Address const&, ZeroTier::Revocation const&) in Network.o
"ZeroTier::Membership::addCredential(ZeroTier::RuntimeEnvironment const*, ZeroTier::NetworkConfig const&, ZeroTier::CertificateOfMembership const&)", referenced from:
ZeroTier::Network::addCredential(ZeroTier::CertificateOfMembership const&) in Network.o
"ZeroTier::Membership::getTag(ZeroTier::NetworkConfig const&, unsigned int) const", referenced from:
ZeroTier::(anonymous namespace)::_doZtFilter(ZeroTier::RuntimeEnvironment const*, ZeroTier::NetworkConfig const&, ZeroTier::Membership const*, bool, ZeroTier::Address const&, ZeroTier::Address&, ZeroTier::MAC const&, ZeroTier::MAC const&, unsigned char const*, unsigned int, unsigned int, unsigned int, ZT_VirtualNetworkRule const*, unsigned int, ZeroTier::Address&, unsigned int&, bool&) in Network.o
"ZeroTier::Membership::addCredential(ZeroTier::RuntimeEnvironment const*, ZeroTier::NetworkConfig const&, ZeroTier::CertificateOfOwnership const&)", referenced from:
ZeroTier::Network::addCredential(ZeroTier::CertificateOfOwnership const&) in IncomingPacket.o
"ZeroTier::Membership::addCredential(ZeroTier::RuntimeEnvironment const*, ZeroTier::NetworkConfig const&, ZeroTier::Capability const&)", referenced from:
ZeroTier::Network::addCredential(ZeroTier::Capability const&) in IncomingPacket.o
"ZeroTier::Membership::pushCredentials(ZeroTier::RuntimeEnvironment const*, unsigned long long, ZeroTier::Address const&, ZeroTier::NetworkConfig const&, int, bool)", referenced from:
ZeroTier::Network::pushCredentialsNow(ZeroTier::Address const&, unsigned long long) in IncomingPacket.o
ZeroTier::Network::filterOutgoingPacket(bool, ZeroTier::Address const&, ZeroTier::Address const&, ZeroTier::MAC const&, ZeroTier::MAC const&, unsigned char const*, unsigned int, unsigned int, unsigned int) in Network.o
ZeroTier::Network::filterIncomingPacket(ZeroTier::SharedPtrZeroTier::Peer const&, ZeroTier::Address const&, ZeroTier::MAC const&, ZeroTier::MAC const&, unsigned char const*, unsigned int, unsigned int, unsigned int) in Network.o
ZeroTier::Network::_sendUpdatesToMembers(ZeroTier::MulticastGroup const*) in Network.o
ZeroTier::Network::gate(ZeroTier::SharedPtrZeroTier::Peer const&) in Network.o
ZeroTier::Network::addCredential(ZeroTier::CertificateOfMembership const&) in Network.o
"ZeroTier::EmbeddedNetworkController::handleControlPlaneHttpPOST(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::handleControlPlaneHttpRequest(ZeroTier::InetAddress const&, unsigned int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&) in OneService.o
"ZeroTier::EmbeddedNetworkController::handleControlPlaneHttpGET(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::handleControlPlaneHttpRequest(ZeroTier::InetAddress const&, unsigned int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&) in OneService.o
"ZeroTier::Membership::addCredential(ZeroTier::RuntimeEnvironment const*, ZeroTier::NetworkConfig const&, ZeroTier::Tag const&)", referenced from:
ZeroTier::Network::addCredential(ZeroTier::Tag const&) in IncomingPacket.o
"ZeroTier::SoftwareUpdater::handleSoftwareUpdateUserMessage(unsigned long long, void const*, unsigned int)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::nodeEventCallback(ZT_Event, void const*) in OneService.o
"ZeroTier::SoftwareUpdater::check(unsigned long long)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::run() in OneService.o
"ZeroTier::EmbeddedNetworkController::handleControlPlaneHttpDELETE(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::handleControlPlaneHttpRequest(ZeroTier::InetAddress const&, unsigned int, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >&) in OneService.o
"ZeroTier::EmbeddedNetworkController::EmbeddedNetworkController(ZeroTier::Node*, char const*)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::run() in OneService.o
"ZeroTier::SoftwareUpdater::apply()", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::run() in OneService.o
"ZeroTier::(anonymous namespace)::StapFrameHandler2(void*, void*, unsigned long long, ZeroTier::MAC const&, ZeroTier::MAC const&, unsigned int, unsigned int, void const*, unsigned int)", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::nodeVirtualNetworkConfigFunction(unsigned long long, void**, ZT_VirtualNetworkConfigOperation, ZT_VirtualNetworkConfig const*) in OneService.o
"ZeroTier::SoftwareUpdater::~SoftwareUpdater()", referenced from:
ZeroTier::(anonymous namespace)::OneServiceImpl::run() in OneService.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
environment:
Xcode Version 8.3.2 (8E2002)
macOS:10.12
git tag:ixia-1.9
error /miniupnpc/version:1:1: error: expected unqualified-id
I went to build a C# project using the previous C# code that was up here and noticed it's all been removed, was that by accident, or was it removed for a reason? Will the previous code still work with the current library?
I created a little C program to test embedding zerotier via libzt.
Judging from the output of the callback things seem to work partially. However I can't get the socket layer to work at all.
I tried to set up a mostly copying code from the examples/cpp/ipv6adhoc
. Initially it failed with a segmentation fault. To get around that one I modified src/lwipDriver.cpp
like this:
@@ -459,6 +459,8 @@ void lwip_init_interface(void *tapref, const MAC &mac, const InetAddress &ip)
static ip6_addr_t ipaddr;
memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
n->ip6_autoconfig_enabled = 1;
+ n->state = tapref; ((VirtualTap*)tapref)->netif = n;
+ netif_add(n, NULL, NULL, NULL, tapref, netif_init, tcpip_input);
LOCK_TCPIP_CORE();
netif_ip6_addr_set(n, 1, &ipaddr);
@@ -478,4 +480,4 @@ void lwip_init_interface(void *tapref, const MAC &mac, const InetAddress &ip)
}
}
-} // namespace ZeroTier
\ No newline at end of file
+} // namespace ZeroTier
With this modification my test program starts up, reports IP address added etc. and finally some ZTS_EVENT_PEER_P2P
and ZTS_EVENT_PEER_RELAY
. Among the latter there are some node ids which belong to (Linux) machines running regular zerotier-one (on the same host or another in the same LAN).
However:
zts_connect
fails for:Moreover I wonder: the regular instance does list the libzt based node identifiers (after a while) an keeps a record in peers.d
. But attempts to ping the libzt nodes fail. Is this to be expected?
How would I debug this situation?
Here is the code:
/*
libzt: # build libzt elsewhere
cd $(HOME)/build/libzt && cmake --build tmp/linux-x86_64-linux-gnu-debug/ && cp tmp/linux-x86_64-linux-gnu-debug/lib/libztcore.a tmp/linux-x86_64-linux-gnu-debug/lib/libzt.a ~/.cache/lambdanative/linux/lib
zttest: libzt ~/.cache/lambdanative/linux/lib/libzt.a
zttest: unix/ssl/ztservice.c
$(CC) $(CFLAGS) -I /home/u/.cache/lambdanative/linux/include -L /home/u/.cache/lambdanative/linux/lib -DUSE_OPENSSL -Wall $< -lssl -lcrypto -lzt -lstdc++ -lm -pthread -o $@
modified src/lwipDriver.cpp
@@ -459,6 +459,8 @@ void lwip_init_interface(void *tapref, const MAC &mac, const InetAddress &ip)
static ip6_addr_t ipaddr;
memcpy(&(ipaddr.addr), ip.rawIpData(), sizeof(ipaddr.addr));
n->ip6_autoconfig_enabled = 1;
+ n->state = tapref; ((VirtualTap*)tapref)->netif = n;
+ netif_add(n, NULL, NULL, NULL, tapref, netif_init, tcpip_input);
LOCK_TCPIP_CORE();
netif_ip6_addr_set(n, 1, &ipaddr);
@@ -478,4 +480,4 @@ void lwip_init_interface(void *tapref, const MAC &mac, const InetAddress &ip)
}
}
-} // namespace ZeroTier
\ No newline at end of file
+} // namespace ZeroTier
modified src/api/sockets.c
@@ -1701,7 +1710,7 @@ lwip_socket(int domain, int type, int protocol)
((protocol == IPPROTO_UDPLITE) ? NETCONN_UDPLITE : NETCONN_UDP)),
DEFAULT_SOCKET_EVENTCB);
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ",
- domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
+ domain == PF_INET ? "PF_INET" : domain == PF_INET6 ? "PF_INET6" : "UNKNOWN", protocol));
#if LWIP_NETBUF_RECVINFO
if (conn) {
/* netconn layer enables pktinfo by default, sockets default to off * /
@@ -1712,7 +1721,7 @@ lwip_socket(int domain, int type, int protocol)
case SOCK_STREAM:
conn = netconn_new_with_callback(DOMAIN_TO_NETCONN_TYPE(domain, NETCONN_TCP), DEFAULT_SOCKET_EVENTCB);
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ",
- domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
+ domain == PF_INET ? "PF_INET" : domain == PF_INET6 ? "PF_INET6" : "UNKNOWN", protocol));
break;
default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n",
*/
#include <stdio.h>
#include <string.h>
#if defined(_WIN32)
#include <WinSock2.h>
#include <stdint.h>
#else
#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
typedef enum {false=0, true=1} bool;
#include <ZeroTier.h>
#include <stdlib.h>
uint64_t generate_adhoc_nwid_from_port(int port)
{
// We will join ad-hoc network ffSSSSEEEE000000
// Where SSSS = start port
// EEEE = end port
uint64_t r = 0xff00000000000000, s, e;
s=(uint16_t)port;
e=(uint16_t)port;
return r | (s << 40) | (e << 24);
}
void set_6plane_addr(struct zts_sockaddr_in6 *sin6, uint64_t nwid, uint64_t zeroTierAddress, uint16_t port)
{
nwid ^= (nwid >> 32);
struct in6_addr *buf=&sin6->sin6_addr;
//memset(buf, 0, sizeof(struct in6_addr));
buf->s6_addr[0] = 0xfc;
buf->s6_addr[1] = (uint8_t)(0xff&(nwid >> 24));
buf->s6_addr[2] = (uint8_t)(0xff&(nwid >> 16));
buf->s6_addr[3] = (uint8_t)(0xff&(nwid >> 8));
buf->s6_addr[4] = (uint8_t)(0xff&nwid);
buf->s6_addr[5] = (uint8_t)(0xff&(zeroTierAddress >> 32));
buf->s6_addr[6] = (uint8_t)(0xff&(zeroTierAddress >> 24));
buf->s6_addr[7] = (uint8_t)(0xff&(zeroTierAddress >> 16));
buf->s6_addr[8] = (uint8_t)(0xff&(zeroTierAddress >> 8));
buf->s6_addr[9] = (uint8_t)(0xff&zeroTierAddress);
buf->s6_addr[10] = 0;
buf->s6_addr[11] = 0;
buf->s6_addr[12] = 0;
buf->s6_addr[13] = 0;
buf->s6_addr[14] = 0;
buf->s6_addr[15] = 0x01;
sin6->sin6_len = sizeof(struct zts_sockaddr_in6);
sin6->sin6_family = AF_INET6;
sin6->sin6_port = htons(port);
/*
{ int i;
printf("Addr: ");
for(i=0;i<14;i+=2) {
printf("%02x%02x:", buf->s6_addr[i], buf->s6_addr[i+1]);
}
printf("%02x%02x\n", buf->s6_addr[i], buf->s6_addr[i+1]);
}
//*/
}
bool node_ready = false;
bool network_ready = false;
int fprint_ztipaddr(FILE* s, struct zts_sockaddr_in6* zt_ip);
void myZeroTierEventCallback(struct zts_callback_msg *msg)
{
switch (msg->eventCode)
{
case ZTS_EVENT_NODE_ONLINE:
printf("ZTS_EVENT_NODE_ONLINE, nodeId=%lx\n", msg->node->address);
node_ready = true;
break;
case ZTS_EVENT_NODE_OFFLINE:
printf("ZTS_EVENT_NODE_OFFLINE\n");
node_ready = false;
break;
case ZTS_EVENT_NETWORK_READY_IP4:
printf("ZTS_EVENT_NETWORK_READY_IP4, networkId=%lx\n", msg->network->nwid);
network_ready = true;
break;
case ZTS_EVENT_NETWORK_READY_IP6:
// msg->network->num_addresses ist meaningless (uninitialized)
printf("ZTS_EVENT_NETWORK_READY_IP6, networkId=%lx\n", msg->network->nwid);
network_ready = true;
break;
case ZTS_EVENT_ADDR_ADDED_IP6:
// printf("ZTS_EVENT_ADDR_ADDED_IP6, networkId=%lx addr=%lx\n", msg->addr->nwid, msg->addr->addr);
printf("ZTS_EVENT_ADDR_ADDED_IP6, networkId=%lx IPv6: ", msg->addr->nwid);
fprint_ztipaddr(stdout, &msg->addr->addr);
printf("\n");
// network_ready = true;
break;
case ZTS_EVENT_NETWORK_OK:
printf("ZTS_EVENT_NETWORK_OK, networkId=%lx nAddr=%d\n", msg->network->nwid, msg->network->num_addresses);
break;
case ZTS_EVENT_PEER_P2P:
printf("ZTS_EVENT_PEER_P2P, nodeId=%lx\n", msg->peer->address);
break;
case ZTS_EVENT_PEER_RELAY:
printf("ZTS_EVENT_PEER_RELAY, nodeId=%lx\n", msg->peer->address);
break;
case ZTS_EVENT_NODE_DOWN:
printf("ZTS_EVENT_NODE_DOWN, nodeId=%lx\n", msg->peer->address);
exit(1);
break;
default:
printf("eventCode: %d\n", msg->eventCode);
break;
}
}
int fprint_ztipaddr(FILE* s, struct zts_sockaddr_in6* zt_ip)
{
char addr_buffer[46];
struct sockaddr_in6 p;
p.sin6_family = AF_INET6;
p.sin6_port = zt_ip->sin6_port;
memcpy(&p.sin6_addr, &zt_ip->sin6_addr, sizeof(struct in6_addr));
getnameinfo((struct sockaddr *)&p, sizeof(struct sockaddr_in6), addr_buffer, sizeof(addr_buffer), 0, 0, NI_NUMERICHOST);
return fprintf(s, "%s", addr_buffer);
}
int unbarf(int rc, char *msg) {
fprintf(stderr, "%s\n", msg);
return rc;
}
int barf(int rc, char *msg) {
fprintf(stderr, "%s\n", msg);
exit(rc);
}
int test_service_create(int port)
{
int sockfd, rc;
struct zts_sockaddr_in6 in6;
in6.sin6_len = sizeof(in6);
in6.sin6_port = htons(port);
in6.sin6_family = AF_INET6;
memcpy(&in6.sin6_addr, &in6addr_any, sizeof(struct zts_in6_addr));
if ((sockfd = zts_socket(ZTS_PF_INET6, SOCK_STREAM, 0)) < 0) {
printf("error creating ZeroTier socket\n");
}
printf("AF_INET6: %d, in6fam: %d %p\n", AF_INET6, ((struct zts_sockaddr *)&in6)->sa_family, &in6 );
if ((rc = zts_bind(sockfd, (struct sockaddr *)&in6, sizeof(in6)) < 0)) {
printf("error binding to interface (%d) fam: %d off %d\n", rc, ((struct zts_sockaddr *)&in6)->sa_family, (int) (((char *) &(((struct zts_sockaddr *)&in6)->sa_family)) - (char *)&in6) );
}
if ((rc = zts_listen(sockfd, 100)) < 0) {
printf("error placing socket in LISTENING state (%d)\n", rc);
}
return sockfd;
}
void* test_service (void *arg)
{
int sockfd, connfd, rc;
sockfd = *(int *)arg;
struct zts_sockaddr_in6 acc_in6;
socklen_t client_addrlen = sizeof(struct sockaddr_in6);
if ((connfd = zts_accept(sockfd, (struct sockaddr *)&acc_in6, &client_addrlen)) < 0) {
printf("error accepting connection (%d)\n", connfd);
}
{
zts_getpeername(connfd, (struct sockaddr*)&acc_in6, &client_addrlen);}
printf("accepted connection from ");
fprint_ztipaddr(stdout, &acc_in6);
printf(" : %d", ntohs(acc_in6.sin6_port));
{ char buf[100];
printf("reading from client...\n");
rc = zts_read(connfd, buf, sizeof buf);
printf("sending to client...\n");
rc = zts_write(connfd, buf, strlen(buf));
printf("Received : %s\n", buf);
}
rc = zts_close(sockfd);
rc = zts_close(connfd);
return (void *) rc;
}
#include <errno.h>
int test_client(struct zts_sockaddr_in6 *remote_addr)
{
char *msg = (char*)"welcome to the machine";
int r=0, w=0, err=0, sockfd;
char rbuf[32];
memset(rbuf, 0, sizeof rbuf);
if ((sockfd = zts_socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
printf("error creating ZeroTier socket\n");
}
if ((err = zts_connect(sockfd, (const struct sockaddr *)remote_addr, sizeof(struct zts_sockaddr_in6))) < 0) {
printf("error connecting to remote host: %s\n", strerror(errno));
return unbarf(err, "error connecting to remote host\n");
} else {
printf("sending to server...\n");
w = zts_write(sockfd, msg, strlen(msg));
printf("reading from server...\n");
r = zts_read(sockfd, rbuf, strlen(msg));
}
printf("Sent : %s\n", msg);
printf("Received : %s\n", rbuf);
err = zts_close(sockfd);
return err;
}
#include <pthread.h>
int main(int argc, char **argv)
{
int port = 7443, rc;
uint64_t nodeid, nwid = generate_adhoc_nwid_from_port(port);
struct zts_sockaddr_in6 myip;
int is_client = argc > 1;
char *cred = is_client ? "zerotier-client" : "zerotier-server";
int zt_port = 0 ? 9993 : is_client ? 9995 : 9994;
printf("Waiting for libzt using '%s' to come online...\n", cred);
if(zts_start(cred, &myZeroTierEventCallback, zt_port)) barf(1, "zts_start");
while (!node_ready) { sleep(1); }
printf("Joining nwid=%llx\n", (unsigned long long)nwid);
if(zts_join(nwid)) barf(2, "zts_join");
printf("Joined virtual network. Requesting configuration...");
while (!network_ready) { sleep(1); }
printf("done\n");
nodeid = zts_get_node_id();
set_6plane_addr(&myip, nwid, nodeid, port);
printf("I am %llx at ", (unsigned long long)nodeid);
fprint_ztipaddr(stdout, &myip);
printf(" port %d\n", ntohs(myip.sin6_port));
if(!is_client) {
pthread_t kt;
int sockfd = test_service_create(7443);
// rc = pthread_create(&kt, NULL, test_service, &sockfd);
return (int)test_service(&sockfd);
} else {
uint64_t srvid;
struct zts_sockaddr_in6 srvip;
sscanf(argv[1], "%llx", &srvid);
set_6plane_addr(&srvip, nwid, srvid, port);
{ int i, r=0;
int success=0, failed=0;
for(i=0; i<2000; ++i) {
int status, j=0;
do {
/* This do-loop came here just to try. May safely be removed. */
status = zts_get_peer_status(srvid);
printf("Status of %llx : %d\n", srvid, status);
if(status==98) sleep(10);
} while(status==98 && ++j<50);
printf("Connecting [%d/%d] to %llx at ", success, failed, (unsigned long long)srvid);
fprint_ztipaddr(stdout, &srvip);
printf(" port %d\n", ntohs(srvip.sin6_port));
if(test_client(&srvip)==0) success++; else failed++;
}
return r;
}
}
return 0;
}
So given the current code found in the DemoServer, it all works great if I am using netcat from a few different windows and even devices, typing in messages manually. Everything seems rather stable and it properly handles clients joining and leaving.
So as a sort of stress test I downloaded a book from Project Gutenberg in text format, and sent the whole file over. Sadly at some point it ends up crashing with a System.ExecutionEngineException.
I edited the book down so it was an even 100k, and it crashes in the exact same spot every time on the 5th send...and after adding a received data counter, its crashing at the exact same # of bytes received - 485320.
That seems awfully weird. Again, any ideas for debugging this would be greatly appreciated!
Thanks for the library :)
I'm hoping to one day do the following inside my projects:
pip3.6 install zerotier
Followed by...
import zerotier
import socket
zerotier.setup(...)
sock = zerotier.socket(socket.AF_INET, socket.SOCK_STREAM)
Or maybe something like this...
import zerotier
zerotier.setup(...)
zerotier.patch_socket_imports()
import requests
req = requests.get('http://10.10.10.10/somewhere/on/my/zt/network')
I also wouldn't mind having some examples as mentioned in #20.
For instance: zts_listen() being limited to listening only on a single network.
With a GPL license on an SDK, any application using the SDK must also have its source released under the GPL.
Please consider an MIT or BSD license for the SDK -- to allow zerotier to be used by businesses.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.