diff options
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r-- | toxcore/DHT.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index dc21575e..68143421 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -695,7 +695,7 @@ static void update_client(const Logger *log, const Mono_Time *mono_time, int ind | |||
695 | net_ntohs(ip_port.port)); | 695 | net_ntohs(ip_port.port)); |
696 | } | 696 | } |
697 | 697 | ||
698 | if (ip_is_lan(assoc->ip_port.ip) != 0 && ip_is_lan(ip_port.ip) == 0) { | 698 | if (!ip_is_lan(assoc->ip_port.ip) && ip_is_lan(ip_port.ip)) { |
699 | return; | 699 | return; |
700 | } | 700 | } |
701 | 701 | ||
@@ -798,7 +798,7 @@ static uint8_t hardening_correct(const Hardening *h) | |||
798 | */ | 798 | */ |
799 | static void get_close_nodes_inner(const Mono_Time *mono_time, const uint8_t *public_key, Node_format *nodes_list, | 799 | static void get_close_nodes_inner(const Mono_Time *mono_time, const uint8_t *public_key, Node_format *nodes_list, |
800 | Family sa_family, const Client_data *client_list, uint32_t client_list_length, | 800 | Family sa_family, const Client_data *client_list, uint32_t client_list_length, |
801 | uint32_t *num_nodes_ptr, uint8_t is_LAN, uint8_t want_good) | 801 | uint32_t *num_nodes_ptr, bool is_LAN, uint8_t want_good) |
802 | { | 802 | { |
803 | if (!net_family_is_ipv4(sa_family) && !net_family_is_ipv6(sa_family) && !net_family_is_unspec(sa_family)) { | 803 | if (!net_family_is_ipv4(sa_family) && !net_family_is_ipv6(sa_family) && !net_family_is_unspec(sa_family)) { |
804 | return; | 804 | return; |
@@ -832,11 +832,11 @@ static void get_close_nodes_inner(const Mono_Time *mono_time, const uint8_t *pub | |||
832 | } | 832 | } |
833 | 833 | ||
834 | /* don't send LAN ips to non LAN peers */ | 834 | /* don't send LAN ips to non LAN peers */ |
835 | if (ip_is_lan(ipptp->ip_port.ip) == 0 && !is_LAN) { | 835 | if (ip_is_lan(ipptp->ip_port.ip) && !is_LAN) { |
836 | continue; | 836 | continue; |
837 | } | 837 | } |
838 | 838 | ||
839 | if (ip_is_lan(ipptp->ip_port.ip) != 0 && want_good && hardening_correct(&ipptp->hardening) != HARDENING_ALL_OK | 839 | if (!ip_is_lan(ipptp->ip_port.ip) && want_good && hardening_correct(&ipptp->hardening) != HARDENING_ALL_OK |
840 | && !id_equal(public_key, client->public_key)) { | 840 | && !id_equal(public_key, client->public_key)) { |
841 | continue; | 841 | continue; |
842 | } | 842 | } |
@@ -862,7 +862,7 @@ static void get_close_nodes_inner(const Mono_Time *mono_time, const uint8_t *pub | |||
862 | * want_good : do we want only good nodes as checked with the hardening returned or not? | 862 | * want_good : do we want only good nodes as checked with the hardening returned or not? |
863 | */ | 863 | */ |
864 | static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *nodes_list, | 864 | static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *nodes_list, |
865 | Family sa_family, uint8_t is_LAN, uint8_t want_good) | 865 | Family sa_family, bool is_LAN, uint8_t want_good) |
866 | { | 866 | { |
867 | uint32_t num_nodes = 0; | 867 | uint32_t num_nodes = 0; |
868 | get_close_nodes_inner(dht->mono_time, public_key, nodes_list, sa_family, | 868 | get_close_nodes_inner(dht->mono_time, public_key, nodes_list, sa_family, |
@@ -889,7 +889,7 @@ static int get_somewhat_close_nodes(const DHT *dht, const uint8_t *public_key, N | |||
889 | } | 889 | } |
890 | 890 | ||
891 | int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *nodes_list, Family sa_family, | 891 | int get_close_nodes(const DHT *dht, const uint8_t *public_key, Node_format *nodes_list, Family sa_family, |
892 | uint8_t is_LAN, uint8_t want_good) | 892 | bool is_LAN, uint8_t want_good) |
893 | { | 893 | { |
894 | memset(nodes_list, 0, MAX_SENT_NODES * sizeof(Node_format)); | 894 | memset(nodes_list, 0, MAX_SENT_NODES * sizeof(Node_format)); |
895 | return get_somewhat_close_nodes(dht, public_key, nodes_list, sa_family, is_LAN, want_good); | 895 | return get_somewhat_close_nodes(dht, public_key, nodes_list, sa_family, is_LAN, want_good); |
@@ -1370,8 +1370,8 @@ static int sendnodes_ipv6(const DHT *dht, IP_Port ip_port, const uint8_t *public | |||
1370 | const size_t node_format_size = sizeof(Node_format); | 1370 | const size_t node_format_size = sizeof(Node_format); |
1371 | 1371 | ||
1372 | Node_format nodes_list[MAX_SENT_NODES]; | 1372 | Node_format nodes_list[MAX_SENT_NODES]; |
1373 | const uint32_t num_nodes = get_close_nodes(dht, client_id, nodes_list, net_family_unspec, ip_is_lan(ip_port.ip) == 0, | 1373 | const uint32_t num_nodes = |
1374 | 1); | 1374 | get_close_nodes(dht, client_id, nodes_list, net_family_unspec, ip_is_lan(ip_port.ip), 1); |
1375 | 1375 | ||
1376 | VLA(uint8_t, plain, 1 + node_format_size * MAX_SENT_NODES + length); | 1376 | VLA(uint8_t, plain, 1 + node_format_size * MAX_SENT_NODES + length); |
1377 | 1377 | ||
@@ -2996,12 +2996,12 @@ bool dht_non_lan_connected(const DHT *dht) | |||
2996 | const Client_data *const client = &dht->close_clientlist[i]; | 2996 | const Client_data *const client = &dht->close_clientlist[i]; |
2997 | 2997 | ||
2998 | if (!mono_time_is_timeout(dht->mono_time, client->assoc4.timestamp, BAD_NODE_TIMEOUT) | 2998 | if (!mono_time_is_timeout(dht->mono_time, client->assoc4.timestamp, BAD_NODE_TIMEOUT) |
2999 | && ip_is_lan(client->assoc4.ip_port.ip) == -1) { | 2999 | && !ip_is_lan(client->assoc4.ip_port.ip)) { |
3000 | return true; | 3000 | return true; |
3001 | } | 3001 | } |
3002 | 3002 | ||
3003 | if (!mono_time_is_timeout(dht->mono_time, client->assoc6.timestamp, BAD_NODE_TIMEOUT) | 3003 | if (!mono_time_is_timeout(dht->mono_time, client->assoc6.timestamp, BAD_NODE_TIMEOUT) |
3004 | && ip_is_lan(client->assoc6.ip_port.ip) == -1) { | 3004 | && !ip_is_lan(client->assoc6.ip_port.ip)) { |
3005 | return true; | 3005 | return true; |
3006 | } | 3006 | } |
3007 | } | 3007 | } |