mirror of
https://github.com/ntop/n2n.git
synced 2024-09-20 00:51:10 +02:00
merged edge's '-b' into '-p' command line option (#772)
This commit is contained in:
parent
4cba2b5582
commit
05e6579038
12
edge.8
12
edge.8
|
@ -28,10 +28,14 @@ truncated to take the first 16 bytes.
|
||||||
sets the n2n supernode IP address and port to register to. Multiple supernodes
|
sets the n2n supernode IP address and port to register to. Multiple supernodes
|
||||||
can be specified.
|
can be specified.
|
||||||
.TP
|
.TP
|
||||||
\fB\-p \fR<\fIlocal port\fR>
|
\fB\-p \fR[<\fIlocal_ip_address\fR>:]<\fIlocal_port\fR>
|
||||||
binds edge to the given UDP port. Useful for keeping the same external socket
|
binds edge to the given UDP port. Useful for keeping the same external socket
|
||||||
across restarts of edge. This allows peer edges which know the edge socket to
|
across restarts of edge. This allows peer edges which know the edge socket to
|
||||||
continue p2p operation without going back to the supernode.
|
continue p2p operation without going back to the supernode. Also, home router's
|
||||||
|
port forwarding feature can refer to that fixed port.
|
||||||
|
Optionally, the edge can bind to the provided local ip address only. This is
|
||||||
|
useful in case restriction to a certain LAN or WiFi interface is desired.
|
||||||
|
By default, the edge binds to any interface.
|
||||||
.TP
|
.TP
|
||||||
\fB\-T \fR<\fItos\fR>
|
\fB\-T \fR<\fItos\fR>
|
||||||
TOS for packets, e.g. 0x48 for SSH like priority
|
TOS for packets, e.g. 0x48 for SSH like priority
|
||||||
|
@ -40,10 +44,6 @@ TOS for packets, e.g. 0x48 for SSH like priority
|
||||||
enable PMTU discovery, it can reduce fragmentation but
|
enable PMTU discovery, it can reduce fragmentation but
|
||||||
causes connections to stall if not properly supported
|
causes connections to stall if not properly supported
|
||||||
.TP
|
.TP
|
||||||
\fB\-b \fR<\fIbind ip\fR>
|
|
||||||
binds edge to the provided local IP address only, defaults to 'any' ip address
|
|
||||||
if not provided
|
|
||||||
.TP
|
|
||||||
\fB\-S1\fR ... \fB\-S2\fR
|
\fB\-S1\fR ... \fB\-S2\fR
|
||||||
do not connect p2p, always use the supernode,
|
do not connect p2p, always use the supernode,
|
||||||
\-S1 = via UDP, \-S2 = via TCP
|
\-S1 = via UDP, \-S2 = via TCP
|
||||||
|
|
51
src/edge.c
51
src/edge.c
|
@ -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
|
||||||
|
@ -176,7 +178,7 @@ static void help (int level) {
|
||||||
"[-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 "
|
||||||
|
@ -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 */
|
||||||
if(conf->local_port == 0) {
|
*colon = 0;
|
||||||
traceEvent(TRACE_WARNING, "bad local port format, using OS assigned port");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'b': {
|
|
||||||
if(optargument) {
|
|
||||||
conf->bind_address = ntohl(inet_addr(optargument));
|
conf->bind_address = ntohl(inet_addr(optargument));
|
||||||
|
conf->local_port = atoi(++colon);
|
||||||
|
|
||||||
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;
|
}
|
||||||
|
if(conf->local_port == 0) {
|
||||||
|
traceEvent(TRACE_WARNING, "bad local port format, using OS assigned port");
|
||||||
|
}
|
||||||
|
} else { /* ip address or port only */
|
||||||
|
char* dot = strpbrk(optargument, ".");
|
||||||
|
if(dot) { /* ip address only */
|
||||||
|
conf->bind_address = ntohl(inet_addr(optargument));
|
||||||
|
if(conf->bind_address == INADDR_NONE) {
|
||||||
|
traceEvent(TRACE_WARNING, "bad address to bind to, binding to any IP address");
|
||||||
|
conf->bind_address = INADDR_ANY;
|
||||||
|
}
|
||||||
|
} 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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user