From: Etienne Dechamps Date: Sun, 6 Jul 2014 09:55:23 +0000 (+0100) Subject: Make sure myport is set correctly when running with Port = 0. X-Git-Tag: release-1.1pre11~78 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=fcf5b53e785fd191dd951b77ad831fe6ac78dce4;p=tinc Make sure myport is set correctly when running with Port = 0. Setting the Port configuration variable to zero can be used to make tinc listen on a system-assigned port. Unfortunately, in this scenario myport will be zero, which means that tinc won't transmit its actual UDP listening port to other nodes. This breaks UDP hole punching and local discovery. --- diff --git a/src/net_setup.c b/src/net_setup.c index 6d15fcf1..c4f2127e 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -1037,7 +1037,7 @@ static bool setup_myself(void) { /* If no Port option was specified, set myport to the port used by the first listening socket. */ - if(!port_specified) { + if(!port_specified || atoi(myport) == 0) { sockaddr_t sa; socklen_t salen = sizeof sa; if(!getsockname(listen_socket[0].udp.fd, &sa.sa, &salen)) {