summaryrefslogtreecommitdiff
path: root/one.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-23 10:46:52 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-23 10:46:52 -0800
commita18336fa1899a9f53b161a60e766695007c49a7b (patch)
treef464c0475ea49e3714df86d69508644adcf2e98a /one.cpp
parent1e4a40e77205b028d799f7112127f3f2f107117e (diff)
parent764dd1c3d94527c0870a913ac314b3b17eaea282 (diff)
downloadinfinitytier-a18336fa1899a9f53b161a60e766695007c49a7b.tar.gz
infinitytier-a18336fa1899a9f53b161a60e766695007c49a7b.zip
MERGE current "dev" into "netcon" -- should not affect netcon itself but will retest -- brings ZeroTier core up to 1.1.0
Diffstat (limited to 'one.cpp')
-rw-r--r--one.cpp72
1 files changed, 26 insertions, 46 deletions
diff --git a/one.cpp b/one.cpp
index a4d5190c..685034df 100644
--- a/one.cpp
+++ b/one.cpp
@@ -911,7 +911,6 @@ static void printHelp(const char *cn,FILE *out)
fprintf(out," -v - Show version"ZT_EOL_S);
fprintf(out," -U - Run as unprivileged user (skip privilege check)"ZT_EOL_S);
fprintf(out," -p<port> - Port for UDP and TCP/HTTP (default: 9993, 0 for random)"ZT_EOL_S);
- //fprintf(out," -T<path> - Override root topology, do not authenticate or update"ZT_EOL_S);
#ifdef __UNIX_LIKE__
fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)"ZT_EOL_S);
@@ -959,8 +958,10 @@ int main(int argc,char **argv)
#endif // __UNIX_LIKE__
#ifdef __WINDOWS__
- WSADATA wsaData;
- WSAStartup(MAKEWORD(2,2),&wsaData);
+ {
+ WSADATA wsaData;
+ WSAStartup(MAKEWORD(2,2),&wsaData);
+ }
#ifdef ZT_WIN_RUN_IN_CONSOLE
bool winRunFromCommandLine = true;
@@ -974,7 +975,6 @@ int main(int argc,char **argv)
if ((strstr(argv[0],"zerotier-cli"))||(strstr(argv[0],"ZEROTIER-CLI")))
return cli(argc,argv);
- std::string overrideRootTopology;
std::string homeDir;
unsigned int port = ZT_DEFAULT_PORT;
bool skipRootCheck = false;
@@ -1001,18 +1001,6 @@ int main(int argc,char **argv)
skipRootCheck = true;
break;
- case 'T': // Override root topology
- if (argv[i][2]) {
- if (!OSUtils::readFile(argv[i] + 2,overrideRootTopology)) {
- fprintf(stderr,"%s: cannot read root topology from %s"ZT_EOL_S,argv[0],argv[i] + 2);
- return 1;
- }
- } else {
- printHelp(argv[0],stdout);
- return 1;
- }
- break;
-
case 'v': // Display version
printf("%d.%d.%d"ZT_EOL_S,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION);
return 0;
@@ -1167,37 +1155,29 @@ int main(int argc,char **argv)
unsigned int returnValue = 0;
- try {
- for(;;) {
- zt1Service = OneService::newInstance(homeDir.c_str(),port,(overrideRootTopology.length() > 0) ? overrideRootTopology.c_str() : (const char *)0);
- switch(zt1Service->run()) {
- case OneService::ONE_STILL_RUNNING: // shouldn't happen, run() won't return until done
- case OneService::ONE_NORMAL_TERMINATION:
- break;
- case OneService::ONE_UNRECOVERABLE_ERROR:
- fprintf(stderr,"%s: fatal error: %s"ZT_EOL_S,argv[0],zt1Service->fatalErrorMessage().c_str());
- returnValue = 1;
- break;
- case OneService::ONE_IDENTITY_COLLISION: {
- delete zt1Service;
- zt1Service = (OneService *)0;
- std::string oldid;
- OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),oldid);
- if (oldid.length()) {
- OSUtils::writeFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret.saved_after_collision").c_str(),oldid);
- OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str());
- OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str());
- }
- } continue; // restart!
- }
- break; // terminate loop -- normally we don't keep restarting
+ for(;;) {
+ zt1Service = OneService::newInstance(homeDir.c_str(),port);
+ switch(zt1Service->run()) {
+ case OneService::ONE_STILL_RUNNING: // shouldn't happen, run() won't return until done
+ case OneService::ONE_NORMAL_TERMINATION:
+ break;
+ case OneService::ONE_UNRECOVERABLE_ERROR:
+ fprintf(stderr,"%s: fatal error: %s"ZT_EOL_S,argv[0],zt1Service->fatalErrorMessage().c_str());
+ returnValue = 1;
+ break;
+ case OneService::ONE_IDENTITY_COLLISION: {
+ delete zt1Service;
+ zt1Service = (OneService *)0;
+ std::string oldid;
+ OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),oldid);
+ if (oldid.length()) {
+ OSUtils::writeFile((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret.saved_after_collision").c_str(),oldid);
+ OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.secret").c_str());
+ OSUtils::rm((homeDir + ZT_PATH_SEPARATOR_S + "identity.public").c_str());
+ }
+ } continue; // restart!
}
- } catch (std::exception &exc) {
- fprintf(stderr,"%s: fatal error: %s"ZT_EOL_S,argv[0],exc.what());
- returnValue = 1;
- } catch ( ... ) {
- fprintf(stderr,"%s: fatal error: unknown exception"ZT_EOL_S,argv[0]);
- returnValue = 1;
+ break; // terminate loop -- normally we don't keep restarting
}
delete zt1Service;