summaryrefslogtreecommitdiff
path: root/node/NodeConfig.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-02-10 14:22:57 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-02-10 14:22:57 -0800
commitcd339486b70d8d43ea9fd64c764e63c65730f4cb (patch)
treec112a799db93c9cc6f12cc633ed8c0b0b728c957 /node/NodeConfig.cpp
parente54a34d8dd3f725ed86b690bfd74eab5cd1257db (diff)
downloadinfinitytier-cd339486b70d8d43ea9fd64c764e63c65730f4cb.tar.gz
infinitytier-cd339486b70d8d43ea9fd64c764e63c65730f4cb.zip
local.conf in NodeConfig
Diffstat (limited to 'node/NodeConfig.cpp')
-rw-r--r--node/NodeConfig.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp
index acdcd49d..ea2b5946 100644
--- a/node/NodeConfig.cpp
+++ b/node/NodeConfig.cpp
@@ -109,10 +109,13 @@ NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsi
LOG("unable to create network %.16llx: (unknown exception)",(unsigned long long)*nwid);
}
}
+
+ _readLocalConfig();
}
NodeConfig::~NodeConfig()
{
+ _writeLocalConfig();
}
void NodeConfig::clean()
@@ -122,6 +125,9 @@ void NodeConfig::clean()
n->second->clean();
}
+/////////////////////////////////////////////////////////////////////////////
+// UDP localhost control bus
+
// Macro used in execute() to push lines onto the return packet
#undef _P
#define _P(f,...) { r.push_back(std::string()); Utils::stdsprintf(r.back(),(f),##__VA_ARGS__); }
@@ -389,4 +395,21 @@ void NodeConfig::_CBcontrolPacketHandler(UdpSocket *sock,void *arg,const InetAdd
}
}
+/////////////////////////////////////////////////////////////////////////////
+
+void NodeConfig::_readLocalConfig()
+{
+ std::string localDotConf(_r->homePath + ZT_PATH_SEPARATOR_S + "local.conf");
+ std::string buf;
+ if (Utils::readFile(localDotConf.c_str(),buf)) {
+ Mutex::Lock _l(_localConfig_m);
+ _localConfig.fromString(buf.c_str());
+ }
+}
+
+void NodeConfig::_writeLocalConfig()
+{
+ Utils::writeFile(((_r->homePath + ZT_PATH_SEPARATOR_S + "local.conf")).c_str(),_localConfig.toString());
+}
+
} // namespace ZeroTier