diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/DHT.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -36,6 +36,7 @@ typedef struct | |||
36 | uint32_t last_pinged; | 36 | uint32_t last_pinged; |
37 | IP_Port ret_ip_port;/* The ip_port returned by this node for the friend | 37 | IP_Port ret_ip_port;/* The ip_port returned by this node for the friend |
38 | (for nodes in friends_list) or us (for nodes in close_clientlist) */ | 38 | (for nodes in friends_list) or us (for nodes in close_clientlist) */ |
39 | uint32_t ret_timestamp; | ||
39 | }Client_data; | 40 | }Client_data; |
40 | /* maximum number of clients stored per friend. */ | 41 | /* maximum number of clients stored per friend. */ |
41 | #define MAX_FRIEND_CLIENTS 8 | 42 | #define MAX_FRIEND_CLIENTS 8 |
@@ -241,6 +242,7 @@ int replace_bad(Client_data * list, uint32_t length, uint8_t * client_id, IP_Por | |||
241 | list[i].timestamp = temp_time; | 242 | list[i].timestamp = temp_time; |
242 | list[i].ret_ip_port.ip.i = 0; | 243 | list[i].ret_ip_port.ip.i = 0; |
243 | list[i].ret_ip_port.port = 0; | 244 | list[i].ret_ip_port.port = 0; |
245 | list[i].ret_timestamp = 0; | ||
244 | return 0; | 246 | return 0; |
245 | } | 247 | } |
246 | } | 248 | } |
@@ -263,6 +265,7 @@ int replace_good(Client_data * list, uint32_t length, uint8_t * client_id, IP_Po | |||
263 | list[i].timestamp = temp_time; | 265 | list[i].timestamp = temp_time; |
264 | list[i].ret_ip_port.ip.i = 0; | 266 | list[i].ret_ip_port.ip.i = 0; |
265 | list[i].ret_ip_port.port = 0; | 267 | list[i].ret_ip_port.port = 0; |
268 | list[i].ret_timestamp = 0; | ||
266 | return 0; | 269 | return 0; |
267 | } | 270 | } |
268 | } | 271 | } |
@@ -305,6 +308,7 @@ void addto_lists(IP_Port ip_port, uint8_t * client_id) | |||
305 | void returnedip_ports(IP_Port ip_port, uint8_t * client_id, uint8_t * nodeclient_id) | 308 | void returnedip_ports(IP_Port ip_port, uint8_t * client_id, uint8_t * nodeclient_id) |
306 | { | 309 | { |
307 | uint32_t i, j; | 310 | uint32_t i, j; |
311 | uint32_t temp_time = unix_time(); | ||
308 | if(memcmp(client_id, self_public_key, CLIENT_ID_SIZE) == 0) | 312 | if(memcmp(client_id, self_public_key, CLIENT_ID_SIZE) == 0) |
309 | { | 313 | { |
310 | for(i = 0; i < LCLIENT_LIST; ++i) | 314 | for(i = 0; i < LCLIENT_LIST; ++i) |
@@ -312,6 +316,7 @@ void returnedip_ports(IP_Port ip_port, uint8_t * client_id, uint8_t * nodeclient | |||
312 | if(memcmp(nodeclient_id, close_clientlist[i].client_id, CLIENT_ID_SIZE) == 0) | 316 | if(memcmp(nodeclient_id, close_clientlist[i].client_id, CLIENT_ID_SIZE) == 0) |
313 | { | 317 | { |
314 | close_clientlist[i].ret_ip_port = ip_port; | 318 | close_clientlist[i].ret_ip_port = ip_port; |
319 | close_clientlist[i].ret_timestamp = temp_time; | ||
315 | return; | 320 | return; |
316 | } | 321 | } |
317 | } | 322 | } |
@@ -326,6 +331,7 @@ void returnedip_ports(IP_Port ip_port, uint8_t * client_id, uint8_t * nodeclient | |||
326 | if(memcmp(nodeclient_id, friends_list[i].client_list[j].client_id, CLIENT_ID_SIZE) == 0) | 331 | if(memcmp(nodeclient_id, friends_list[i].client_list[j].client_id, CLIENT_ID_SIZE) == 0) |
327 | { | 332 | { |
328 | friends_list[i].client_list[j].ret_ip_port = ip_port; | 333 | friends_list[i].client_list[j].ret_ip_port = ip_port; |
334 | friends_list[i].client_list[j].ret_timestamp = temp_time; | ||
329 | return; | 335 | return; |
330 | } | 336 | } |
331 | } | 337 | } |
@@ -1019,7 +1025,7 @@ int route_tofriend(uint8_t * friend_id, uint8_t * packet, uint32_t length) | |||
1019 | for(j = 0; j < MAX_FRIEND_CLIENTS; ++j) | 1025 | for(j = 0; j < MAX_FRIEND_CLIENTS; ++j) |
1020 | { | 1026 | { |
1021 | if(friends_list[i].client_list[j].ret_ip_port.ip.i != 0 && | 1027 | if(friends_list[i].client_list[j].ret_ip_port.ip.i != 0 && |
1022 | friends_list[i].client_list[j].timestamp + BAD_NODE_TIMEOUT > temp_time) | 1028 | friends_list[i].client_list[j].ret_timestamp + BAD_NODE_TIMEOUT > temp_time) |
1023 | /*If ip is not zero and node is good */ | 1029 | /*If ip is not zero and node is good */ |
1024 | { | 1030 | { |
1025 | if(sendpacket(friends_list[i].client_list[j].ip_port, packet, length) == length) | 1031 | if(sendpacket(friends_list[i].client_list[j].ip_port, packet, length) == length) |
@@ -1050,7 +1056,7 @@ int friend_ips(IP_Port * ip_portlist, uint8_t * friend_id) | |||
1050 | for(j = 0; j < MAX_FRIEND_CLIENTS; ++j) | 1056 | for(j = 0; j < MAX_FRIEND_CLIENTS; ++j) |
1051 | { | 1057 | { |
1052 | if(friends_list[i].client_list[j].ret_ip_port.ip.i != 0 && | 1058 | if(friends_list[i].client_list[j].ret_ip_port.ip.i != 0 && |
1053 | friends_list[i].client_list[j].timestamp + BAD_NODE_TIMEOUT > temp_time) | 1059 | friends_list[i].client_list[j].ret_timestamp + BAD_NODE_TIMEOUT > temp_time) |
1054 | /*If ip is not zero and node is good */ | 1060 | /*If ip is not zero and node is good */ |
1055 | { | 1061 | { |
1056 | ip_portlist[num_ips] = friends_list[i].client_list[j].ret_ip_port; | 1062 | ip_portlist[num_ips] = friends_list[i].client_list[j].ret_ip_port; |