summaryrefslogtreecommitdiff
path: root/other/DHT_bootstrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r--other/DHT_bootstrap.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index 0bf71312..229e6593 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -31,7 +31,7 @@
31#include "../toxcore/friend_requests.h" 31#include "../toxcore/friend_requests.h"
32#include "../testing/misc_tools.h" 32#include "../testing/misc_tools.h"
33 33
34//Sleep function (x = milliseconds) 34/* Sleep function (x = milliseconds) */
35#ifdef WIN32 35#ifdef WIN32
36#define c_sleep(x) Sleep(1*x) 36#define c_sleep(x) Sleep(1*x)
37#else 37#else
@@ -52,7 +52,8 @@ void manage_keys(DHT *dht)
52 FILE *keys_file = fopen("key", "r"); 52 FILE *keys_file = fopen("key", "r");
53 53
54 if (keys_file != NULL) { 54 if (keys_file != NULL) {
55 //if file was opened successfully -- load keys 55 /* If file was opened successfully -- load keys,
56 otherwise save new keys */
56 size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keys_file); 57 size_t read_size = fread(keys, sizeof(uint8_t), KEYS_SIZE, keys_file);
57 58
58 if (read_size != KEYS_SIZE) { 59 if (read_size != KEYS_SIZE) {
@@ -61,9 +62,8 @@ void manage_keys(DHT *dht)
61 } 62 }
62 63
63 load_keys(dht->c, keys); 64 load_keys(dht->c, keys);
64 printf("Keys loaded successfully\n"); 65 printf("Keys loaded successfully.\n");
65 } else { 66 } else {
66 //otherwise save new keys
67 new_keys(dht->c); 67 new_keys(dht->c);
68 save_keys(dht->c, keys); 68 save_keys(dht->c, keys);
69 keys_file = fopen("key", "w"); 69 keys_file = fopen("key", "w");
@@ -73,7 +73,7 @@ void manage_keys(DHT *dht)
73 exit(1); 73 exit(1);
74 } 74 }
75 75
76 printf("Keys saved successfully\n"); 76 printf("Keys saved successfully.\n");
77 } 77 }
78 78
79 fclose(keys_file); 79 fclose(keys_file);
@@ -81,8 +81,8 @@ void manage_keys(DHT *dht)
81 81
82int main(int argc, char *argv[]) 82int main(int argc, char *argv[])
83{ 83{
84 //initialize networking 84 /* Initialize networking -
85 //bind to ip 0.0.0.0:PORT 85 Bind to ip 0.0.0.0:PORT */
86 IP ip; 86 IP ip;
87 ip.i = 0; 87 ip.i = 0;
88 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); 88 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT)));
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
106 printf("\n"); 106 printf("\n");
107 printf("Port: %u\n", PORT); 107 printf("Port: %u\n", PORT);
108 108
109 perror("Initialization"); 109 perror("Initialization.");
110 110
111 if (argc > 3) { 111 if (argc > 3) {
112 printf("Trying to bootstrap into the network...\n"); 112 printf("Trying to bootstrap into the network...\n");