diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-01 17:32:37 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-08-01 17:32:37 -0400 |
commit | 741642ba531e487c18c8139c4a2e9510eed0466d (patch) | |
tree | 8722e1ca4d49dcb74be2429bdbe65b396aeed7c2 /node | |
parent | 8d30d51cf3925007a4f773928b62269836228b44 (diff) | |
download | infinitytier-741642ba531e487c18c8139c4a2e9510eed0466d.tar.gz infinitytier-741642ba531e487c18c8139c4a2e9510eed0466d.zip |
netconf service work
Diffstat (limited to 'node')
-rw-r--r-- | node/Node.cpp | 21 | ||||
-rw-r--r-- | node/RuntimeEnvironment.hpp | 9 | ||||
-rw-r--r-- | node/Service.hpp | 6 | ||||
-rw-r--r-- | node/Utils.hpp | 9 |
4 files changed, 44 insertions, 1 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 9c748b4a..e67dd526 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -67,6 +67,7 @@ #include "Mutex.hpp" #include "Multicaster.hpp" #include "CMWC4096.hpp" +#include "Service.hpp" #include "../version.h" @@ -191,6 +192,10 @@ struct _NodeImpl } }; +static void _netconfServiceMessageHandler(void *renv,Service &svc,const Dictionary &msg) +{ +} + Node::Node(const char *hp) throw() : _impl(new _NodeImpl) @@ -209,6 +214,10 @@ Node::~Node() { _NodeImpl *impl = (_NodeImpl *)_impl; +#ifndef __WINDOWS__ + delete impl->renv.netconfService; +#endif + delete impl->renv.sysEnv; delete impl->renv.topology; delete impl->renv.sw; @@ -337,6 +346,18 @@ Node::ReasonForTermination Node::run() return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"unknown exception during initialization"); } +#ifndef __WINDOWS__ + try { + std::string netconfServicePath(_r->homePath + ZT_PATH_SEPARATOR_S + "services.d" + ZT_PATH_SEPARATOR_S + "netconf.service"); + if (Utils::fileExists(netconfServicePath.c_str())) { + LOG("netconf.d/netconfi.service appears to exist, starting..."); + _r->netconfService = new Service(_r,"netconf",netconfServicePath.c_str(),&_netconfServiceMessageHandler,_r); + } + } catch ( ... ) { + LOG("unexpected exception attempting to start services"); + } +#endif + try { uint64_t lastPingCheck = 0; uint64_t lastClean = Utils::now(); // don't need to do this immediately diff --git a/node/RuntimeEnvironment.hpp b/node/RuntimeEnvironment.hpp index 7797e651..00d393af 100644 --- a/node/RuntimeEnvironment.hpp +++ b/node/RuntimeEnvironment.hpp @@ -29,6 +29,7 @@ #define _ZT_RUNTIMEENVIRONMENT_HPP #include <string> +#include "Constants.hpp" #include "Identity.hpp" #include "Condition.hpp" @@ -42,6 +43,7 @@ class Topology; class SysEnv; class Multicaster; class CMWC4096; +class Service; /** * Holds global state for an instance of ZeroTier::Node @@ -67,6 +69,9 @@ public: sw((Switch *)0), topology((Topology *)0), sysEnv((SysEnv *)0) +#ifndef __WINDOWS__ + ,netconfService((Service *)0) +#endif { } @@ -88,6 +93,10 @@ public: Switch *sw; Topology *topology; SysEnv *sysEnv; + +#ifndef __WINDOWS__ + Service *netconfService; // may be null +#endif }; } // namespace ZeroTier diff --git a/node/Service.hpp b/node/Service.hpp index 8b9407e7..c8b729c7 100644 --- a/node/Service.hpp +++ b/node/Service.hpp @@ -72,7 +72,11 @@ public: * @param handler Handler function to call when service generates output * @param arg First argument to service */ - Service(const RuntimeEnvironment *renv,const char *name,const char *path,void (*handler)(void *,Service &,const Dictionary &),void *arg); + Service(const RuntimeEnvironment *renv, + const char *name, + const char *path, + void (*handler)(void *,Service &,const Dictionary &), + void *arg); virtual ~Service(); diff --git a/node/Utils.hpp b/node/Utils.hpp index de7acf0e..a222ca4f 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -120,6 +120,15 @@ public: static uint64_t getLastModified(const char *path); /** + * @param path Path to check + * @return True if file or directory exists at path location + */ + static inline bool fileExists(const char *path) + { + return (getLastModified(path) != 0); + } + + /** * @param t64 Time in ms since epoch * @return RFC1123 date string */ |