Let choose_local_address() prefer addresses discovered via SLPD
This commit is contained in:
parent
11b8eb81b9
commit
69bb848f59
1 changed files with 15 additions and 10 deletions
|
@ -605,17 +605,22 @@ static void choose_local_address(const node_t *n, const sockaddr_t **sa, int *so
|
||||||
int j = rand() % n->edge_tree->count;
|
int j = rand() % n->edge_tree->count;
|
||||||
edge_t *candidate = NULL;
|
edge_t *candidate = NULL;
|
||||||
|
|
||||||
for splay_each(edge_t, e, n->edge_tree) {
|
|
||||||
if(i++ == j) {
|
|
||||||
candidate = e;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (candidate && candidate->local_address.sa.sa_family) {
|
if (!n->slpd_address) {
|
||||||
*sa = &candidate->local_address;
|
for splay_each(edge_t, e, n->edge_tree) {
|
||||||
*sock = rand() % listen_sockets;
|
if(i++ == j) {
|
||||||
adapt_socket(*sa, sock);
|
candidate = e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (candidate && candidate->local_address.sa.sa_family) {
|
||||||
|
*sa = &candidate->local_address;
|
||||||
|
*sock = rand() % listen_sockets;
|
||||||
|
adapt_socket(*sa, sock);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//*sa = str2sockaddr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue