Only set dht public key and direct ip when first creating connection.

Check if ip family is valid in set_direct_ip_port() function.
This commit is contained in:
irungentoo 2014-09-26 21:14:36 -04:00
parent a8b7ddc1a3
commit 33e5c34aaf
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
2 changed files with 9 additions and 6 deletions

View File

@ -2413,13 +2413,13 @@ void do_friends(Messenger *m)
}
}
friend_new_connection(m, i, m->friendlist[i].client_id);
if (friend_new_connection(m, i, m->friendlist[i].client_id) == 0) {
if (m->friendlist[i].dht_lock)
set_connection_dht_public_key(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_temp_pk,
current_time_monotonic());
if (m->friendlist[i].dht_lock)
set_connection_dht_public_key(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_temp_pk,
current_time_monotonic());
set_direct_ip_port(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_ip_port);
set_direct_ip_port(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_ip_port);
}
}

View File

@ -1700,6 +1700,9 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port)
if (conn == 0)
return -1;
if (ip_port.ip.family != AF_INET && ip_port.ip.family != AF_INET6)
return -1;
if (!ipport_equal(&ip_port, &conn->ip_port)) {
if (bs_list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) {
bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id);