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:
Guus Sliepen 2012-03-21 13:20:15 +01:00
parent 80e15d8b96
commit a7dbb50c23
3 changed files with 31 additions and 5 deletions

View file

@ -587,12 +587,25 @@ static bool setup_myself(void) {
if(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_socktype = SOCK_STREAM;
hint.ai_protocol = IPPROTO_TCP;
hint.ai_flags = AI_PASSIVE;
err = getaddrinfo(address, myport, &hint, &ai);
err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai);
free(address);
if(err || !ai) {