mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-03-22 12:05:55 +00:00
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:
parent
21a7e774bb
commit
4e5d2d2c72
@ -60,7 +60,6 @@ all: one
|
||||
one: $(OBJS) one.o
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
|
||||
$(STRIP) zerotier-one
|
||||
ln -sf zerotier-one zerotier-cli
|
||||
ln -sf zerotier-one zerotier-idtool
|
||||
|
||||
selftest: $(OBJS) selftest.o
|
||||
@ -72,7 +71,7 @@ selftest: $(OBJS) selftest.o
|
||||
# ./buildinstaller.sh
|
||||
|
||||
clean:
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o build-* zerotier-* ZeroTierOneInstaller-*
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o build-* zerotier-one zerotier-idtool zerotier-selftest ZeroTierOneInstaller-*
|
||||
|
||||
debug: FORCE
|
||||
make -j 4 ZT_DEBUG=1
|
||||
|
@ -66,7 +66,6 @@ all: one
|
||||
one: $(OBJS) one.o
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
|
||||
$(STRIP) zerotier-one
|
||||
ln -sf zerotier-one zerotier-cli
|
||||
ln -sf zerotier-one zerotier-idtool
|
||||
|
||||
selftest: $(OBJS) selftest.o
|
||||
@ -77,7 +76,7 @@ installer: one FORCE
|
||||
./buildinstaller.sh
|
||||
|
||||
clean:
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* build-* ZeroTierOneInstaller-* *.deb *.rpm
|
||||
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-one zerotier-idtool zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm
|
||||
|
||||
debug: FORCE
|
||||
make -j 4 ZT_DEBUG=1
|
||||
|
@ -55,7 +55,6 @@ all: one
|
||||
one: $(OBJS) one.o
|
||||
$(CXX) $(CXXFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
|
||||
$(STRIP) zerotier-one
|
||||
ln -sf zerotier-one zerotier-cli
|
||||
ln -sf zerotier-one zerotier-idtool
|
||||
|
||||
selftest: $(OBJS) selftest.o
|
||||
@ -76,7 +75,7 @@ selftest: $(OBJS) selftest.o
|
||||
# $(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app"
|
||||
|
||||
clean:
|
||||
rm -rf *.dSYM build-* *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* ZeroTierOneInstaller-*
|
||||
rm -rf *.dSYM build-* *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-one zerotier-idtool zerotier-selftest ZeroTierOneInstaller-*
|
||||
|
||||
# For our use -- builds official signed binary, packages in installer and download DMG
|
||||
official: FORCE
|
||||
|
26
one.cpp
26
one.cpp
@ -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);
|
||||
|
@ -131,6 +131,7 @@ class OneServiceImpl : public OneService
|
||||
public:
|
||||
OneServiceImpl(const char *hp,unsigned int port,NetworkController *master,const char *overrideRootTopology) :
|
||||
_homePath((hp) ? hp : "."),
|
||||
_port(port),
|
||||
_phy(this,true),
|
||||
_master(master),
|
||||
_overrideRootTopology((overrideRootTopology) ? overrideRootTopology : ""),
|
||||
@ -160,6 +161,10 @@ public:
|
||||
in6.sin6_port = in4.sin_port;
|
||||
_v6UdpSocket = _phy.udpBind((const struct sockaddr *)&in6,this,131072);
|
||||
_v6TcpListenSocket = _phy.tcpListen((const struct sockaddr *)&in6,this);
|
||||
|
||||
char portstr[64];
|
||||
Utils::snprintf(portstr,sizeof(portstr),"%u",port);
|
||||
OSUtils::writeFile((_homePath + ZT_PATH_SEPARATOR_S + "zerotier-one.port").c_str(),std::string(portstr));
|
||||
}
|
||||
|
||||
virtual ~OneServiceImpl()
|
||||
@ -632,6 +637,7 @@ private:
|
||||
}
|
||||
|
||||
const std::string _homePath;
|
||||
unsigned int _port;
|
||||
Phy<OneServiceImpl *> _phy;
|
||||
NetworkController *_master;
|
||||
std::string _overrideRootTopology;
|
||||
|
Loading…
x
Reference in New Issue
Block a user