summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/DHT.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index 1c550628..c1eadc2a 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -1010,14 +1010,10 @@ static void get_bunchnodes(DHT *dht, Client_data *list, uint16_t length, uint16_
1010 IPPTsPng *assoc; 1010 IPPTsPng *assoc;
1011#ifdef CLIENT_ONETOONE_IP 1011#ifdef CLIENT_ONETOONE_IP
1012 assoc = &list[i].assoc; 1012 assoc = &list[i].assoc;
1013 if (1) {
1014#else 1013#else
1015 uint32_t a; 1014 uint32_t a;
1016 for (a = 0; a < 2; a++) { 1015
1017 if (!a) 1016 for (a = 0, assoc = &list[i].assoc6; a < 2; a++, assoc = &list[i].assoc4)
1018 assoc = &list[i].assoc6;
1019 else
1020 assoc = &list[i].assoc4;
1021#endif 1017#endif
1022 if (ipport_isset(&(assoc->ip_port)) && 1018 if (ipport_isset(&(assoc->ip_port)) &&
1023 !is_timeout(temp_time, assoc->ret_timestamp, BAD_NODE_TIMEOUT)) { 1019 !is_timeout(temp_time, assoc->ret_timestamp, BAD_NODE_TIMEOUT)) {
@@ -1027,7 +1023,6 @@ static void get_bunchnodes(DHT *dht, Client_data *list, uint16_t length, uint16_
1027 if (num >= max_num) 1023 if (num >= max_num)
1028 return; 1024 return;
1029 } 1025 }
1030 }
1031 } 1026 }
1032} 1027}
1033 1028
@@ -1105,20 +1100,15 @@ int DHT_getfriendip(DHT *dht, uint8_t *client_id, IP_Port *ip_port)
1105 IPPTsPng *assoc = NULL; 1100 IPPTsPng *assoc = NULL;
1106#ifdef CLIENT_ONETOONE_IP 1101#ifdef CLIENT_ONETOONE_IP
1107 assoc = &client->assoc; 1102 assoc = &client->assoc;
1108 if (1) {
1109#else 1103#else
1110 uint32_t a; 1104 uint32_t a;
1111 for (a = 0; a < 2; a++) { 1105
1112 if (!a) 1106 for (a = 0, assoc = &client->assoc6; a < 2; a++, assoc = &client->assoc4)
1113 assoc = &client->assoc6;
1114 else
1115 assoc = &client->assoc4;
1116#endif 1107#endif
1117 if (!is_timeout(temp_time, assoc->timestamp, BAD_NODE_TIMEOUT)) { 1108 if (!is_timeout(temp_time, assoc->timestamp, BAD_NODE_TIMEOUT)) {
1118 *ip_port = assoc->ip_port; 1109 *ip_port = assoc->ip_port;
1119 return 1; 1110 return 1;
1120 } 1111 }
1121 }
1122 } 1112 }
1123 } 1113 }
1124 1114
@@ -1145,14 +1135,10 @@ static void do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, uint8
1145 IPPTsPng *assoc; 1135 IPPTsPng *assoc;
1146#ifdef CLIENT_ONETOONE_IP 1136#ifdef CLIENT_ONETOONE_IP
1147 assoc = &client->assoc; 1137 assoc = &client->assoc;
1148 if (1) {
1149#else 1138#else
1150 uint32_t a; 1139 uint32_t a;
1151 for (a = 0; a < 2; a++) { 1140
1152 if (!a) 1141 for (a = 0, assoc = &client->assoc6; a < 2; a++, assoc = &client->assoc4)
1153 assoc = &client->assoc6;
1154 else
1155 assoc = &client->assoc4;
1156#endif 1142#endif
1157 1143
1158 if (!is_timeout(temp_time, assoc->timestamp, KILL_NODE_TIMEOUT)) { 1144 if (!is_timeout(temp_time, assoc->timestamp, KILL_NODE_TIMEOUT)) {
@@ -1168,7 +1154,6 @@ static void do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, uint8
1168 ++num_nodes; 1154 ++num_nodes;
1169 } 1155 }
1170 } 1156 }
1171 }
1172 } 1157 }
1173 1158
1174 if ((num_nodes != 0) && 1159 if ((num_nodes != 0) &&