summaryrefslogtreecommitdiff
path: root/other/DHT_bootstrap.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-23 10:04:05 -0700
committerirungentoo <irungentoo@gmail.com>2013-07-23 10:04:05 -0700
commit2b8d86ebe2d193506f0439f095182e5862d545ab (patch)
tree7b902fcd20eaa969c233600c8797d9dc09f0f9dd /other/DHT_bootstrap.c
parent0019fe05e5c5eb81caefb6e7d9743ef500985d7c (diff)
parentea550d4c869d97c6a1b1dee8defabacd7d9d40e2 (diff)
Merge pull request #97 from nurupo/master
Some cleanup
Diffstat (limited to 'other/DHT_bootstrap.c')
-rw-r--r--other/DHT_bootstrap.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index ac74d901..0bacccd9 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -48,10 +48,9 @@ void manage_keys()
48 if (read_size != KEYS_SIZE) { 48 if (read_size != KEYS_SIZE) {
49 printf("Error while reading the key file\nExiting.\n"); 49 printf("Error while reading the key file\nExiting.\n");
50 exit(1); 50 exit(1);
51 } else {
52 printf("Keys loaded successfully\n");
53 } 51 }
54 load_keys(keys); 52 load_keys(keys);
53 printf("Keys loaded successfully\n");
55 } else { 54 } else {
56 //otherwise save new keys 55 //otherwise save new keys
57 new_keys(); 56 new_keys();
@@ -60,9 +59,8 @@ void manage_keys()
60 if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) { 59 if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) {
61 printf("Error while writing the key file.\nExiting.\n"); 60 printf("Error while writing the key file.\nExiting.\n");
62 exit(1); 61 exit(1);
63 } else {
64 printf("Keys saved successfully\n");
65 } 62 }
63 printf("Keys saved successfully\n");
66 } 64 }
67 65
68 fclose(keys_file); 66 fclose(keys_file);
@@ -80,15 +78,15 @@ int main(int argc, char *argv[])
80 printf("%hhX",self_public_key[i]); 78 printf("%hhX",self_public_key[i]);
81 } 79 }
82 printf("\n"); 80 printf("\n");
83 printf("Port: %u\n", PORT); 81 printf("Port: %u\n", PORT);
84 //initialize networking 82 //initialize networking
85 //bind to ip 0.0.0.0:PORT 83 //bind to ip 0.0.0.0:PORT
86 IP ip; 84 IP ip;
87 ip.i = 0; 85 ip.i = 0;
88 init_networking(ip, PORT); 86 init_networking(ip, PORT);
89 87
90 perror("Initialization"); 88 perror("Initialization");
91 89
92 if (argc > 3) { 90 if (argc > 3) {
93 printf("Trying to bootstrap into the network...\n"); 91 printf("Trying to bootstrap into the network...\n");
94 IP_Port bootstrap_info; 92 IP_Port bootstrap_info;
@@ -102,7 +100,7 @@ int main(int argc, char *argv[])
102 IP_Port ip_port; 100 IP_Port ip_port;
103 uint8_t data[MAX_UDP_PACKET_SIZE]; 101 uint8_t data[MAX_UDP_PACKET_SIZE];
104 uint32_t length; 102 uint32_t length;
105 103
106 int is_waiting_for_dht_connection = 1; 104 int is_waiting_for_dht_connection = 1;
107 while(1) 105 while(1)
108 { 106 {
@@ -112,7 +110,7 @@ int main(int argc, char *argv[])
112 is_waiting_for_dht_connection = 0; 110 is_waiting_for_dht_connection = 0;
113 } 111 }
114 doDHT(); 112 doDHT();
115 113
116 while(receivepacket(&ip_port, data, &length) != -1) 114 while(receivepacket(&ip_port, data, &length) != -1)
117 { 115 {
118 DHT_handlepacket(data, length, ip_port); 116 DHT_handlepacket(data, length, ip_port);