|
@ -160,7 +160,9 @@ static void help (int level) { |
|
|
" -c <community name>" |
|
|
" -c <community name>" |
|
|
" -l <supernode host:port>" |
|
|
" -l <supernode host:port>" |
|
|
"\n " |
|
|
"\n " |
|
|
"[-p <local port>] " |
|
|
"[-p [<local bind ip address>:]<local port>] " |
|
|
|
|
|
"\n " |
|
|
|
|
|
|
|
|
#ifdef __linux__ |
|
|
#ifdef __linux__ |
|
|
"[-T <type of service>] " |
|
|
"[-T <type of service>] " |
|
|
#endif |
|
|
#endif |
|
@ -168,15 +170,15 @@ static void help (int level) { |
|
|
"[-D] " |
|
|
"[-D] " |
|
|
#endif |
|
|
#endif |
|
|
"\n options for under- " |
|
|
"\n options for under- " |
|
|
"[-i <registration interval>]" |
|
|
"[-i <registration interval>] " |
|
|
"[-L <registration ttl>]" |
|
|
"[-L <registration ttl>] " |
|
|
"\n lying connection " |
|
|
"\n lying connection " |
|
|
"[-k <key>] " |
|
|
"[-k <key>] " |
|
|
"[-A<cipher>] " |
|
|
"[-A<cipher>] " |
|
|
"[-H] " |
|
|
"[-H] " |
|
|
"[-z<compression>]" |
|
|
"[-z<compression>] " |
|
|
"\n " |
|
|
"\n " |
|
|
"[-b <bind IP address>][-S<level of solitude>]" |
|
|
"[-S<level of solitude>] " |
|
|
"\n\n tap device and " |
|
|
"\n\n tap device and " |
|
|
"[-a [static:|dhcp:]<tap IP address>[/<cidr suffix>]] " |
|
|
"[-a [static:|dhcp:]<tap IP address>[/<cidr suffix>]] " |
|
|
"\n overlay network " |
|
|
"\n overlay network " |
|
@ -206,8 +208,8 @@ static void help (int level) { |
|
|
"[-n <cidr:gateway>] " |
|
|
"[-n <cidr:gateway>] " |
|
|
#ifndef WIN32 |
|
|
#ifndef WIN32 |
|
|
"\n " |
|
|
"\n " |
|
|
"[-u <numerical user id>]" |
|
|
"[-u <numerical user id>] " |
|
|
"[-g <numerical group id>]" |
|
|
"[-g <numerical group id>] " |
|
|
#endif |
|
|
#endif |
|
|
"\n\n environment " |
|
|
"\n\n environment " |
|
|
"N2N_KEY instead of [-k <key>]" |
|
|
"N2N_KEY instead of [-k <key>]" |
|
@ -243,7 +245,8 @@ static void help (int level) { |
|
|
printf (" ---------------------------------------------\n\n"); |
|
|
printf (" ---------------------------------------------\n\n"); |
|
|
printf(" -c <community> | n2n community name the edge belongs to\n"); |
|
|
printf(" -c <community> | n2n community name the edge belongs to\n"); |
|
|
printf(" -l <host:port> | supernode ip address or name, and port\n"); |
|
|
printf(" -l <host:port> | supernode ip address or name, and port\n"); |
|
|
printf(" -p <local port> | fixed local UDP port\n"); |
|
|
printf(" -p [<ip>:]<port> | fixed local UDP port and optionally bind to the\n" |
|
|
|
|
|
" | sepcified local IP address only (any by default)\n"); |
|
|
#ifdef __linux__ |
|
|
#ifdef __linux__ |
|
|
printf(" -T <tos> | TOS for packets, e.g. 0x48 for SSH like priority\n"); |
|
|
printf(" -T <tos> | TOS for packets, e.g. 0x48 for SSH like priority\n"); |
|
|
#endif |
|
|
#endif |
|
@ -251,8 +254,6 @@ static void help (int level) { |
|
|
printf(" -D | enable PMTU discovery, it can reduce fragmentation but\n" |
|
|
printf(" -D | enable PMTU discovery, it can reduce fragmentation but\n" |
|
|
" | causes connections to stall if not properly supported\n"); |
|
|
" | causes connections to stall if not properly supported\n"); |
|
|
#endif |
|
|
#endif |
|
|
printf(" -b <bind ip> | bind the edge to the provided local IP address only,\n" |
|
|
|
|
|
" | defaults to 'any' ip address if not provided\n"); |
|
|
|
|
|
printf(" -S1 ... -S2 | do not connect p2p, always use the supernode,\n" |
|
|
printf(" -S1 ... -S2 | do not connect p2p, always use the supernode,\n" |
|
|
" | -S1 = via UDP" |
|
|
" | -S1 = via UDP" |
|
|
|
|
|
|
|
@ -580,27 +581,34 @@ static int setOption (int optkey, char *optargument, n2n_tuntap_priv_config_t *e |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case 'p': { |
|
|
case 'p': { |
|
|
conf->local_port = atoi(optargument); |
|
|
char* colon = strpbrk(optargument, ":"); |
|
|
|
|
|
if(colon) { /*ip address:port */ |
|
|
|
|
|
*colon = 0; |
|
|
|
|
|
conf->bind_address = ntohl(inet_addr(optargument)); |
|
|
|
|
|
conf->local_port = atoi(++colon); |
|
|
|
|
|
|
|
|
|
|
|
if(conf->bind_address == INADDR_NONE) { |
|
|
|
|
|
traceEvent(TRACE_WARNING, "bad address to bind to, binding to any IP address"); |
|
|
|
|
|
conf->bind_address = INADDR_ANY; |
|
|
|
|
|
} |
|
|
if(conf->local_port == 0) { |
|
|
if(conf->local_port == 0) { |
|
|
traceEvent(TRACE_WARNING, "bad local port format, using OS assigned port"); |
|
|
traceEvent(TRACE_WARNING, "bad local port format, using OS assigned port"); |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
} else { /* ip address or port only */ |
|
|
case 'b': { |
|
|
char* dot = strpbrk(optargument, "."); |
|
|
if(optargument) { |
|
|
if(dot) { /* ip address only */ |
|
|
conf->bind_address = ntohl(inet_addr(optargument)); |
|
|
conf->bind_address = ntohl(inet_addr(optargument)); |
|
|
|
|
|
|
|
|
if(conf->bind_address == INADDR_NONE) { |
|
|
if(conf->bind_address == INADDR_NONE) { |
|
|
traceEvent(TRACE_WARNING, "Bad address to bind to, binding to any IP address."); |
|
|
traceEvent(TRACE_WARNING, "bad address to bind to, binding to any IP address"); |
|
|
conf->bind_address = INADDR_ANY; |
|
|
conf->bind_address = INADDR_ANY; |
|
|
break; |
|
|
} |
|
|
|
|
|
} else { /* port only */ |
|
|
|
|
|
conf->local_port = atoi(optargument); |
|
|
|
|
|
if(conf->local_port == 0) { |
|
|
|
|
|
traceEvent(TRACE_WARNING, "bad local port format, using OS assigned port"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -726,7 +734,6 @@ static const struct option long_options[] = |
|
|
{ "tap-device", required_argument, NULL, 'd' }, |
|
|
{ "tap-device", required_argument, NULL, 'd' }, |
|
|
{ "euid", required_argument, NULL, 'u' }, |
|
|
{ "euid", required_argument, NULL, 'u' }, |
|
|
{ "egid", required_argument, NULL, 'g' }, |
|
|
{ "egid", required_argument, NULL, 'g' }, |
|
|
{ "bind", required_argument, NULL, 'b' }, |
|
|
|
|
|
{ "help" , no_argument, NULL, '@' }, /* special character '@' to identify long help case */ |
|
|
{ "help" , no_argument, NULL, '@' }, /* special character '@' to identify long help case */ |
|
|
{ "verbose", no_argument, NULL, 'v' }, |
|
|
{ "verbose", no_argument, NULL, 'v' }, |
|
|
{ NULL, 0, NULL, 0 } |
|
|
{ NULL, 0, NULL, 0 } |
|
@ -740,7 +747,7 @@ static int loadFromCLI (int argc, char *argv[], n2n_edge_conf_t *conf, n2n_tunta |
|
|
u_char c; |
|
|
u_char c; |
|
|
|
|
|
|
|
|
while ((c = getopt_long(argc, argv, |
|
|
while ((c = getopt_long(argc, argv, |
|
|
"k:a:b:c:Eu:g:m:M:s:d:l:p:fvhrt:i:I:J:P:S::DL:z::A::Hn:R:" |
|
|
"k:a:c:Eu:g:m:M:s:d:l:p:fvhrt:i:I:J:P:S::DL:z::A::Hn:R:" |
|
|
#ifdef __linux__ |
|
|
#ifdef __linux__ |
|
|
"T:" |
|
|
"T:" |
|
|
#endif |
|
|
#endif |
|
|