diff options
-rw-r--r-- | ext/installfiles/linux/DEBIAN/control.in | 1 | ||||
-rwxr-xr-x | ext/installfiles/linux/init.d/zerotier-one | 19 | ||||
-rwxr-xr-x | ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One | bin | 152736 -> 152736 bytes | |||
-rw-r--r-- | ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib | bin | 3723 -> 3616 bytes | |||
-rw-r--r-- | ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources | 4 | ||||
-rw-r--r-- | ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib | 16 | ||||
-rw-r--r-- | node/Peer.hpp | 1 | ||||
-rw-r--r-- | node/Switch.cpp | 10 | ||||
-rw-r--r-- | osdep/OSXEthernetTap.cpp | 45 | ||||
-rw-r--r-- | osdep/PortMapper.cpp | 2 | ||||
-rw-r--r-- | selftest.cpp | 6 | ||||
-rw-r--r-- | service/OneService.cpp | 22 |
12 files changed, 66 insertions, 60 deletions
diff --git a/ext/installfiles/linux/DEBIAN/control.in b/ext/installfiles/linux/DEBIAN/control.in index d774b61e..dab6587f 100644 --- a/ext/installfiles/linux/DEBIAN/control.in +++ b/ext/installfiles/linux/DEBIAN/control.in @@ -3,6 +3,7 @@ Architecture: __ARCH__ Maintainer: ZeroTier, Inc. <contact@zerotier.com> Priority: optional Version: __VERSION__ +Installed-Size: 1024 Homepage: https://github.com/zerotier/ZeroTierOne Description: ZeroTier One network virtualization service ZeroTier One is a fast, secure, and easy to use peer to peer network diff --git a/ext/installfiles/linux/init.d/zerotier-one b/ext/installfiles/linux/init.d/zerotier-one index c8e7615e..b0a8aa41 100755 --- a/ext/installfiles/linux/init.d/zerotier-one +++ b/ext/installfiles/linux/init.d/zerotier-one @@ -7,21 +7,20 @@ # networks. See https://www.zerotier.com/ for more information. ### BEGIN INIT INFO -# Provides: zerotier-one -# Required-Start: $local_fs $network -# Required-Stop: $local_fs -# Default-Start: 2345 -# Default-Stop: 90 -# Short-Description: start ZeroTier One -# Description: ZeroTier One provides public and private distributed ethernet \ -# networks. See https://www.zerotier.com/ for more information. +# Provides: zerotier-one +# Required-Start: $local_fs $network +# Required-Stop: $local_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start ZeroTier One +# Description: ZeroTier One provides public and private distributed ethernet \ +# networks. See https://www.zerotier.com/ for more information. ### END INIT INFO # # This script is written to avoid distro-specific dependencies, so it does not # use the rc bash script libraries found on some systems. It should work on -# just about anything, even systems using Upstart. Upstart native support may -# come in the future. +# just about anything. # zthome=/var/lib/zerotier-one diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One Binary files differindex ba15bca9..8e38b861 100755 --- a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One +++ b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/MacOS/ZeroTier One diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib Binary files differindex 69258da6..e7b174a1 100644 --- a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib +++ b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/Resources/en.lproj/Window.nib diff --git a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources index 14556923..5e334db0 100644 --- a/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources +++ b/ext/mac-ui-macgap1-wrapper/bin/ZeroTier One.app/Contents/_CodeSignature/CodeResources @@ -39,7 +39,7 @@ <dict> <key>hash</key> <data> - 7dgumnPDtoIzhi9QoaFhDvCo9ys= + aP0mIANPPnnTMmxYlELioz9ZO1I= </data> <key>optional</key> <true/> @@ -82,7 +82,7 @@ <dict> <key>hash</key> <data> - 7dgumnPDtoIzhi9QoaFhDvCo9ys= + aP0mIANPPnnTMmxYlELioz9ZO1I= </data> <key>optional</key> <true/> diff --git a/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib b/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib index 2c46b79f..fa70acaa 100644 --- a/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib +++ b/ext/mac-ui-macgap1-wrapper/src/MacGap/en.lproj/Window.xib @@ -13,22 +13,22 @@ </connections> </customObject> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> - <customObject id="-3" userLabel="Application"/> + <customObject id="-3" userLabel="Application" customClass="NSObject"/> <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="1"> - <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> - <rect key="contentRect" x="575" y="564" width="500" height="700"/> + <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> + <rect key="contentRect" x="575" y="564" width="500" height="500"/> <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/> - <value key="minSize" type="size" width="500" height="700"/> - <value key="maxSize" type="size" width="500" height="700"/> <view key="contentView" id="2" customClass="ContentView"> - <rect key="frame" x="0.0" y="0.0" width="500" height="700"/> + <rect key="frame" x="0.0" y="0.0" width="500" height="500"/> <autoresizingMask key="autoresizingMask"/> <subviews> <webView id="5"> - <rect key="frame" x="0.0" y="0.0" width="500" height="700"/> + <rect key="frame" x="0.0" y="0.0" width="500" height="500"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <animations/> - <webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12"/> + <webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12"> + <nil key="identifier"/> + </webPreferences> </webView> </subviews> <animations/> diff --git a/node/Peer.hpp b/node/Peer.hpp index 7b8d18ea..5816db69 100644 --- a/node/Peer.hpp +++ b/node/Peer.hpp @@ -263,7 +263,6 @@ public: return (l * (((unsigned int)tsr / (ZT_PEER_DIRECT_PING_DELAY + 1000)) + 1)); } - /** * Update latency with a new direct measurment * diff --git a/node/Switch.cpp b/node/Switch.cpp index 74e2f4c6..bf0d1aff 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -820,10 +820,12 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) for(std::vector< std::pair<Address,InetAddress> >::const_iterator r(nconf->relays().begin());r!=nconf->relays().end();++r) { if (r->first != peer->address()) { SharedPtr<Peer> rp(RR->topology->getPeer(r->first)); - const unsigned int q = rp->relayQuality(now); - if ((rp)&&(q < bestq)) { // SUBTILE: < == don't use these if they are nil quality (unsigned int max), instead use a root - bestq = q; - rp.swap(relay); + if (rp) { + const unsigned int q = rp->relayQuality(now); + if (q < bestq) { // SUBTILE: < == don't use these if they are nil quality (unsigned int max), instead use a root + bestq = q; + rp.swap(relay); + } } } } diff --git a/osdep/OSXEthernetTap.cpp b/osdep/OSXEthernetTap.cpp index 6b6f360b..3e43cf95 100644 --- a/osdep/OSXEthernetTap.cpp +++ b/osdep/OSXEthernetTap.cpp @@ -143,7 +143,7 @@ static inline int _intl_getifmaddrs(struct _intl_ifmaddrs **pif) } free(buf); buf = NULL; - } + } } while (buf == NULL); for (next = buf; next < buf + needed; next += rtm->rtm_msglen) { @@ -475,37 +475,11 @@ bool OSXEthernetTap::enabled() const return _enabled; } -static bool ___removeIp(const std::string &_dev,const InetAddress &ip) -{ - long cpid = (long)vfork(); - if (cpid == 0) { - execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"inet",ip.toIpString().c_str(),"-alias",(const char *)0); - _exit(-1); - } else if (cpid > 0) { - int exitcode = -1; - waitpid(cpid,&exitcode,0); - return (exitcode == 0); - } - return false; // never reached, make compiler shut up about return value -} - bool OSXEthernetTap::addIp(const InetAddress &ip) { if (!ip) return false; - std::vector<InetAddress> allIps(ips()); - if (std::binary_search(allIps.begin(),allIps.end(),ip)) - return true; - - // Remove and reconfigure if address is the same but netmask is different - for(std::vector<InetAddress>::iterator i(allIps.begin());i!=allIps.end();++i) { - if ((i->ipsEqual(ip))&&(i->netmaskBits() != ip.netmaskBits())) { - if (___removeIp(_dev,*i)) - break; - } - } - long cpid = (long)vfork(); if (cpid == 0) { ::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),ip.isV4() ? "inet" : "inet6",ip.toString().c_str(),"alias",(const char *)0); @@ -524,9 +498,18 @@ bool OSXEthernetTap::removeIp(const InetAddress &ip) if (!ip) return true; std::vector<InetAddress> allIps(ips()); - if (!std::binary_search(allIps.begin(),allIps.end(),ip)) { - if (___removeIp(_dev,ip)) - return true; + for(std::vector<InetAddress>::iterator i(allIps.begin());i!=allIps.end();++i) { + if (*i == ip) { + long cpid = (long)vfork(); + if (cpid == 0) { + execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"inet",ip.toIpString().c_str(),"-alias",(const char *)0); + _exit(-1); + } else if (cpid > 0) { + int exitcode = -1; + waitpid(cpid,&exitcode,0); + return (exitcode == 0); + } + } } return false; } @@ -564,7 +547,7 @@ std::vector<InetAddress> OSXEthernetTap::ips() const freeifaddrs(ifa); std::sort(r.begin(),r.end()); - std::unique(r.begin(),r.end()); + r.erase(std::unique(r.begin(),r.end()),r.end()); return r; } diff --git a/osdep/PortMapper.cpp b/osdep/PortMapper.cpp index 5c017931..87c886c2 100644 --- a/osdep/PortMapper.cpp +++ b/osdep/PortMapper.cpp @@ -28,7 +28,7 @@ #ifdef ZT_USE_MINIUPNPC // Uncomment to dump debug messages -#define ZT_PORTMAPPER_TRACE 1 +//#define ZT_PORTMAPPER_TRACE 1 #include <stdio.h> #include <stdlib.h> diff --git a/selftest.cpp b/selftest.cpp index e68f564c..4e9219b2 100644 --- a/selftest.cpp +++ b/selftest.cpp @@ -1096,7 +1096,7 @@ int main(int argc,char **argv) srand((unsigned int)time(0)); - /* + ///* r |= testSqliteNetworkController(); r |= testOther(); r |= testCrypto(); @@ -1106,17 +1106,19 @@ int main(int argc,char **argv) r |= testPhy(); r |= testResolver(); //r |= testHttp(); - */ + //*/ if (r) std::cout << std::endl << "SOMETHING FAILED!" << std::endl; + /* #ifdef ZT_USE_MINIUPNPC std::cout << std::endl; std::cout << "[portmapper] Starting port mapper and waiting forever... use CTRL+C to exit. (enable ZT_PORTMAPPER_TRACE in PortMapper.cpp for output)" << std::endl; PortMapper mapper(12345,"ZeroTier/__selftest"); Thread::sleep(0xffffffff); #endif + */ return r; } diff --git a/service/OneService.cpp b/service/OneService.cpp index 96da4274..c3204b5d 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -355,6 +355,26 @@ public: static BackgroundSoftwareUpdateChecker backgroundSoftwareUpdateChecker; #endif // ZT_AUTO_UPDATE +static bool isBlacklistedLocalInterfaceForZeroTierTraffic(const char *ifn) +{ +#if defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux) + if ((ifn[0] == 'l')&&(ifn[1] == 'o')) return true; // loopback + if ((ifn[0] == 'z')&&(ifn[1] == 't')) return true; // sanity check: zt# + if ((ifn[0] == 't')&&(ifn[1] == 'u')&&(ifn[2] == 'n')) return true; // tun# is probably an OpenVPN tunnel or similar + if ((ifn[0] == 't')&&(ifn[1] == 'a')&&(ifn[2] == 'p')) return true; // tap# is probably an OpenVPN tunnel or similar +#endif + +#ifdef __APPLE__ + if ((ifn[0] == 'l')&&(ifn[1] == 'o')) return true; // loopback + if ((ifn[0] == 'z')&&(ifn[1] == 't')) return true; // sanity check: zt# + if ((ifn[0] == 't')&&(ifn[1] == 'u')&&(ifn[2] == 'n')) return true; // tun# is probably an OpenVPN tunnel or similar + if ((ifn[0] == 't')&&(ifn[1] == 'a')&&(ifn[2] == 'p')) return true; // tap# is probably an OpenVPN tunnel or similar + if ((ifn[0] == 'u')&&(ifn[1] == 't')&&(ifn[2] == 'u')&&(ifn[3] == 'n')) return true; // ... as is utun# +#endif + + return false; +} + static std::string _trimString(const std::string &s) { unsigned long end = (unsigned long)s.length(); @@ -768,7 +788,7 @@ public: if ((getifaddrs(&ifatbl) == 0)&&(ifatbl)) { struct ifaddrs *ifa = ifatbl; while (ifa) { - if ((ifa->ifa_name)&&(ifa->ifa_addr)) { + if ((ifa->ifa_name)&&(ifa->ifa_addr)&&(!isBlacklistedLocalInterfaceForZeroTierTraffic(ifa->ifa_name))) { bool isZT = false; for(std::vector<std::string>::const_iterator d(ztDevices.begin());d!=ztDevices.end();++d) { if (*d == ifa->ifa_name) { |