Choose a suitable socket when updating a node's UDP address.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 17 Nov 2012 21:14:52 +0000 (22:14 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 17 Nov 2012 21:14:52 +0000 (22:14 +0100)
src/node.c

index e67b9b97fd51fe8b556bdecb125be1ff518777a1..5dc3119fb9b19ca10dddabd1877cdf517d74b342 100644 (file)
@@ -129,6 +129,13 @@ void update_node_udp(node_t *n, const sockaddr_t *sa) {
 
        if(sa) {
                n->address = *sa;
+               n->sock = 0;
+               for(int i = 0; i < listen_sockets; i++) {
+                       if(listen_socket[i].sa.sa.sa_family == sa->sa.sa_family) {
+                               n->sock = i;
+                               break;
+                       }
+               }
                hash_insert(node_udp_cache, sa, n);
                free(n->hostname);
                n->hostname = sockaddr2hostname(&n->address);