diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-07-25 17:53:57 -0400 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-07-25 17:53:57 -0400 |
commit | 57d8730f1b3da3f9fe23a9fa02c8557b80bf6716 (patch) | |
tree | 3ac70dfd9d3ecabcb90a18b2aff4a5a2e5d43db4 /node/Node.cpp | |
parent | af8fcac0fcfd64600a442dc4d633601e29e611ea (diff) | |
download | infinitytier-57d8730f1b3da3f9fe23a9fa02c8557b80bf6716.tar.gz infinitytier-57d8730f1b3da3f9fe23a9fa02c8557b80bf6716.zip |
Wire up RPC plugin loading to Node.
Diffstat (limited to 'node/Node.cpp')
-rw-r--r-- | node/Node.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 08b08fc1..b5c23ed9 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -68,6 +68,7 @@ #include "Mutex.hpp" #include "Multicaster.hpp" #include "CMWC4096.hpp" +#include "RPC.hpp" #include "../version.h" @@ -210,6 +211,7 @@ Node::~Node() { _NodeImpl *impl = (_NodeImpl *)_impl; + delete impl->renv.rpc; delete impl->renv.sysEnv; delete impl->renv.topology; delete impl->renv.sw; @@ -315,6 +317,7 @@ Node::ReasonForTermination Node::run() _r->sw = new Switch(_r); _r->topology = new Topology(_r,(_r->homePath + ZT_PATH_SEPARATOR_S + "peer.db").c_str()); _r->sysEnv = new SysEnv(_r); + _r->rpc = new RPC(_r); // TODO: make configurable bool boundPort = false; @@ -339,6 +342,25 @@ Node::ReasonForTermination Node::run() } try { + std::map<std::string,bool> pluginsd(Utils::listDirectory((_r->homePath + ZT_PATH_SEPARATOR_S + "plugins.d").c_str())); + for(std::map<std::string,bool>::iterator ppath(pluginsd.begin());ppath!=pluginsd.end();++ppath) { + if (!ppath->second) { + try { + std::string funcName(ppath->first.substr(0,ppath->first.rfind('.'))); + LOG("loading plugins.d/%s as RPC function %s",ppath->first.c_str(),funcName.c_str()); + _r->rpc->loadLocal(funcName.c_str(),(_r->homePath + ZT_PATH_SEPARATOR_S + "plugins.d" + ZT_PATH_SEPARATOR_S + ppath->first).c_str()); + } catch (std::exception &exc) { + LOG("failed to load plugin plugins.d/%s: %s",ppath->first.c_str(),exc.what()); + } catch ( ... ) { + LOG("failed to load plugin plugins.d/%s: (unknown exception)",ppath->first.c_str()); + } + } + } + } catch ( ... ) { + TRACE("unknown exception attempting to enumerate and load plugins"); + } + + try { uint64_t lastPingCheck = 0; uint64_t lastTopologyClean = Utils::now(); // don't need to do this immediately uint64_t lastNetworkFingerprintCheck = 0; |