mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Make TCP optional, rename port constant.
This commit is contained in:
parent
73c1d43f2f
commit
181369964f
4 changed files with 21 additions and 12 deletions
19
main.cpp
19
main.cpp
|
@ -93,7 +93,8 @@ static void printHelp(const char *cn,FILE *out)
|
||||||
fprintf(out,"Available switches:"ZT_EOL_S);
|
fprintf(out,"Available switches:"ZT_EOL_S);
|
||||||
fprintf(out," -h - Display this help"ZT_EOL_S);
|
fprintf(out," -h - Display this help"ZT_EOL_S);
|
||||||
fprintf(out," -v - Show version"ZT_EOL_S);
|
fprintf(out," -v - Show version"ZT_EOL_S);
|
||||||
fprintf(out," -p<port> - Bind to this port for network I/O"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);
|
||||||
#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
|
||||||
|
@ -473,7 +474,8 @@ int main(int argc,char **argv)
|
||||||
return ZeroTierIdTool::main(argc,argv);
|
return ZeroTierIdTool::main(argc,argv);
|
||||||
|
|
||||||
const char *homeDir = (const char *)0;
|
const char *homeDir = (const char *)0;
|
||||||
unsigned int port = 0;
|
unsigned int udpPort = ZT_DEFAULT_UDP_PORT;
|
||||||
|
unsigned int tcpPort = 0;
|
||||||
#ifdef __UNIX_LIKE__
|
#ifdef __UNIX_LIKE__
|
||||||
bool runAsDaemon = false;
|
bool runAsDaemon = false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -484,8 +486,15 @@ int main(int argc,char **argv)
|
||||||
if (argv[i][0] == '-') {
|
if (argv[i][0] == '-') {
|
||||||
switch(argv[i][1]) {
|
switch(argv[i][1]) {
|
||||||
case 'p':
|
case 'p':
|
||||||
port = Utils::strToUInt(argv[i] + 2);
|
udpPort = Utils::strToUInt(argv[i] + 2);
|
||||||
if (port > 65535) {
|
if (udpPort > 65535) {
|
||||||
|
printHelp(argv[0],stdout);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
tcpPort = Utils::strToUInt(argv[i] + 2);
|
||||||
|
if (tcpPort > 65535) {
|
||||||
printHelp(argv[0],stdout);
|
printHelp(argv[0],stdout);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -626,7 +635,7 @@ int main(int argc,char **argv)
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
bool needsReset = false;
|
bool needsReset = false;
|
||||||
try {
|
try {
|
||||||
node = new Node(homeDir,port,port,needsReset);
|
node = new Node(homeDir,udpPort,tcpPort,needsReset);
|
||||||
switch(node->run()) {
|
switch(node->run()) {
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
case Node::NODE_RESTART_FOR_UPGRADE: {
|
case Node::NODE_RESTART_FOR_UPGRADE: {
|
||||||
|
|
|
@ -114,9 +114,9 @@ error_no_byte_order_defined;
|
||||||
#define ZT_ADDRESS_RESERVED_PREFIX 0xff
|
#define ZT_ADDRESS_RESERVED_PREFIX 0xff
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default local port for ZeroTier traffic
|
* Default local port for ZeroTier UDP traffic
|
||||||
*/
|
*/
|
||||||
#define ZT_DEFAULT_PORT 9993
|
#define ZT_DEFAULT_UDP_PORT 9993
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default payload MTU for UDP packets
|
* Default payload MTU for UDP packets
|
||||||
|
|
|
@ -377,8 +377,8 @@ Node::Node(const char *hp,unsigned int udpPort,unsigned int tcpPort,bool resetId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->udpPort = ((udpPort > 0)&&(udpPort <= 0xffff)) ? udpPort : (unsigned int)ZT_DEFAULT_PORT;
|
impl->udpPort = udpPort & 0xffff;
|
||||||
impl->tcpPort = ((tcpPort > 0)&&(tcpPort <= 0xffff)) ? tcpPort : (unsigned int)ZT_DEFAULT_PORT;
|
impl->tcpPort = tcpPort & 0xffff;
|
||||||
impl->reasonForTermination = Node::NODE_RUNNING;
|
impl->reasonForTermination = Node::NODE_RUNNING;
|
||||||
impl->started = false;
|
impl->started = false;
|
||||||
impl->running = false;
|
impl->running = false;
|
||||||
|
|
|
@ -153,11 +153,11 @@ public:
|
||||||
* The node is not executed until run() is called.
|
* The node is not executed until run() is called.
|
||||||
*
|
*
|
||||||
* @param hp Home directory path or NULL for system-wide default for this platform (default: NULL)
|
* @param hp Home directory path or NULL for system-wide default for this platform (default: NULL)
|
||||||
* @param udpPort UDP port or 0 for default (9993) (default: 0)
|
* @param udpPort UDP port or 0 to disable (default: 9993)
|
||||||
* @param tcpPort TCP port or 0 for default (9993) (default: 0)
|
* @param tcpPort TCP port or 0 to disable (default: 0)
|
||||||
* @param resetIdentity If true, delete identity before starting and regenerate (default: false)
|
* @param resetIdentity If true, delete identity before starting and regenerate (default: false)
|
||||||
*/
|
*/
|
||||||
Node(const char *hp = (const char *)0,unsigned int udpPort = 0,unsigned int tcpPort = 0,bool resetIdentity = false)
|
Node(const char *hp = (const char *)0,unsigned int udpPort = 9993,unsigned int tcpPort = 0,bool resetIdentity = false)
|
||||||
throw();
|
throw();
|
||||||
|
|
||||||
~Node();
|
~Node();
|
||||||
|
|
Loading…
Add table
Reference in a new issue