Allow multiple BindToAddress statements.
This commit is contained in:
parent
708314df2f
commit
9f6a96af39
3 changed files with 47 additions and 36 deletions
|
@ -133,7 +133,10 @@ IPv6 listening sockets will be created.
|
|||
If your computer has more than one IPv4 or IPv6 address,
|
||||
.Nm tinc
|
||||
will by default listen on all of them for incoming connections.
|
||||
It is possible to bind only to a single address with this variable.
|
||||
Multiple
|
||||
.Va BindToAddress
|
||||
variables may be specified,
|
||||
in which case listening sockets for each specified address are made.
|
||||
|
||||
.Pp
|
||||
This option may not work on all platforms.
|
||||
|
|
|
@ -759,7 +759,8 @@ both IPv4 and IPv6 or just IPv6 listening sockets will be created.
|
|||
@item BindToAddress = <@var{address}> [experimental]
|
||||
If your computer has more than one IPv4 or IPv6 address, tinc
|
||||
will by default listen on all of them for incoming connections.
|
||||
It is possible to bind only to a single address with this variable.
|
||||
Multiple BindToAddress variables may be specified,
|
||||
in which case listening sockets for each specified address are made.
|
||||
|
||||
This option may not work on all platforms.
|
||||
|
||||
|
|
|
@ -582,7 +582,12 @@ static bool setup_myself(void) {
|
|||
|
||||
/* Open sockets */
|
||||
|
||||
get_config_string(lookup_config(config_tree, "BindToAddress"), &address);
|
||||
cfg = lookup_config(config_tree, "BindToAddress");
|
||||
|
||||
do {
|
||||
get_config_string(cfg, &address);
|
||||
if(cfg)
|
||||
cfg = lookup_config_next(config_tree, cfg);
|
||||
|
||||
hint.ai_family = addressfamily;
|
||||
hint.ai_socktype = SOCK_STREAM;
|
||||
|
@ -590,6 +595,7 @@ static bool setup_myself(void) {
|
|||
hint.ai_flags = AI_PASSIVE;
|
||||
|
||||
err = getaddrinfo(address, myport, &hint, &ai);
|
||||
free(address);
|
||||
|
||||
if(err || !ai) {
|
||||
logger(LOG_ERR, "System call `%s' failed: %s", "getaddrinfo",
|
||||
|
@ -623,6 +629,7 @@ static bool setup_myself(void) {
|
|||
}
|
||||
|
||||
freeaddrinfo(ai);
|
||||
} while(cfg);
|
||||
|
||||
if(listen_sockets)
|
||||
logger(LOG_NOTICE, "Ready");
|
||||
|
|
Loading…
Reference in a new issue