diff options
author | irungentoo <irungentoo@gmail.com> | 2014-09-26 21:14:36 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-09-26 21:14:36 -0400 |
commit | 33e5c34aaf6dd9f4b7af17538cc334bf7a8bfaba (patch) | |
tree | d3ea2e21139412c33f9ec9b460867b3699a2cf0c | |
parent | a8b7ddc1a39577f368d0ea735087c12207e6795d (diff) |
Only set dht public key and direct ip when first creating connection.
Check if ip family is valid in set_direct_ip_port() function.
-rw-r--r-- | toxcore/Messenger.c | 12 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 521562b8..9383af68 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -2413,13 +2413,13 @@ void do_friends(Messenger *m) | |||
2413 | } | 2413 | } |
2414 | } | 2414 | } |
2415 | 2415 | ||
2416 | friend_new_connection(m, i, m->friendlist[i].client_id); | 2416 | if (friend_new_connection(m, i, m->friendlist[i].client_id) == 0) { |
2417 | if (m->friendlist[i].dht_lock) | ||
2418 | set_connection_dht_public_key(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_temp_pk, | ||
2419 | current_time_monotonic()); | ||
2417 | 2420 | ||
2418 | if (m->friendlist[i].dht_lock) | 2421 | set_direct_ip_port(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_ip_port); |
2419 | set_connection_dht_public_key(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_temp_pk, | 2422 | } |
2420 | current_time_monotonic()); | ||
2421 | |||
2422 | set_direct_ip_port(m->net_crypto, m->friendlist[i].crypt_connection_id, m->friendlist[i].dht_ip_port); | ||
2423 | 2423 | ||
2424 | } | 2424 | } |
2425 | 2425 | ||
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index a286df2a..59f6ee9a 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -1700,6 +1700,9 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port) | |||
1700 | if (conn == 0) | 1700 | if (conn == 0) |
1701 | return -1; | 1701 | return -1; |
1702 | 1702 | ||
1703 | if (ip_port.ip.family != AF_INET && ip_port.ip.family != AF_INET6) | ||
1704 | return -1; | ||
1705 | |||
1703 | if (!ipport_equal(&ip_port, &conn->ip_port)) { | 1706 | if (!ipport_equal(&ip_port, &conn->ip_port)) { |
1704 | if (bs_list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) { | 1707 | if (bs_list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) { |
1705 | bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); | 1708 | bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); |