Check all Address statements when making outgoing connections.
authorGuus Sliepen <guus@tinc-vpn.org>
Thu, 18 Oct 2018 13:59:24 +0000 (15:59 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Thu, 18 Oct 2018 14:13:51 +0000 (16:13 +0200)
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

index 445cd1c..b6d48d0 100644 (file)
@@ -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) {