From 1cf2b56fcc57073d952928da2338bdaff2cb7889 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 18 Oct 2018 15:59:24 +0200 Subject: [PATCH] Check all Address statements when making outgoing connections. The logic in get_recent_address() caused tinc to only consider the first Address statement that could be resolved to one or more IP addresses. --- src/address_cache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/address_cache.c b/src/address_cache.c index 445cd1c..b6d48d0 100644 --- a/src/address_cache.c +++ b/src/address_cache.c @@ -151,7 +151,7 @@ const sockaddr_t *get_recent_address(address_cache_t *cache) { cache->cfg = lookup_config(cache->config_tree, "Address"); } - while(cache->cfg && !cache->ai) { + while(cache->cfg && !cache->aip) { char *address, *port; get_config_string(cache->cfg, &address); @@ -167,6 +167,10 @@ const sockaddr_t *get_recent_address(address_cache_t *cache) { } } + if(cache->ai) { + free_known_addresses(cache->ai); + } + cache->aip = cache->ai = str2addrinfo(address, port, SOCK_STREAM); if(cache->ai) { -- 2.25.1