diff options
Diffstat (limited to 'other')
-rw-r--r-- | other/DHT_bootstrap.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 738c2a0c..462360c3 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c | |||
@@ -75,11 +75,12 @@ void manage_keys(DHT *dht) | |||
75 | exit(1); | 75 | exit(1); |
76 | } | 76 | } |
77 | 77 | ||
78 | load_keys(dht->c, keys); | 78 | memcpy(dht->self_public_key, keys, crypto_box_PUBLICKEYBYTES); |
79 | memcpy(dht->self_secret_key, keys + crypto_box_PUBLICKEYBYTES, crypto_box_SECRETKEYBYTES); | ||
79 | printf("Keys loaded successfully.\n"); | 80 | printf("Keys loaded successfully.\n"); |
80 | } else { | 81 | } else { |
81 | new_keys(dht->c); | 82 | memcpy(keys, dht->self_public_key, crypto_box_PUBLICKEYBYTES); |
82 | save_keys(dht->c, keys); | 83 | memcpy(keys + crypto_box_PUBLICKEYBYTES, dht->self_secret_key, crypto_box_SECRETKEYBYTES); |
83 | keys_file = fopen("key", "w"); | 84 | keys_file = fopen("key", "w"); |
84 | 85 | ||
85 | if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) { | 86 | if (fwrite(keys, sizeof(uint8_t), KEYS_SIZE, keys_file) != KEYS_SIZE) { |
@@ -113,7 +114,7 @@ int main(int argc, char *argv[]) | |||
113 | IP ip; | 114 | IP ip; |
114 | ip_init(&ip, ipv6enabled); | 115 | ip_init(&ip, ipv6enabled); |
115 | 116 | ||
116 | DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); | 117 | DHT *dht = new_DHT(new_networking(ip, PORT)); |
117 | Onion *onion = new_onion(dht); | 118 | Onion *onion = new_onion(dht); |
118 | Onion_Announce *onion_a = new_onion_announce(dht); | 119 | Onion_Announce *onion_a = new_onion_announce(dht); |
119 | 120 | ||
@@ -129,9 +130,6 @@ int main(int argc, char *argv[]) | |||
129 | perror("Initialization"); | 130 | perror("Initialization"); |
130 | 131 | ||
131 | manage_keys(dht); | 132 | manage_keys(dht); |
132 | /* We want our DHT public key to be the same as our internal one since this is a bootstrap node */ | ||
133 | memcpy(dht->self_public_key, dht->c->self_public_key, crypto_box_PUBLICKEYBYTES); | ||
134 | memcpy(dht->self_secret_key, dht->c->self_secret_key, crypto_box_SECRETKEYBYTES); | ||
135 | printf("Public key: "); | 133 | printf("Public key: "); |
136 | uint32_t i; | 134 | uint32_t i; |
137 | 135 | ||
@@ -151,17 +149,14 @@ int main(int argc, char *argv[]) | |||
151 | file = fopen("PUBLIC_ID.txt", "w"); | 149 | file = fopen("PUBLIC_ID.txt", "w"); |
152 | 150 | ||
153 | for (i = 0; i < 32; i++) { | 151 | for (i = 0; i < 32; i++) { |
154 | if (dht->c->self_public_key[i] < 16) | 152 | printf("%02hhX", dht->self_public_key[i]); |
155 | printf("0"); | 153 | fprintf(file, "%02hhX", dht->self_public_key[i]); |
156 | |||
157 | printf("%hhX", dht->c->self_public_key[i]); | ||
158 | fprintf(file, "%hhX", dht->c->self_public_key[i]); | ||
159 | } | 154 | } |
160 | 155 | ||
161 | fclose(file); | 156 | fclose(file); |
162 | 157 | ||
163 | printf("\n"); | 158 | printf("\n"); |
164 | printf("Port: %u\n", ntohs(dht->c->lossless_udp->net->port)); | 159 | printf("Port: %u\n", ntohs(dht->net->port)); |
165 | 160 | ||
166 | if (argc > argvoffset + 3) { | 161 | if (argc > argvoffset + 3) { |
167 | printf("Trying to bootstrap into the network...\n"); | 162 | printf("Trying to bootstrap into the network...\n"); |
@@ -198,7 +193,7 @@ int main(int argc, char *argv[]) | |||
198 | #ifdef TCP_RELAY_ENABLED | 193 | #ifdef TCP_RELAY_ENABLED |
199 | do_TCP_server(tcp_s); | 194 | do_TCP_server(tcp_s); |
200 | #endif | 195 | #endif |
201 | networking_poll(dht->c->lossless_udp->net); | 196 | networking_poll(dht->net); |
202 | 197 | ||
203 | c_sleep(1); | 198 | c_sleep(1); |
204 | } | 199 | } |