summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-04-02 17:12:04 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-04-02 17:12:04 -0700
commitf0223490becc9bba82297cd6316c87d2f89f2052 (patch)
treec8ceec0a71c3953377c463a6a2844c4c96622560 /node/Node.cpp
parent81e56904104c45beb17e574eb1691a864cd91bb2 (diff)
downloadinfinitytier-f0223490becc9bba82297cd6316c87d2f89f2052.tar.gz
infinitytier-f0223490becc9bba82297cd6316c87d2f89f2052.zip
Make GUI work with new control client API, make control client look for user authtoken.secret if system unreadable.
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index 051cb317..f9a0a614 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -109,27 +109,30 @@ Node::NodeControlClient::NodeControlClient(const char *hp,void (*resultHandler)(
std::string at;
if (authToken)
at = authToken;
- else if (!Utils::readFile((std::string(hp) + ZT_PATH_SEPARATOR_S + "authtoken.secret").c_str(),at))
- impl->err = "no authentication token specified and authtoken.secret not readable";
- else {
- std::string myid;
- if (Utils::readFile((std::string(hp) + ZT_PATH_SEPARATOR_S + "identity.public").c_str(),myid)) {
- std::string myaddr(myid.substr(0,myid.find(':')));
- if (myaddr.length() != 10)
- impl->err = "invalid address extracted from identity.public";
- else {
- try {
- impl->resultHandler = resultHandler;
- impl->arg = arg;
- impl->ipcc = new IpcConnection((std::string(ZT_IPC_ENDPOINT_BASE) + myaddr).c_str(),&_CBipcResultHandler,_impl);
- impl->ipcc->printf("auth %s"ZT_EOL_S,at.c_str());
- } catch ( ... ) {
- impl->ipcc = (IpcConnection *)0;
- impl->err = "failure connecting to running ZeroTier One service";
- }
- }
- } else impl->err = "unable to read identity.public";
+ else if (!Utils::readFile(authTokenDefaultSystemPath(),at)) {
+ if (!Utils::readFile(authTokenDefaultUserPath(),at)) {
+ impl->err = "no authentication token specified and authtoken.secret not readable";
+ return;
+ }
}
+
+ std::string myid;
+ if (Utils::readFile((std::string(hp) + ZT_PATH_SEPARATOR_S + "identity.public").c_str(),myid)) {
+ std::string myaddr(myid.substr(0,myid.find(':')));
+ if (myaddr.length() != 10)
+ impl->err = "invalid address extracted from identity.public";
+ else {
+ try {
+ impl->resultHandler = resultHandler;
+ impl->arg = arg;
+ impl->ipcc = new IpcConnection((std::string(ZT_IPC_ENDPOINT_BASE) + myaddr).c_str(),&_CBipcResultHandler,_impl);
+ impl->ipcc->printf("auth %s"ZT_EOL_S,at.c_str());
+ } catch ( ... ) {
+ impl->ipcc = (IpcConnection *)0;
+ impl->err = "failure connecting to running ZeroTier One service";
+ }
+ }
+ } else impl->err = "unable to read identity.public";
}
Node::NodeControlClient::~NodeControlClient()