From 902c8c38d261b1e73329ab4b9fefcfe11995c8b7 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 20 Nov 2013 14:10:33 -0500 Subject: UI basically works, almost ready for testing and packaging... --- node/Node.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'node/Node.cpp') diff --git a/node/Node.cpp b/node/Node.cpp index fe8cfb18..c88741a6 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -182,6 +182,11 @@ unsigned long Node::LocalClient::send(const char *command) } } +std::vector Node::LocalClient::splitLine(const char *line) +{ + return Utils::split(line," ","\\","\""); +} + struct _NodeImpl { RuntimeEnvironment renv; -- cgit v1.2.3 From b699bdefbd008a5dbfab4308e9b969b2aaa88ce1 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 21 Nov 2013 16:34:27 -0500 Subject: Add shutdownIfUnreadable file feature: shut down if shutdownIfUnreadable in home folder is in fact existent but unreadable (e.g. broken link). This enables nifty shutdown on .app trashing feature for OSX. --- node/Node.cpp | 8 ++++++++ node/Utils.cpp | 12 +++++++++++- node/Utils.hpp | 6 ++---- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'node/Node.cpp') diff --git a/node/Node.cpp b/node/Node.cpp index c88741a6..f2668e4e 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -467,6 +467,7 @@ Node::ReasonForTermination Node::run() // Core I/O loop try { + std::string shutdownIfUnreadablePath(_r->homePath + ZT_PATH_SEPARATOR_S + "shutdownIfUnreadable"); uint64_t lastNetworkAutoconfCheck = Utils::now() - 5000; // check autoconf again after 5s for startup uint64_t lastPingCheck = 0; uint64_t lastClean = Utils::now(); // don't need to do this immediately @@ -476,6 +477,13 @@ Node::ReasonForTermination Node::run() long lastDelayDelta = 0; while (impl->reasonForTermination == NODE_RUNNING) { + if (Utils::fileExists(shutdownIfUnreadablePath.c_str(),false)) { + FILE *tmpf = fopen(shutdownIfUnreadablePath.c_str(),"r"); + if (!tmpf) + return impl->terminateBecause(Node::NODE_NORMAL_TERMINATION,"shutdownIfUnreadable was not readable"); + fclose(tmpf); + } + uint64_t now = Utils::now(); bool resynchronize = false; diff --git a/node/Utils.cpp b/node/Utils.cpp index 31cb40dd..608de593 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -246,7 +246,7 @@ no getSecureRandom() implementation; void Utils::lockDownFile(const char *path,bool isDir) { -#if defined(__APPLE__) || defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux) +#ifdef __UNIX_LIKE__ chmod(path,isDir ? 0700 : 0600); #else #ifdef _WIN32 @@ -263,6 +263,16 @@ uint64_t Utils::getLastModified(const char *path) return (((uint64_t)s.st_mtime) * 1000ULL); } +bool Utils::fileExists(const char *path,bool followLinks) +{ + struct stat s; +#ifdef __UNIX_LIKE__ + if (!followLinks) + return (lstat(path,&s) == 0); +#endif + return (stat(path,&s) == 0); +} + int64_t Utils::getFileSize(const char *path) { struct stat s; diff --git a/node/Utils.hpp b/node/Utils.hpp index 4e060748..2fea8b9b 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -177,12 +177,10 @@ public: /** * @param path Path to check + * @param followLinks Follow links (on platforms with that concept) * @return True if file or directory exists at path location */ - static inline bool fileExists(const char *path) - { - return (getLastModified(path) != 0); - } + static bool fileExists(const char *path,bool followLinks = true); /** * @param path Path to file -- cgit v1.2.3 From 612c17240af65243a1fa5d8cc17d3ebdb38a9bee Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 6 Dec 2013 16:49:20 -0800 Subject: Dead code removal, fix for cleanup GitHub issue #28 --- node/Address.hpp | 4 ++-- node/Array.hpp | 4 ++-- node/AtomicCounter.hpp | 4 ++-- node/BandwidthAccount.hpp | 4 ++-- node/Buffer.hpp | 4 ++-- node/C25519.hpp | 4 ++-- node/CMWC4096.hpp | 4 ++-- node/CertificateOfMembership.hpp | 4 ++-- node/Condition.hpp | 4 ++-- node/Constants.hpp | 4 ++-- node/Defaults.hpp | 4 ++-- node/Demarc.hpp | 4 ++-- node/Dictionary.hpp | 4 ++-- node/EthernetTap.hpp | 4 ++-- node/Identity.hpp | 4 ++-- node/InetAddress.hpp | 4 ++-- node/Logger.hpp | 4 ++-- node/MAC.hpp | 4 ++-- node/MulticastGroup.hpp | 4 ++-- node/Multicaster.hpp | 4 ++-- node/Mutex.hpp | 4 ++-- node/Network.hpp | 4 ++-- node/NetworkConfig.hpp | 4 ++-- node/Node.cpp | 9 --------- node/Node.hpp | 12 ++---------- node/NodeConfig.hpp | 4 ++-- node/NonCopyable.hpp | 4 ++-- node/Packet.hpp | 4 ++-- node/PacketDecoder.hpp | 4 ++-- node/Peer.hpp | 4 ++-- node/Poly1305.hpp | 4 ++-- node/RuntimeEnvironment.hpp | 4 ++-- node/SHA512.hpp | 4 ++-- node/Salsa20.hpp | 4 ++-- node/Service.hpp | 4 ++-- node/SharedPtr.hpp | 4 ++-- node/Switch.hpp | 4 ++-- node/SysEnv.hpp | 4 ++-- node/Thread.hpp | 4 ++-- node/Topology.hpp | 4 ++-- node/UdpSocket.hpp | 4 ++-- node/Utils.hpp | 4 ++-- 42 files changed, 82 insertions(+), 99 deletions(-) (limited to 'node/Node.cpp') diff --git a/node/Address.hpp b/node/Address.hpp index b28284b0..7247260c 100644 --- a/node/Address.hpp +++ b/node/Address.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_ADDRESS_HPP -#define _ZT_ADDRESS_HPP +#ifndef ZT_ADDRESS_HPP +#define ZT_ADDRESS_HPP #include #include diff --git a/node/Array.hpp b/node/Array.hpp index d48c2f52..c31626b2 100644 --- a/node/Array.hpp +++ b/node/Array.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_ARRAY_HPP -#define _ZT_ARRAY_HPP +#ifndef ZT_ARRAY_HPP +#define ZT_ARRAY_HPP #include #include diff --git a/node/AtomicCounter.hpp b/node/AtomicCounter.hpp index ebc70817..1aecaa65 100644 --- a/node/AtomicCounter.hpp +++ b/node/AtomicCounter.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_ATOMICCOUNTER_HPP -#define _ZT_ATOMICCOUNTER_HPP +#ifndef ZT_ATOMICCOUNTER_HPP +#define ZT_ATOMICCOUNTER_HPP #include "Mutex.hpp" #include "NonCopyable.hpp" diff --git a/node/BandwidthAccount.hpp b/node/BandwidthAccount.hpp index be180cfc..98c7dd20 100644 --- a/node/BandwidthAccount.hpp +++ b/node/BandwidthAccount.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_BWACCOUNT_HPP -#define _ZT_BWACCOUNT_HPP +#ifndef ZT_BWACCOUNT_HPP +#define ZT_BWACCOUNT_HPP #include #include diff --git a/node/Buffer.hpp b/node/Buffer.hpp index 1767ae04..e8308306 100644 --- a/node/Buffer.hpp +++ b/node/Buffer.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_BUFFER_HPP -#define _ZT_BUFFER_HPP +#ifndef ZT_BUFFER_HPP +#define ZT_BUFFER_HPP #include #include diff --git a/node/C25519.hpp b/node/C25519.hpp index 79edfa06..2a594f72 100644 --- a/node/C25519.hpp +++ b/node/C25519.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_C25519_HPP -#define _ZT_C25519_HPP +#ifndef ZT_C25519_HPP +#define ZT_C25519_HPP #include "Array.hpp" #include "Utils.hpp" diff --git a/node/CMWC4096.hpp b/node/CMWC4096.hpp index 29351861..01c57e15 100644 --- a/node/CMWC4096.hpp +++ b/node/CMWC4096.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_CMWC4096_HPP -#define _ZT_CMWC4096_HPP +#ifndef ZT_CMWC4096_HPP +#define ZT_CMWC4096_HPP #include #include "Utils.hpp" diff --git a/node/CertificateOfMembership.hpp b/node/CertificateOfMembership.hpp index 76e1cfbc..6f78734e 100644 --- a/node/CertificateOfMembership.hpp +++ b/node/CertificateOfMembership.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_CERTIFICATEOFMEMBERSHIP_HPP -#define _ZT_CERTIFICATEOFMEMBERSHIP_HPP +#ifndef ZT_CERTIFICATEOFMEMBERSHIP_HPP +#define ZT_CERTIFICATEOFMEMBERSHIP_HPP #include #include diff --git a/node/Condition.hpp b/node/Condition.hpp index 4b2d32ca..728799d9 100644 --- a/node/Condition.hpp +++ b/node/Condition.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_CONDITION_HPP -#define _ZT_CONDITION_HPP +#ifndef ZT_CONDITION_HPP +#define ZT_CONDITION_HPP #include "Constants.hpp" #include "NonCopyable.hpp" diff --git a/node/Constants.hpp b/node/Constants.hpp index dbdc4ec9..3f121cf4 100644 --- a/node/Constants.hpp +++ b/node/Constants.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_CONSTANTS_HPP -#define _ZT_CONSTANTS_HPP +#ifndef ZT_CONSTANTS_HPP +#define ZT_CONSTANTS_HPP // // This include file also auto-detects and canonicalizes some environment diff --git a/node/Defaults.hpp b/node/Defaults.hpp index dac59ae6..d546d01f 100644 --- a/node/Defaults.hpp +++ b/node/Defaults.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_DEFAULTS_HPP -#define _ZT_DEFAULTS_HPP +#ifndef ZT_DEFAULTS_HPP +#define ZT_DEFAULTS_HPP #include #include diff --git a/node/Demarc.hpp b/node/Demarc.hpp index fc283fef..0bbdef44 100644 --- a/node/Demarc.hpp +++ b/node/Demarc.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_DEMARC_HPP -#define _ZT_DEMARC_HPP +#ifndef ZT_DEMARC_HPP +#define ZT_DEMARC_HPP #include #include diff --git a/node/Dictionary.hpp b/node/Dictionary.hpp index a0a64cec..214c0094 100644 --- a/node/Dictionary.hpp +++ b/node/Dictionary.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_DICTIONARY_HPP -#define _ZT_DICTIONARY_HPP +#ifndef ZT_DICTIONARY_HPP +#define ZT_DICTIONARY_HPP #include #include diff --git a/node/EthernetTap.hpp b/node/EthernetTap.hpp index 3db41392..68a365bf 100644 --- a/node/EthernetTap.hpp +++ b/node/EthernetTap.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_ETHERNETTAP_HPP -#define _ZT_ETHERNETTAP_HPP +#ifndef ZT_ETHERNETTAP_HPP +#define ZT_ETHERNETTAP_HPP #include #include diff --git a/node/Identity.hpp b/node/Identity.hpp index cb911b92..f6b1f876 100644 --- a/node/Identity.hpp +++ b/node/Identity.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_IDENTITY_HPP -#define _ZT_IDENTITY_HPP +#ifndef ZT_IDENTITY_HPP +#define ZT_IDENTITY_HPP #include #include diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp index 54fbc395..d90574e5 100644 --- a/node/InetAddress.hpp +++ b/node/InetAddress.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_INETADDRESS_HPP -#define _ZT_INETADDRESS_HPP +#ifndef ZT_INETADDRESS_HPP +#define ZT_INETADDRESS_HPP #include #include diff --git a/node/Logger.hpp b/node/Logger.hpp index de71ed39..b99df392 100644 --- a/node/Logger.hpp +++ b/node/Logger.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_LOGGER_HPP -#define _ZT_LOGGER_HPP +#ifndef ZT_LOGGER_HPP +#define ZT_LOGGER_HPP #include diff --git a/node/MAC.hpp b/node/MAC.hpp index 87363a44..f0bca937 100644 --- a/node/MAC.hpp +++ b/node/MAC.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_MAC_HPP -#define _ZT_MAC_HPP +#ifndef ZT_MAC_HPP +#define ZT_MAC_HPP #include #include diff --git a/node/MulticastGroup.hpp b/node/MulticastGroup.hpp index 426ef048..32f8c0ed 100644 --- a/node/MulticastGroup.hpp +++ b/node/MulticastGroup.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_MULTICASTGROUP_HPP -#define _ZT_MULTICASTGROUP_HPP +#ifndef ZT_MULTICASTGROUP_HPP +#define ZT_MULTICASTGROUP_HPP #include diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp index 16ae7218..164bfd79 100644 --- a/node/Multicaster.hpp +++ b/node/Multicaster.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_MULTICASTER_HPP -#define _ZT_MULTICASTER_HPP +#ifndef ZT_MULTICASTER_HPP +#define ZT_MULTICASTER_HPP #include #include diff --git a/node/Mutex.hpp b/node/Mutex.hpp index b0130293..509b60be 100644 --- a/node/Mutex.hpp +++ b/node/Mutex.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_MUTEX_HPP -#define _ZT_MUTEX_HPP +#ifndef ZT_MUTEX_HPP +#define ZT_MUTEX_HPP #include "Constants.hpp" #include "NonCopyable.hpp" diff --git a/node/Network.hpp b/node/Network.hpp index a219cdf2..f41e7502 100644 --- a/node/Network.hpp +++ b/node/Network.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_NETWORK_HPP -#define _ZT_NETWORK_HPP +#ifndef ZT_NETWORK_HPP +#define ZT_NETWORK_HPP #include diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp index a833006f..823363bd 100644 --- a/node/NetworkConfig.hpp +++ b/node/NetworkConfig.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_NETWORKCONFIG_HPP -#define _ZT_NETWORKCONFIG_HPP +#ifndef ZT_NETWORKCONFIG_HPP +#define ZT_NETWORKCONFIG_HPP #include diff --git a/node/Node.cpp b/node/Node.cpp index f2668e4e..8c6ab49b 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -623,15 +623,6 @@ unsigned int Node::versionMajor() throw() { return ZEROTIER_ONE_VERSION_MAJOR; } unsigned int Node::versionMinor() throw() { return ZEROTIER_ONE_VERSION_MINOR; } unsigned int Node::versionRevision() throw() { return ZEROTIER_ONE_VERSION_REVISION; } -// Scanned for by loader and/or updater to determine a binary's version -const unsigned char EMBEDDED_VERSION_STAMP[20] = { - 0x6d,0xfe,0xff,0x01,0x90,0xfa,0x89,0x57,0x88,0xa1,0xaa,0xdc,0xdd,0xde,0xb0,0x33, - ZEROTIER_ONE_VERSION_MAJOR, - ZEROTIER_ONE_VERSION_MINOR, - (unsigned char)(((unsigned int)ZEROTIER_ONE_VERSION_REVISION) & 0xff), /* little-endian */ - (unsigned char)((((unsigned int)ZEROTIER_ONE_VERSION_REVISION) >> 8) & 0xff) -}; - } // namespace ZeroTier extern "C" { diff --git a/node/Node.hpp b/node/Node.hpp index 476ec7cd..9d02c008 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_NODE_HPP -#define _ZT_NODE_HPP +#ifndef ZT_NODE_HPP +#define ZT_NODE_HPP #include #include @@ -171,14 +171,6 @@ private: void *const _impl; // private implementation }; -/** - * An embedded version code that can be searched for in the binary - * - * This shouldn't be used by users, but is exported to make certain that - * the linker actually includes it in the image. - */ -extern const unsigned char EMBEDDED_VERSION_STAMP[20]; - } // namespace ZeroTier extern "C" { diff --git a/node/NodeConfig.hpp b/node/NodeConfig.hpp index 0e7e4c98..2612cf6a 100644 --- a/node/NodeConfig.hpp +++ b/node/NodeConfig.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_NODECONFIG_HPP -#define _ZT_NODECONFIG_HPP +#ifndef ZT_NODECONFIG_HPP +#define ZT_NODECONFIG_HPP #include diff --git a/node/NonCopyable.hpp b/node/NonCopyable.hpp index 26536a36..e39deba8 100644 --- a/node/NonCopyable.hpp +++ b/node/NonCopyable.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _NONCOPYABLE_HPP__ -#define _NONCOPYABLE_HPP__ +#ifndef ZT_NONCOPYABLE_HPP__ +#define ZT_NONCOPYABLE_HPP__ namespace ZeroTier { diff --git a/node/Packet.hpp b/node/Packet.hpp index b7f52e3c..6f3f9117 100644 --- a/node/Packet.hpp +++ b/node/Packet.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_N_PACKET_HPP -#define _ZT_N_PACKET_HPP +#ifndef ZT_N_PACKET_HPP +#define ZT_N_PACKET_HPP #include #include diff --git a/node/PacketDecoder.hpp b/node/PacketDecoder.hpp index cb3522ff..72b05290 100644 --- a/node/PacketDecoder.hpp +++ b/node/PacketDecoder.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_PACKETDECODER_HPP -#define _ZT_PACKETDECODER_HPP +#ifndef ZT_PACKETDECODER_HPP +#define ZT_PACKETDECODER_HPP #include diff --git a/node/Peer.hpp b/node/Peer.hpp index 0a8a7b57..de5df08f 100644 --- a/node/Peer.hpp +++ b/node/Peer.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_PEER_HPP -#define _ZT_PEER_HPP +#ifndef ZT_PEER_HPP +#define ZT_PEER_HPP #include diff --git a/node/Poly1305.hpp b/node/Poly1305.hpp index 94e6078d..8baa448f 100644 --- a/node/Poly1305.hpp +++ b/node/Poly1305.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_POLY1305_HPP -#define _ZT_POLY1305_HPP +#ifndef ZT_POLY1305_HPP +#define ZT_POLY1305_HPP namespace ZeroTier { diff --git a/node/RuntimeEnvironment.hpp b/node/RuntimeEnvironment.hpp index 75b171ff..48797b14 100644 --- a/node/RuntimeEnvironment.hpp +++ b/node/RuntimeEnvironment.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_RUNTIMEENVIRONMENT_HPP -#define _ZT_RUNTIMEENVIRONMENT_HPP +#ifndef ZT_RUNTIMEENVIRONMENT_HPP +#define ZT_RUNTIMEENVIRONMENT_HPP #include diff --git a/node/SHA512.hpp b/node/SHA512.hpp index 565eb097..721933cb 100644 --- a/node/SHA512.hpp +++ b/node/SHA512.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_SHA512_HPP -#define _ZT_SHA512_HPP +#ifndef ZT_SHA512_HPP +#define ZT_SHA512_HPP #define ZT_SHA512_DIGEST_LEN 64 diff --git a/node/Salsa20.hpp b/node/Salsa20.hpp index 9f34ba78..e09e2aaa 100644 --- a/node/Salsa20.hpp +++ b/node/Salsa20.hpp @@ -4,8 +4,8 @@ * This therefore is public domain. */ -#ifndef _ZT_SALSA20_HPP -#define _ZT_SALSA20_HPP +#ifndef ZT_SALSA20_HPP +#define ZT_SALSA20_HPP #include diff --git a/node/Service.hpp b/node/Service.hpp index d8467cd1..22e53d62 100644 --- a/node/Service.hpp +++ b/node/Service.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_SERVICE_HPP -#define _ZT_SERVICE_HPP +#ifndef ZT_SERVICE_HPP +#define ZT_SERVICE_HPP #include #include diff --git a/node/SharedPtr.hpp b/node/SharedPtr.hpp index 834d0a2e..f7604c06 100644 --- a/node/SharedPtr.hpp +++ b/node/SharedPtr.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_SHAREDPTR_HPP -#define _ZT_SHAREDPTR_HPP +#ifndef ZT_SHAREDPTR_HPP +#define ZT_SHAREDPTR_HPP #include "Mutex.hpp" #include "AtomicCounter.hpp" diff --git a/node/Switch.hpp b/node/Switch.hpp index 68e3c6c4..6b3b8e6e 100644 --- a/node/Switch.hpp +++ b/node/Switch.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_N_SWITCH_HPP -#define _ZT_N_SWITCH_HPP +#ifndef ZT_N_SWITCH_HPP +#define ZT_N_SWITCH_HPP #include #include diff --git a/node/SysEnv.hpp b/node/SysEnv.hpp index 21c25713..4f4a4f16 100644 --- a/node/SysEnv.hpp +++ b/node/SysEnv.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_SYSENV_HPP -#define _ZT_SYSENV_HPP +#ifndef ZT_SYSENV_HPP +#define ZT_SYSENV_HPP #include diff --git a/node/Thread.hpp b/node/Thread.hpp index d295fea3..8adf79d3 100644 --- a/node/Thread.hpp +++ b/node/Thread.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_THREAD_HPP -#define _ZT_THREAD_HPP +#ifndef ZT_THREAD_HPP +#define ZT_THREAD_HPP #include diff --git a/node/Topology.hpp b/node/Topology.hpp index 09dec86e..312377bc 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_TOPOLOGY_HPP -#define _ZT_TOPOLOGY_HPP +#ifndef ZT_TOPOLOGY_HPP +#define ZT_TOPOLOGY_HPP #include #include diff --git a/node/UdpSocket.hpp b/node/UdpSocket.hpp index d8467f64..cbd9de86 100644 --- a/node/UdpSocket.hpp +++ b/node/UdpSocket.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_UDPSOCKET_HPP -#define _ZT_UDPSOCKET_HPP +#ifndef ZT_UDPSOCKET_HPP +#define ZT_UDPSOCKET_HPP #include diff --git a/node/Utils.hpp b/node/Utils.hpp index 2fea8b9b..dfead0d1 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -25,8 +25,8 @@ * LLC. Start here: http://www.zerotier.com/ */ -#ifndef _ZT_UTILS_HPP -#define _ZT_UTILS_HPP +#ifndef ZT_UTILS_HPP +#define ZT_UTILS_HPP #include #include -- cgit v1.2.3 From a22a3ed7e8754fbfb2f48e4a32b79d6b7468e25c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 11 Dec 2013 13:00:18 -0800 Subject: Software update work... --- make-mac.mk | 2 +- node/Node.cpp | 6 ++++++ node/NodeConfig.cpp | 9 +++++++++ node/SoftwareUpdater.hpp | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) (limited to 'node/Node.cpp') diff --git a/make-mac.mk b/make-mac.mk index 8b1d121b..9f0d7d8c 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -2,7 +2,7 @@ CC=clang CXX=clang++ INCLUDES= -DEFS= +DEFS=-DZT_AUTO_UPDATE LIBS=-lm # Uncomment for a release optimized universal binary build diff --git a/node/Node.cpp b/node/Node.cpp index 8c6ab49b..dd0e47ed 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -68,6 +68,7 @@ #include "CMWC4096.hpp" #include "SHA512.hpp" #include "Service.hpp" +#include "SoftwareUpdater.hpp" #ifdef __WINDOWS__ #include @@ -210,6 +211,7 @@ struct _NodeImpl #ifndef __WINDOWS__ delete renv.netconfService; #endif + delete renv.updater; delete renv.nc; delete renv.sysEnv; delete renv.topology; @@ -429,6 +431,10 @@ Node::ReasonForTermination Node::run() return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,foo); } _r->node = this; +#ifdef ZT_AUTO_UPDATE + if (ZT_DEFAULTS.updateLatestNfoURL.length()) + _r->updater = new SoftwareUpdater(_r); +#endif // Bind local port for core I/O if (!_r->demarc->bindLocalUdp(impl->port)) { diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp index ce5943c5..770f1f6f 100644 --- a/node/NodeConfig.cpp +++ b/node/NodeConfig.cpp @@ -56,6 +56,7 @@ #include "Poly1305.hpp" #include "SHA512.hpp" #include "Node.hpp" +#include "SoftwareUpdater.hpp" namespace ZeroTier { @@ -184,6 +185,7 @@ std::vector NodeConfig::execute(const char *command) _P("200 help join "); _P("200 help leave "); _P("200 help terminate []"); + _P("200 help updatecheck"); } else if (cmd[0] == "info") { bool isOnline = false; uint64_t now = Utils::now(); @@ -268,6 +270,13 @@ std::vector NodeConfig::execute(const char *command) if (cmd.size() > 1) _r->node->terminate(Node::NODE_NORMAL_TERMINATION,cmd[1].c_str()); else _r->node->terminate(Node::NODE_NORMAL_TERMINATION,(const char *)0); + } else if (cmd[0] == "updatecheck") { + if (_r->updater) { + _P("200 checking for software updates now at: %s",ZT_DEFAULTS.updateLatestNfoURL.c_str()); + _r->updater->checkNow(); + } else { + _P("500 software updates are not enabled"); + } } else { _P("404 %s No such command. Use 'help' for help.",cmd[0].c_str()); } diff --git a/node/SoftwareUpdater.hpp b/node/SoftwareUpdater.hpp index bfcdf395..5e47bbea 100644 --- a/node/SoftwareUpdater.hpp +++ b/node/SoftwareUpdater.hpp @@ -74,12 +74,26 @@ public: } } + /** + * Check for updates now regardless of last check time or version + */ + inline void checkNow() + { + Mutex::Lock _l(_lock); + if (_status == UPDATE_STATUS_IDLE) { + _lastUpdateAttempt = Utils::now(); + _status = UPDATE_STATUS_GETTING_NFO; + HttpClient::GET(ZT_DEFAULTS.updateLatestNfoURL,HttpClient::NO_HEADERS,ZT_UPDATE_HTTP_TIMEOUT,&_cbHandleGetLatestVersionInfo,this); + } + } + /** * Pack three-component version into a 64-bit integer * * @param vmaj Major version (0..65535) * @param vmin Minor version (0..65535) * @param rev Revision (0..65535) + * @return Version packed into an easily comparable 64-bit integer */ static inline uint64_t packVersion(unsigned int vmaj,unsigned int vmin,unsigned int rev) throw() -- cgit v1.2.3