summaryrefslogtreecommitdiff
path: root/other
diff options
context:
space:
mode:
Diffstat (limited to 'other')
-rw-r--r--other/DHT_bootstrap.c25
-rw-r--r--other/bootstrap_daemon/tox_bootstrap_daemon.c19
2 files changed, 19 insertions, 25 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index 50d473a9..462360c3 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -31,6 +31,8 @@
31#include "../toxcore/friend_requests.h" 31#include "../toxcore/friend_requests.h"
32#include "../toxcore/util.h" 32#include "../toxcore/util.h"
33 33
34#define TCP_RELAY_ENABLED
35
34#ifdef TCP_RELAY_ENABLED 36#ifdef TCP_RELAY_ENABLED
35#include "../toxcore/TCP_server.h" 37#include "../toxcore/TCP_server.h"
36#endif 38#endif
@@ -73,11 +75,12 @@ void manage_keys(DHT *dht)
73 exit(1); 75 exit(1);
74 } 76 }
75 77
76 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);
77 printf("Keys loaded successfully.\n"); 80 printf("Keys loaded successfully.\n");
78 } else { 81 } else {
79 new_keys(dht->c); 82 memcpy(keys, dht->self_public_key, crypto_box_PUBLICKEYBYTES);
80 save_keys(dht->c, keys); 83 memcpy(keys + crypto_box_PUBLICKEYBYTES, dht->self_secret_key, crypto_box_SECRETKEYBYTES);
81 keys_file = fopen("key", "w"); 84 keys_file = fopen("key", "w");
82 85
83 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) {
@@ -111,7 +114,7 @@ int main(int argc, char *argv[])
111 IP ip; 114 IP ip;
112 ip_init(&ip, ipv6enabled); 115 ip_init(&ip, ipv6enabled);
113 116
114 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); 117 DHT *dht = new_DHT(new_networking(ip, PORT));
115 Onion *onion = new_onion(dht); 118 Onion *onion = new_onion(dht);
116 Onion_Announce *onion_a = new_onion_announce(dht); 119 Onion_Announce *onion_a = new_onion_announce(dht);
117 120
@@ -127,9 +130,6 @@ int main(int argc, char *argv[])
127 perror("Initialization"); 130 perror("Initialization");
128 131
129 manage_keys(dht); 132 manage_keys(dht);
130 /* We want our DHT public key to be the same as our internal one since this is a bootstrap node */
131 memcpy(dht->self_public_key, dht->c->self_public_key, crypto_box_PUBLICKEYBYTES);
132 memcpy(dht->self_secret_key, dht->c->self_secret_key, crypto_box_SECRETKEYBYTES);
133 printf("Public key: "); 133 printf("Public key: ");
134 uint32_t i; 134 uint32_t i;
135 135
@@ -149,17 +149,14 @@ int main(int argc, char *argv[])
149 file = fopen("PUBLIC_ID.txt", "w"); 149 file = fopen("PUBLIC_ID.txt", "w");
150 150
151 for (i = 0; i < 32; i++) { 151 for (i = 0; i < 32; i++) {
152 if (dht->c->self_public_key[i] < 16) 152 printf("%02hhX", dht->self_public_key[i]);
153 printf("0"); 153 fprintf(file, "%02hhX", dht->self_public_key[i]);
154
155 printf("%hhX", dht->c->self_public_key[i]);
156 fprintf(file, "%hhX", dht->c->self_public_key[i]);
157 } 154 }
158 155
159 fclose(file); 156 fclose(file);
160 157
161 printf("\n"); 158 printf("\n");
162 printf("Port: %u\n", ntohs(dht->c->lossless_udp->net->port)); 159 printf("Port: %u\n", ntohs(dht->net->port));
163 160
164 if (argc > argvoffset + 3) { 161 if (argc > argvoffset + 3) {
165 printf("Trying to bootstrap into the network...\n"); 162 printf("Trying to bootstrap into the network...\n");
@@ -196,7 +193,7 @@ int main(int argc, char *argv[])
196#ifdef TCP_RELAY_ENABLED 193#ifdef TCP_RELAY_ENABLED
197 do_TCP_server(tcp_s); 194 do_TCP_server(tcp_s);
198#endif 195#endif
199 networking_poll(dht->c->lossless_udp->net); 196 networking_poll(dht->net);
200 197
201 c_sleep(1); 198 c_sleep(1);
202 } 199 }
diff --git a/other/bootstrap_daemon/tox_bootstrap_daemon.c b/other/bootstrap_daemon/tox_bootstrap_daemon.c
index 66f6436d..abad7760 100644
--- a/other/bootstrap_daemon/tox_bootstrap_daemon.c
+++ b/other/bootstrap_daemon/tox_bootstrap_daemon.c
@@ -36,9 +36,9 @@
36#include "config.h" 36#include "config.h"
37#endif 37#endif
38 38
39#include "../../toxcore/DHT.h" 39#include "../../toxcore/onion_announce.h"
40#include "../../toxcore/friend_requests.h"
41#include "../../toxcore/LAN_discovery.h" 40#include "../../toxcore/LAN_discovery.h"
41#include "../../toxcore/util.h"
42 42
43#include "../../testing/misc_tools.c" 43#include "../../testing/misc_tools.c"
44 44
@@ -75,11 +75,12 @@ int manage_keys(DHT *dht, char *keys_file_path)
75 return 0; 75 return 0;
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 } else { 80 } else {
80 // Otherwise save new keys 81 // Otherwise save new keys
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 84
84 keys_file = fopen(keys_file_path, "w"); 85 keys_file = fopen(keys_file_path, "w");
85 86
@@ -92,10 +93,6 @@ int manage_keys(DHT *dht, char *keys_file_path)
92 93
93 fclose(keys_file); 94 fclose(keys_file);
94 95
95 // We want our DHT public key to be the same as our internal one since this is a bootstrap node
96 memcpy(dht->self_public_key, dht->c->self_public_key, crypto_box_PUBLICKEYBYTES);
97 memcpy(dht->self_secret_key, dht->c->self_secret_key, crypto_box_SECRETKEYBYTES);
98
99 return 1; 96 return 1;
100} 97}
101 98
@@ -351,7 +348,7 @@ int main(int argc, char *argv[])
351 IP ip; 348 IP ip;
352 ip_init(&ip, enable_ipv6); 349 ip_init(&ip, enable_ipv6);
353 350
354 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, port))); 351 DHT *dht = new_DHT(new_networking(ip, port));
355 352
356 if (dht == NULL) { 353 if (dht == NULL) {
357 syslog(LOG_ERR, "Couldn't initialize Tox DHT instance. Exiting.\n"); 354 syslog(LOG_ERR, "Couldn't initialize Tox DHT instance. Exiting.\n");
@@ -384,7 +381,7 @@ int main(int argc, char *argv[])
384 return 1; 381 return 1;
385 } 382 }
386 383
387 print_public_key(dht->c->self_public_key); 384 print_public_key(dht->self_public_key);
388 385
389 // Write the PID file 386 // Write the PID file
390 FILE *pidf = fopen(pid_file_path, "w"); 387 FILE *pidf = fopen(pid_file_path, "w");