summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing/DHT_test.c46
-rw-r--r--toxcore/DHT.c2
2 files changed, 31 insertions, 17 deletions
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 11027af5..375a2cc1 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -52,6 +52,29 @@
52 52
53#define PORT 33445 53#define PORT 33445
54 54
55void print_client_id(uint8_t * client_id)
56{
57 uint32_t j;
58 for (j = 0; j < CLIENT_ID_SIZE; j++) {
59 printf("%02hhX", client_id[j]);
60 }
61}
62
63void print_hardening(Hardening *h)
64{
65 printf("Hardening:\n");
66 printf("routes_requests_ok: %hhu\n", h->routes_requests_ok);
67 printf("routes_requests_timestamp: %llu\n", (long long unsigned int)h->routes_requests_timestamp);
68 printf("routes_requests_pingedid: "); print_client_id(h->routes_requests_pingedid);
69 printf("\nsend_nodes_ok: %hhu\n", h->send_nodes_ok);
70 printf("send_nodes_timestamp: %llu\n", (long long unsigned int)h->send_nodes_timestamp);
71 printf("send_nodes_pingedid: "); print_client_id(h->send_nodes_pingedid);
72 printf("\ntesting_requests: %hhu\n", h->testing_requests);
73 printf("testing_timestamp: %llu\n", (long long unsigned int)h->testing_timestamp);
74 printf("testing_pingedid: "); print_client_id(h->testing_pingedid);
75 printf("\n\n");
76}
77
55void print_assoc(IPPTsPng *assoc, uint8_t ours) 78void print_assoc(IPPTsPng *assoc, uint8_t ours)
56{ 79{
57 IP_Port *ipp = &assoc->ip_port; 80 IP_Port *ipp = &assoc->ip_port;
@@ -65,20 +88,19 @@ void print_assoc(IPPTsPng *assoc, uint8_t ours)
65 else 88 else
66 printf("RET IP: %s Port: %u\n", ip_ntoa(&ipp->ip), ntohs(ipp->port)); 89 printf("RET IP: %s Port: %u\n", ip_ntoa(&ipp->ip), ntohs(ipp->port));
67 printf("Timestamp: %llu\n", (long long unsigned int) assoc->ret_timestamp); 90 printf("Timestamp: %llu\n", (long long unsigned int) assoc->ret_timestamp);
91 print_hardening(&assoc->hardening);
92
68} 93}
69 94
70void print_clientlist(DHT *dht) 95void print_clientlist(DHT *dht)
71{ 96{
72 uint32_t i, j; 97 uint32_t i;
73 printf("___________________CLOSE________________________________\n"); 98 printf("___________________CLOSE________________________________\n");
74 99
75 for (i = 0; i < LCLIENT_LIST; i++) { 100 for (i = 0; i < LCLIENT_LIST; i++) {
76 Client_data *client = &dht->close_clientlist[i]; 101 Client_data *client = &dht->close_clientlist[i];
77 printf("ClientID: "); 102 printf("ClientID: ");
78 103 print_client_id(client->client_id);
79 for (j = 0; j < CLIENT_ID_SIZE; j++) {
80 printf("%02hhX", client->client_id[j]);
81 }
82 104
83 print_assoc(&client->assoc4, 1); 105 print_assoc(&client->assoc4, 1);
84 print_assoc(&client->assoc6, 1); 106 print_assoc(&client->assoc6, 1);
@@ -87,7 +109,7 @@ void print_clientlist(DHT *dht)
87 109
88void print_friendlist(DHT *dht) 110void print_friendlist(DHT *dht)
89{ 111{
90 uint32_t i, j, k; 112 uint32_t i, k;
91 IP_Port p_ip; 113 IP_Port p_ip;
92 printf("_________________FRIENDS__________________________________\n"); 114 printf("_________________FRIENDS__________________________________\n");
93 115
@@ -95,9 +117,7 @@ void print_friendlist(DHT *dht)
95 printf("FRIEND %u\n", k); 117 printf("FRIEND %u\n", k);
96 printf("ID: "); 118 printf("ID: ");
97 119
98 for (j = 0; j < CLIENT_ID_SIZE; j++) { 120 print_client_id(dht->friends_list[k].client_id);
99 printf("%c", dht->friends_list[k].client_id[j]);
100 }
101 121
102 int friendok = DHT_getfriendip(dht, dht->friends_list[k].client_id, &p_ip); 122 int friendok = DHT_getfriendip(dht, dht->friends_list[k].client_id, &p_ip);
103 printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip), ntohs(p_ip.port), friendok); 123 printf("\nIP: %s:%u (%d)", ip_ntoa(&p_ip.ip), ntohs(p_ip.port), friendok);
@@ -107,13 +127,7 @@ void print_friendlist(DHT *dht)
107 for (i = 0; i < MAX_FRIEND_CLIENTS; i++) { 127 for (i = 0; i < MAX_FRIEND_CLIENTS; i++) {
108 Client_data *client = &dht->friends_list[k].client_list[i]; 128 Client_data *client = &dht->friends_list[k].client_list[i];
109 printf("ClientID: "); 129 printf("ClientID: ");
110 130 print_client_id(client->client_id);
111 for (j = 0; j < CLIENT_ID_SIZE; j++) {
112 if (client->client_id[j] < 16)
113 printf("0");
114
115 printf("%hhX", client->client_id[j]);
116 }
117 131
118 print_assoc(&client->assoc4, 0); 132 print_assoc(&client->assoc4, 0);
119 print_assoc(&client->assoc6, 0); 133 print_assoc(&client->assoc6, 0);
diff --git a/toxcore/DHT.c b/toxcore/DHT.c
index b9ba7e1d..2f85e172 100644
--- a/toxcore/DHT.c
+++ b/toxcore/DHT.c
@@ -1706,7 +1706,7 @@ static int handle_hardening(void *object, IP_Port source, uint8_t *source_pubkey
1706 return 1; 1706 return 1;
1707 1707
1708 /* If Nodes look good and the request checks out */ 1708 /* If Nodes look good and the request checks out */
1709 temp->hardening.routes_requests_ok = 1; 1709 temp->hardening.send_nodes_ok = 1;
1710 return 0;/* success*/ 1710 return 0;/* success*/
1711 } 1711 }
1712 } 1712 }