mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-01 23:10:52 +00:00
Software update work...
This commit is contained in:
parent
c5ef502b42
commit
a22a3ed7e8
@ -2,7 +2,7 @@ CC=clang
|
|||||||
CXX=clang++
|
CXX=clang++
|
||||||
|
|
||||||
INCLUDES=
|
INCLUDES=
|
||||||
DEFS=
|
DEFS=-DZT_AUTO_UPDATE
|
||||||
LIBS=-lm
|
LIBS=-lm
|
||||||
|
|
||||||
# Uncomment for a release optimized universal binary build
|
# Uncomment for a release optimized universal binary build
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
#include "CMWC4096.hpp"
|
#include "CMWC4096.hpp"
|
||||||
#include "SHA512.hpp"
|
#include "SHA512.hpp"
|
||||||
#include "Service.hpp"
|
#include "Service.hpp"
|
||||||
|
#include "SoftwareUpdater.hpp"
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
@ -210,6 +211,7 @@ struct _NodeImpl
|
|||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
delete renv.netconfService;
|
delete renv.netconfService;
|
||||||
#endif
|
#endif
|
||||||
|
delete renv.updater;
|
||||||
delete renv.nc;
|
delete renv.nc;
|
||||||
delete renv.sysEnv;
|
delete renv.sysEnv;
|
||||||
delete renv.topology;
|
delete renv.topology;
|
||||||
@ -429,6 +431,10 @@ Node::ReasonForTermination Node::run()
|
|||||||
return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,foo);
|
return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,foo);
|
||||||
}
|
}
|
||||||
_r->node = this;
|
_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
|
// Bind local port for core I/O
|
||||||
if (!_r->demarc->bindLocalUdp(impl->port)) {
|
if (!_r->demarc->bindLocalUdp(impl->port)) {
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include "Poly1305.hpp"
|
#include "Poly1305.hpp"
|
||||||
#include "SHA512.hpp"
|
#include "SHA512.hpp"
|
||||||
#include "Node.hpp"
|
#include "Node.hpp"
|
||||||
|
#include "SoftwareUpdater.hpp"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
@ -184,6 +185,7 @@ std::vector<std::string> NodeConfig::execute(const char *command)
|
|||||||
_P("200 help join <network ID>");
|
_P("200 help join <network ID>");
|
||||||
_P("200 help leave <network ID>");
|
_P("200 help leave <network ID>");
|
||||||
_P("200 help terminate [<reason>]");
|
_P("200 help terminate [<reason>]");
|
||||||
|
_P("200 help updatecheck");
|
||||||
} else if (cmd[0] == "info") {
|
} else if (cmd[0] == "info") {
|
||||||
bool isOnline = false;
|
bool isOnline = false;
|
||||||
uint64_t now = Utils::now();
|
uint64_t now = Utils::now();
|
||||||
@ -268,6 +270,13 @@ std::vector<std::string> NodeConfig::execute(const char *command)
|
|||||||
if (cmd.size() > 1)
|
if (cmd.size() > 1)
|
||||||
_r->node->terminate(Node::NODE_NORMAL_TERMINATION,cmd[1].c_str());
|
_r->node->terminate(Node::NODE_NORMAL_TERMINATION,cmd[1].c_str());
|
||||||
else _r->node->terminate(Node::NODE_NORMAL_TERMINATION,(const char *)0);
|
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 {
|
} else {
|
||||||
_P("404 %s No such command. Use 'help' for help.",cmd[0].c_str());
|
_P("404 %s No such command. Use 'help' for help.",cmd[0].c_str());
|
||||||
}
|
}
|
||||||
|
@ -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
|
* Pack three-component version into a 64-bit integer
|
||||||
*
|
*
|
||||||
* @param vmaj Major version (0..65535)
|
* @param vmaj Major version (0..65535)
|
||||||
* @param vmin Minor version (0..65535)
|
* @param vmin Minor version (0..65535)
|
||||||
* @param rev Revision (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)
|
static inline uint64_t packVersion(unsigned int vmaj,unsigned int vmin,unsigned int rev)
|
||||||
throw()
|
throw()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user