diff options
author | Grant Limberg <grant.limberg@zerotier.com> | 2018-09-28 10:56:40 -0700 |
---|---|---|
committer | Grant Limberg <grant.limberg@zerotier.com> | 2018-09-28 10:56:40 -0700 |
commit | c1ea1329c1fec8f632711711113e4dcf37ea21da (patch) | |
tree | d4a05942d957e3539cfa5150844157208c6f516d | |
parent | 417aa9547b4f3abb9009a3dbb66ecf93d3d686f7 (diff) | |
parent | 60d5a3c631d2185aaba7ce6da3ce96b37fbd0290 (diff) | |
download | infinitytier-c1ea1329c1fec8f632711711113e4dcf37ea21da.tar.gz infinitytier-c1ea1329c1fec8f632711711113e4dcf37ea21da.zip |
Merge branch 'dev' into libpq
-rw-r--r-- | controller/EmbeddedNetworkController.cpp | 1 | ||||
-rw-r--r-- | controller/FileDB.cpp | 14 | ||||
-rwxr-xr-x | ext/installfiles/mac/uninstall.sh | 2 | ||||
-rw-r--r-- | node/InetAddress.cpp | 43 |
4 files changed, 22 insertions, 38 deletions
diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index e0cea53d..27d7658a 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -1043,6 +1043,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE( json network,member; _db->get(nwid,network,address,member); + _db->eraseMember(nwid, address); { std::lock_guard<std::mutex> l(_memberStatus_l); diff --git a/controller/FileDB.cpp b/controller/FileDB.cpp index 8cbd60ce..3f5d46bd 100644 --- a/controller/FileDB.cpp +++ b/controller/FileDB.cpp @@ -136,12 +136,24 @@ void FileDB::eraseNetwork(const uint64_t networkId) get(networkId,network); char p[16384]; OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.16llx.json",_networksPath.c_str(),networkId); - OSUtils::rm(p); + + if (OSUtils::fileExists(p,false)){ + OSUtils::rm(p); + } _networkChanged(network,nullJson,true); } void FileDB::eraseMember(const uint64_t networkId,const uint64_t memberId) { + nlohmann::json network,member,nullJson; + get(networkId,network); + get(memberId,member); + char p[16384]; + OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.16llx" ZT_PATH_SEPARATOR_S "member" ZT_PATH_SEPARATOR_S "%.10llx.json",_networksPath.c_str(),networkId,memberId); + if (OSUtils::fileExists(p,false)){ + OSUtils::rm(p); + } + _memberChanged(member,nullJson,true); } void FileDB::nodeIsOnline(const uint64_t networkId,const uint64_t memberId,const InetAddress &physicalAddress) diff --git a/ext/installfiles/mac/uninstall.sh b/ext/installfiles/mac/uninstall.sh index 9bf5d6fc..52c09b63 100755 --- a/ext/installfiles/mac/uninstall.sh +++ b/ext/installfiles/mac/uninstall.sh @@ -27,7 +27,7 @@ kextunload '/Library/Application Support/ZeroTier/One/tap.kext' >>/dev/null 2>&1 echo "Removing ZeroTier One files..." rm -rf '/Applications/ZeroTier One.app' -rm -f '/usr/bin/zerotier-one' '/usr/bin/zerotier-idtool' '/usr/bin/zerotier-cli' '/Library/LaunchDaemons/com.zerotier.one.plist' +rm -f '/usr/local/bin/zerotier-one' '/usr/local/bin/zerotier-idtool' '/usr/local/bin/zerotier-cli' '/Library/LaunchDaemons/com.zerotier.one.plist' cd '/Library/Application Support/ZeroTier/One' if [ "`pwd`" = '/Library/Application Support/ZeroTier/One' ]; then diff --git a/node/InetAddress.cpp b/node/InetAddress.cpp index 5d6ad07f..3eb5579f 100644 --- a/node/InetAddress.cpp +++ b/node/InetAddress.cpp @@ -139,33 +139,15 @@ char *InetAddress::toString(char buf[64]) const char *InetAddress::toIpString(char buf[64]) const { + buf[0] = (char)0; switch(ss_family) { case AF_INET: { - const uint8_t *a = reinterpret_cast<const uint8_t *>(&(reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr)); - char *p = buf; - for(int i=0;;++i) { - Utils::decimal((unsigned long)a[i],p); - if (i != 3) { - while (*p) ++p; - *(p++) = '.'; - } else break; - } - } break; + inet_ntop(AF_INET, &reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr, buf, INET_ADDRSTRLEN); + } break; case AF_INET6: { - uint16_t a[8]; - ZT_FAST_MEMCPY(a,reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,16); - char *p = buf; - for(int i=0;i<8;++i) { - Utils::hex(Utils::ntoh(a[i]),p); - p[4] = (i == 7) ? (char)0 : ':'; - p += 5; - } + inet_ntop(AF_INET6, reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr, buf, INET6_ADDRSTRLEN); } break; - - default: - buf[0] = (char)0; - break; } return buf; } @@ -191,28 +173,17 @@ bool InetAddress::fromString(const char *ipSlashPort) } if (strchr(buf,':')) { - uint16_t a[8]; - unsigned int b = 0; - char *saveptr = (char *)0; - for(char *s=Utils::stok(buf,":",&saveptr);((s)&&(b<8));s=Utils::stok((char *)0,":",&saveptr)) - a[b++] = Utils::hton((uint16_t)(Utils::hexStrToUInt(s) & 0xffff)); - struct sockaddr_in6 *const in6 = reinterpret_cast<struct sockaddr_in6 *>(this); + inet_pton(AF_INET6, buf, &in6->sin6_addr.s6_addr); in6->sin6_family = AF_INET6; - ZT_FAST_MEMCPY(in6->sin6_addr.s6_addr,a,16); in6->sin6_port = Utils::hton((uint16_t)port); + return true; } else if (strchr(buf,'.')) { - uint8_t a[4]; - unsigned int b = 0; - char *saveptr = (char *)0; - for(char *s=Utils::stok(buf,".",&saveptr);((s)&&(b<4));s=Utils::stok((char *)0,".",&saveptr)) - a[b++] = (uint8_t)(Utils::strToUInt(s) & 0xff); - struct sockaddr_in *const in = reinterpret_cast<struct sockaddr_in *>(this); + inet_pton(AF_INET, buf, &in->sin_addr.s_addr); in->sin_family = AF_INET; - ZT_FAST_MEMCPY(&(in->sin_addr.s_addr),a,4); in->sin_port = Utils::hton((uint16_t)port); return true; |