summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-09-28 09:54:17 -0400
committerirungentoo <irungentoo@gmail.com>2013-09-28 09:54:17 -0400
commit92f89b9384e4b26c2ecd5639154640f4618a580b (patch)
tree2afa73d33f3559ee7708931746659267689cfa12 /toxcore/DHT.c
parented07194eb638d2b6baa4ae033f05cddd585aaef0 (diff)
LAN ips can be sent to LAN ips.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index d83e409e..2c8d5bc9 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -310,7 +310,7 @@ static int friend_number(DHT *dht, uint8_t *client_id)
310 */ 310 */
311static void get_close_nodes_inner(DHT *dht, uint8_t *client_id, Node_format *nodes_list, 311static void get_close_nodes_inner(DHT *dht, uint8_t *client_id, Node_format *nodes_list,
312 sa_family_t sa_family, Client_data *client_list, uint32_t client_list_length, 312 sa_family_t sa_family, Client_data *client_list, uint32_t client_list_length,
313 time_t timestamp, int *num_nodes_ptr) 313 time_t timestamp, int *num_nodes_ptr, uint8_t is_LAN)
314{ 314{
315 if ((sa_family != AF_INET) && (sa_family != AF_INET6)) 315 if ((sa_family != AF_INET) && (sa_family != AF_INET6))
316 return; 316 return;
@@ -370,7 +370,7 @@ static void get_close_nodes_inner(DHT *dht, uint8_t *client_id, Node_format *nod
370 if (ipv46x) 370 if (ipv46x)
371 continue; 371 continue;
372 372
373 if (!LAN_ip(ipptp->ip_port.ip)) 373 if (!LAN_ip(ipptp->ip_port.ip) && !is_LAN)
374 continue; 374 continue;
375 375
376 if (num_nodes < MAX_SENT_NODES) { 376 if (num_nodes < MAX_SENT_NODES) {
@@ -412,17 +412,17 @@ static void get_close_nodes_inner(DHT *dht, uint8_t *client_id, Node_format *nod
412 * TODO: For the love of based <your favorite deity, in doubt use "love"> make 412 * TODO: For the love of based <your favorite deity, in doubt use "love"> make
413 * this function cleaner and much more efficient. 413 * this function cleaner and much more efficient.
414 */ 414 */
415static int get_close_nodes(DHT *dht, uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family) 415static int get_close_nodes(DHT *dht, uint8_t *client_id, Node_format *nodes_list, sa_family_t sa_family, uint8_t is_LAN)
416{ 416{
417 time_t timestamp = unix_time(); 417 time_t timestamp = unix_time();
418 int num_nodes = 0, i; 418 int num_nodes = 0, i;
419 get_close_nodes_inner(dht, client_id, nodes_list, sa_family, 419 get_close_nodes_inner(dht, client_id, nodes_list, sa_family,
420 dht->close_clientlist, LCLIENT_LIST, timestamp, &num_nodes); 420 dht->close_clientlist, LCLIENT_LIST, timestamp, &num_nodes, is_LAN);
421 421
422 for (i = 0; i < dht->num_friends; ++i) 422 for (i = 0; i < dht->num_friends; ++i)
423 get_close_nodes_inner(dht, client_id, nodes_list, sa_family, 423 get_close_nodes_inner(dht, client_id, nodes_list, sa_family,
424 dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS, 424 dht->friends_list[i].client_list, MAX_FRIEND_CLIENTS,
425 timestamp, &num_nodes); 425 timestamp, &num_nodes, is_LAN);
426 426
427 return num_nodes; 427 return num_nodes;
428} 428}
@@ -827,7 +827,7 @@ static int sendnodes(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_t *cl
827 + Node4_format_size * MAX_SENT_NODES + ENCRYPTION_PADDING]; 827 + Node4_format_size * MAX_SENT_NODES + ENCRYPTION_PADDING];
828 828
829 Node_format nodes_list[MAX_SENT_NODES]; 829 Node_format nodes_list[MAX_SENT_NODES];
830 int num_nodes = get_close_nodes(dht, client_id, nodes_list, AF_INET); 830 int num_nodes = get_close_nodes(dht, client_id, nodes_list, AF_INET, LAN_ip(ip_port.ip) == 0);
831 831
832 if (num_nodes == 0) 832 if (num_nodes == 0)
833 return 0; 833 return 0;
@@ -902,7 +902,7 @@ static int sendnodes_ipv6(DHT *dht, IP_Port ip_port, uint8_t *public_key, uint8_
902 + Node_format_size * MAX_SENT_NODES + ENCRYPTION_PADDING]; 902 + Node_format_size * MAX_SENT_NODES + ENCRYPTION_PADDING];
903 903
904 Node_format nodes_list[MAX_SENT_NODES]; 904 Node_format nodes_list[MAX_SENT_NODES];
905 int num_nodes = get_close_nodes(dht, client_id, nodes_list, AF_INET6); 905 int num_nodes = get_close_nodes(dht, client_id, nodes_list, AF_INET6, LAN_ip(ip_port.ip) == 0);
906 906
907 if (num_nodes == 0) 907 if (num_nodes == 0)
908 return 0; 908 return 0;