Allow a port to be specified in BindToAddress statements.
This can be used to let tinc listen on multiple ports for incoming connections.
This commit is contained in:
parent
80e15d8b96
commit
a7dbb50c23
3 changed files with 31 additions and 5 deletions
|
@ -129,7 +129,7 @@ If
|
||||||
is selected, then depending on the operating system both IPv4 and IPv6 or just
|
is selected, then depending on the operating system both IPv4 and IPv6 or just
|
||||||
IPv6 listening sockets will be created.
|
IPv6 listening sockets will be created.
|
||||||
|
|
||||||
.It Va BindToAddress Li = Ar address Bq experimental
|
.It Va BindToAddress Li = Ar address Oo Ar port Oc Bq experimental
|
||||||
If your computer has more than one IPv4 or IPv6 address,
|
If your computer has more than one IPv4 or IPv6 address,
|
||||||
.Nm tinc
|
.Nm tinc
|
||||||
will by default listen on all of them for incoming connections.
|
will by default listen on all of them for incoming connections.
|
||||||
|
@ -137,7 +137,16 @@ Multiple
|
||||||
.Va BindToAddress
|
.Va BindToAddress
|
||||||
variables may be specified,
|
variables may be specified,
|
||||||
in which case listening sockets for each specified address are made.
|
in which case listening sockets for each specified address are made.
|
||||||
|
.Pp
|
||||||
|
If no
|
||||||
|
.Ar port
|
||||||
|
is specified, the socket will be bound to the port specified by the
|
||||||
|
.Va Port
|
||||||
|
option, or to port 655 if neither is given.
|
||||||
|
To only bind to a specific port but not to a specific address, use
|
||||||
|
.Li *
|
||||||
|
for the
|
||||||
|
.Ar address .
|
||||||
.Pp
|
.Pp
|
||||||
This option may not work on all platforms.
|
This option may not work on all platforms.
|
||||||
|
|
||||||
|
@ -452,7 +461,7 @@ Since host configuration files only contain public keys,
|
||||||
no secrets are revealed by sending out this information.
|
no secrets are revealed by sending out this information.
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
|
|
||||||
.It Va Address Li = Ar address Oo port Oc Bq recommended
|
.It Va Address Li = Ar address Oo Ar port Oc Bq recommended
|
||||||
The IP address or hostname of this tinc daemon on the real network.
|
The IP address or hostname of this tinc daemon on the real network.
|
||||||
This will only be used when trying to make an outgoing connection to this tinc daemon.
|
This will only be used when trying to make an outgoing connection to this tinc daemon.
|
||||||
Optionally, a port can be specified to use for this address.
|
Optionally, a port can be specified to use for this address.
|
||||||
|
|
|
@ -756,12 +756,16 @@ If any is selected, then depending on the operating system
|
||||||
both IPv4 and IPv6 or just IPv6 listening sockets will be created.
|
both IPv4 and IPv6 or just IPv6 listening sockets will be created.
|
||||||
|
|
||||||
@cindex BindToAddress
|
@cindex BindToAddress
|
||||||
@item BindToAddress = <@var{address}> [experimental]
|
@item BindToAddress = <@var{address}> [<@var{port}>] [experimental]
|
||||||
If your computer has more than one IPv4 or IPv6 address, tinc
|
If your computer has more than one IPv4 or IPv6 address, tinc
|
||||||
will by default listen on all of them for incoming connections.
|
will by default listen on all of them for incoming connections.
|
||||||
Multiple BindToAddress variables may be specified,
|
Multiple BindToAddress variables may be specified,
|
||||||
in which case listening sockets for each specified address are made.
|
in which case listening sockets for each specified address are made.
|
||||||
|
|
||||||
|
If no @var{port} is specified, the socket will be bound to the port specified by the Port option,
|
||||||
|
or to port 655 if neither is given.
|
||||||
|
To only bind to a specific port but not to a specific address, use "*" for the @var{address}.
|
||||||
|
|
||||||
This option may not work on all platforms.
|
This option may not work on all platforms.
|
||||||
|
|
||||||
@cindex BindToInterface
|
@cindex BindToInterface
|
||||||
|
|
|
@ -587,12 +587,25 @@ static bool setup_myself(void) {
|
||||||
if(cfg)
|
if(cfg)
|
||||||
cfg = lookup_config_next(config_tree, cfg);
|
cfg = lookup_config_next(config_tree, cfg);
|
||||||
|
|
||||||
|
char *port = myport;
|
||||||
|
|
||||||
|
if(address) {
|
||||||
|
char *space = strchr(address, ' ');
|
||||||
|
if(space) {
|
||||||
|
*space++ = 0;
|
||||||
|
port = space;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strcmp(address, "*"))
|
||||||
|
*address = 0;
|
||||||
|
}
|
||||||
|
|
||||||
hint.ai_family = addressfamily;
|
hint.ai_family = addressfamily;
|
||||||
hint.ai_socktype = SOCK_STREAM;
|
hint.ai_socktype = SOCK_STREAM;
|
||||||
hint.ai_protocol = IPPROTO_TCP;
|
hint.ai_protocol = IPPROTO_TCP;
|
||||||
hint.ai_flags = AI_PASSIVE;
|
hint.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
err = getaddrinfo(address, myport, &hint, &ai);
|
err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai);
|
||||||
free(address);
|
free(address);
|
||||||
|
|
||||||
if(err || !ai) {
|
if(err || !ai) {
|
||||||
|
|
Loading…
Reference in a new issue