summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index df736ebe..8faa7f03 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -183,6 +183,7 @@ static void dht_ip_callback(void *data, int32_t number, IP_Port ip_port)
183 183
184 set_direct_ip_port(m->net_crypto, m->friendlist[number].crypt_connection_id, ip_port); 184 set_direct_ip_port(m->net_crypto, m->friendlist[number].crypt_connection_id, ip_port);
185 m->friendlist[number].dht_ip_port = ip_port; 185 m->friendlist[number].dht_ip_port = ip_port;
186 m->friendlist[number].dht_ip_port_lastrecv = unix_time();
186} 187}
187 188
188/* Callback for dht public key changes. */ 189/* Callback for dht public key changes. */
@@ -1629,10 +1630,14 @@ static int handle_new_connections(void *object, New_Connection *n_c)
1629 1630
1630 if (n_c->source.ip.family != AF_INET && n_c->source.ip.family != AF_INET6) { 1631 if (n_c->source.ip.family != AF_INET && n_c->source.ip.family != AF_INET6) {
1631 set_direct_ip_port(m->net_crypto, m->friendlist[friend_id].crypt_connection_id, m->friendlist[friend_id].dht_ip_port); 1632 set_direct_ip_port(m->net_crypto, m->friendlist[friend_id].crypt_connection_id, m->friendlist[friend_id].dht_ip_port);
1633 } else {
1634 m->friendlist[friend_id].dht_ip_port = n_c->source;
1635 m->friendlist[friend_id].dht_ip_port_lastrecv = unix_time();
1632 } 1636 }
1633 1637
1634 dht_pk_callback(m, friend_id, n_c->dht_public_key); 1638 dht_pk_callback(m, friend_id, n_c->dht_public_key);
1635 1639
1640 nc_dht_pk_callback(m->net_crypto, id, &dht_pk_callback, m, friend_id);
1636 return 0; 1641 return 0;
1637 } 1642 }
1638 1643
@@ -2410,6 +2415,10 @@ void do_friends(Messenger *m)
2410 m->friendlist[i].dht_lock = 0; 2415 m->friendlist[i].dht_lock = 0;
2411 } 2416 }
2412 } 2417 }
2418
2419 if (m->friendlist[i].dht_ip_port_lastrecv + FRIEND_DHT_TIMEOUT < temp_time) {
2420 m->friendlist[i].dht_ip_port.ip.family = 0;
2421 }
2413 } 2422 }
2414 2423
2415 if (friend_new_connection(m, i, m->friendlist[i].client_id) == 0) { 2424 if (friend_new_connection(m, i, m->friendlist[i].client_id) == 0) {