|
@@ -75,6 +75,9 @@
|
|
#include "control/NodeControlClient.hpp"
|
|
#include "control/NodeControlClient.hpp"
|
|
#include "control/NodeControlService.hpp"
|
|
#include "control/NodeControlService.hpp"
|
|
|
|
|
|
|
|
+#include "testnet/TestEthernetTapFactory.hpp"
|
|
|
|
+#include "testnet/TestRoutingTable.hpp"
|
|
|
|
+
|
|
#ifdef __WINDOWS__
|
|
#ifdef __WINDOWS__
|
|
#include "osnet/WindowsEthernetTapFactory.hpp"
|
|
#include "osnet/WindowsEthernetTapFactory.hpp"
|
|
#include "osnet/WindowsRoutingTable.hpp"
|
|
#include "osnet/WindowsRoutingTable.hpp"
|
|
@@ -564,6 +567,8 @@ static void printHelp(const char *cn,FILE *out)
|
|
fprintf(out," -v - Show version"ZT_EOL_S);
|
|
fprintf(out," -v - Show version"ZT_EOL_S);
|
|
fprintf(out," -p<port> - Port for UDP (default: 9993)"ZT_EOL_S);
|
|
fprintf(out," -p<port> - Port for UDP (default: 9993)"ZT_EOL_S);
|
|
fprintf(out," -t<port> - Port for TCP (default: disabled)"ZT_EOL_S);
|
|
fprintf(out," -t<port> - Port for TCP (default: disabled)"ZT_EOL_S);
|
|
|
|
+ fprintf(out," -T<path> - Override root topology, do not authenticate or update"ZT_EOL_S);
|
|
|
|
+ fprintf(out," -u - Do not require root, use dummy tap device"ZT_EOL_S);
|
|
#ifdef __UNIX_LIKE__
|
|
#ifdef __UNIX_LIKE__
|
|
fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)"ZT_EOL_S);
|
|
fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)"ZT_EOL_S);
|
|
#endif
|
|
#endif
|
|
@@ -619,6 +624,8 @@ int main(int argc,char **argv)
|
|
unsigned int udpPort = ZT_DEFAULT_UDP_PORT;
|
|
unsigned int udpPort = ZT_DEFAULT_UDP_PORT;
|
|
unsigned int tcpPort = 0;
|
|
unsigned int tcpPort = 0;
|
|
|
|
|
|
|
|
+ std::string overrideRootTopology;
|
|
|
|
+ bool userMode = false;
|
|
#ifdef __UNIX_LIKE__
|
|
#ifdef __UNIX_LIKE__
|
|
bool runAsDaemon = false;
|
|
bool runAsDaemon = false;
|
|
#endif
|
|
#endif
|
|
@@ -652,6 +659,20 @@ int main(int argc,char **argv)
|
|
runAsDaemon = true;
|
|
runAsDaemon = true;
|
|
break;
|
|
break;
|
|
#endif
|
|
#endif
|
|
|
|
+ case 'T':
|
|
|
|
+ if (argv[i][2]) {
|
|
|
|
+ if (!Utils::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 'u':
|
|
|
|
+ userMode = true;
|
|
|
|
+ break;
|
|
case 'v':
|
|
case 'v':
|
|
printf("%s"ZT_EOL_S,Node::versionString());
|
|
printf("%s"ZT_EOL_S,Node::versionString());
|
|
return 0;
|
|
return 0;
|
|
@@ -728,7 +749,7 @@ int main(int argc,char **argv)
|
|
homeDir = ZT_DEFAULTS.defaultHomePath.c_str();
|
|
homeDir = ZT_DEFAULTS.defaultHomePath.c_str();
|
|
|
|
|
|
#ifdef __UNIX_LIKE__
|
|
#ifdef __UNIX_LIKE__
|
|
- if (getuid() != 0) {
|
|
|
|
|
|
+ if ((!userMode)&&(getuid() != 0)) {
|
|
fprintf(stderr,"%s: must be run as root (uid 0)\n",argv[0]);
|
|
fprintf(stderr,"%s: must be run as root (uid 0)\n",argv[0]);
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
@@ -758,17 +779,18 @@ int main(int argc,char **argv)
|
|
#endif // __UNIX_LIKE__
|
|
#endif // __UNIX_LIKE__
|
|
|
|
|
|
#ifdef __WINDOWS__
|
|
#ifdef __WINDOWS__
|
|
- _winPokeAHole();
|
|
|
|
if (winRunFromCommandLine) {
|
|
if (winRunFromCommandLine) {
|
|
// Running in "interactive" mode (mostly for debugging)
|
|
// Running in "interactive" mode (mostly for debugging)
|
|
- if (IsCurrentUserLocalAdministrator() != TRUE) {
|
|
|
|
|
|
+ if ((!userMode)&&(IsCurrentUserLocalAdministrator() != TRUE)) {
|
|
fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]);
|
|
fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]);
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
+ _winPokeAHole();
|
|
SetConsoleCtrlHandler(&_winConsoleCtrlHandler,TRUE);
|
|
SetConsoleCtrlHandler(&_winConsoleCtrlHandler,TRUE);
|
|
// continues on to ordinary command line execution code below...
|
|
// continues on to ordinary command line execution code below...
|
|
} else {
|
|
} else {
|
|
// Running from service manager
|
|
// Running from service manager
|
|
|
|
+ _winPokeAHole();
|
|
ZeroTierOneService zt1Service;
|
|
ZeroTierOneService zt1Service;
|
|
if (CServiceBase::Run(zt1Service) == TRUE) {
|
|
if (CServiceBase::Run(zt1Service) == TRUE) {
|
|
return 0;
|
|
return 0;
|
|
@@ -791,8 +813,13 @@ int main(int argc,char **argv)
|
|
// succeed unless something is wrong with the filesystem.
|
|
// succeed unless something is wrong with the filesystem.
|
|
std::string authToken(NodeControlClient::getAuthToken((std::string(homeDir) + ZT_PATH_SEPARATOR_S + "authtoken.secret").c_str(),true));
|
|
std::string authToken(NodeControlClient::getAuthToken((std::string(homeDir) + ZT_PATH_SEPARATOR_S + "authtoken.secret").c_str(),true));
|
|
|
|
|
|
- tapFactory = ZTCreatePlatformEthernetTapFactory;
|
|
|
|
- routingTable = ZTCreatePlatformRoutingTable;
|
|
|
|
|
|
+ if (userMode) {
|
|
|
|
+ tapFactory = new TestEthernetTapFactory();
|
|
|
|
+ routingTable = new TestRoutingTable();
|
|
|
|
+ } else {
|
|
|
|
+ tapFactory = ZTCreatePlatformEthernetTapFactory;
|
|
|
|
+ routingTable = ZTCreatePlatformRoutingTable;
|
|
|
|
+ }
|
|
|
|
|
|
node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset);
|
|
node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset);
|
|
controlService = new NodeControlService(node,authToken.c_str());
|
|
controlService = new NodeControlService(node,authToken.c_str());
|