summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-12-12 13:02:02 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-12-12 13:02:02 -0800
commit54d1b11b1981481ba177c8f7c84c179977f5652d (patch)
treeaa8eacfe1d0badfca3f9cb6e9856b9f458e1a785 /node/Node.cpp
parentf038ed9ca2f3e65e063571e77cd48f1072f2d3e3 (diff)
parent68defd998008e83e5348d29cab5535dab3d444e8 (diff)
downloadinfinitytier-54d1b11b1981481ba177c8f7c84c179977f5652d.tar.gz
infinitytier-54d1b11b1981481ba177c8f7c84c179977f5652d.zip
Merge branch 'adamierymenko-dev'
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index fe8cfb18..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 <Windows.h>
@@ -182,6 +183,11 @@ unsigned long Node::LocalClient::send(const char *command)
}
}
+std::vector<std::string> Node::LocalClient::splitLine(const char *line)
+{
+ return Utils::split(line," ","\\","\"");
+}
+
struct _NodeImpl
{
RuntimeEnvironment renv;
@@ -205,6 +211,7 @@ struct _NodeImpl
#ifndef __WINDOWS__
delete renv.netconfService;
#endif
+ delete renv.updater;
delete renv.nc;
delete renv.sysEnv;
delete renv.topology;
@@ -424,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)) {
@@ -462,6 +473,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
@@ -471,6 +483,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;
@@ -610,15 +629,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" {