Write a zerotier-one.port file to the home path to make CLI easy to write, and do a backward compatiable CLI in bash instead of as part of the executable.

This commit is contained in:
Adam Ierymenko 2015-04-15 19:38:01 -07:00
parent 21a7e774bb
commit 4e5d2d2c72
5 changed files with 10 additions and 31 deletions

26
one.cpp
View file

@ -75,18 +75,6 @@ using namespace ZeroTier;
static OneService *volatile zt1Service = (OneService *)0;
/****************************************************************************/
/* zerotier-cli personality */
/****************************************************************************/
#ifdef __WINDOWS__
int cli(int argc, _TCHAR* argv[])
#else
int cli(int argc,char **argv)
#endif
{
}
/****************************************************************************/
/* zerotier-idtool personality */
/****************************************************************************/
@ -435,7 +423,7 @@ static void printHelp(const char *cn,FILE *out)
{
fprintf(out,"ZeroTier One version %d.%d.%d"ZT_EOL_S"(c)2011-2015 ZeroTier, Inc."ZT_EOL_S,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION);
fprintf(out,"Licensed under the GNU General Public License v3"ZT_EOL_S""ZT_EOL_S);
fprintf(out,"Usage: %s [-switches] [home directory] [-q <query>]"ZT_EOL_S""ZT_EOL_S,cn);
fprintf(out,"Usage: %s [-switches] [home directory]"ZT_EOL_S""ZT_EOL_S,cn);
fprintf(out,"Available switches:"ZT_EOL_S);
fprintf(out," -h - Display this help"ZT_EOL_S);
fprintf(out," -v - Show version"ZT_EOL_S);
@ -444,7 +432,6 @@ static void printHelp(const char *cn,FILE *out)
#ifdef __UNIX_LIKE__
fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)"ZT_EOL_S);
#endif // __UNIX_LIKE__
fprintf(out," -q - Send a query to a running service (zerotier-cli)"ZT_EOL_S);
fprintf(out," -i - Generate and manage identities (zerotier-idtool)"ZT_EOL_S);
#ifdef __WINDOWS__
fprintf(out," -C - Run from command line instead of as service (Windows)"ZT_EOL_S);
@ -495,8 +482,6 @@ int main(int argc,char **argv)
#endif
#endif // __WINDOWS__
if ((strstr(argv[0],"zerotier-cli"))||(strstr(argv[0],"ZEROTIER-CLI")))
return cli(argc,argv);
if ((strstr(argv[0],"zerotier-idtool"))||(strstr(argv[0],"ZEROTIER-IDTOOL")))
return idtool(argc,argv);
@ -516,9 +501,6 @@ int main(int argc,char **argv)
}
break;
case 't': // TCP port -- ignore, since we now bind to both UDP and TCP on the same port
break;
#ifdef __UNIX_LIKE__
case 'd': // Run in background as daemon
runAsDaemon = true;
@ -541,12 +523,6 @@ int main(int argc,char **argv)
printf("%d.%d.%d"ZT_EOL_S,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION);
return 0;
case 'q': // Invoke cli personality
if (argv[i][2]) {
printHelp(argv[0],stdout);
return 0;
} else return cli(argc,argv);
case 'i': // Invoke idtool personality
if (argv[i][2]) {
printHelp(argv[0],stdout);