summaryrefslogtreecommitdiff
path: root/other
diff options
context:
space:
mode:
Diffstat (limited to 'other')
-rw-r--r--other/DHT_bootstrap.c32
-rw-r--r--other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c7
2 files changed, 30 insertions, 9 deletions
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index 654b759f..63cb1b75 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -84,10 +84,23 @@ void manage_keys(DHT *dht)
84 84
85int main(int argc, char *argv[]) 85int main(int argc, char *argv[])
86{ 86{
87 if (argc == 2 && !strncasecmp(argv[1], "-h", 3)) {
88 printf("Usage (connected) : %s [--ipv4|--ipv6] IP PORT KEY\n", argv[0]);
89 printf("Usage (unconnected): %s [--ipv4|--ipv6]\n", argv[0]);
90 exit(0);
91 }
92
93 /* let user override default by cmdline */
94 uint8_t ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; /* x */
95 int argvoffset = cmdline_parsefor_ipv46(argc, argv, &ipv6enabled);
96 if (argvoffset < 0)
97 exit(1);
98
87 /* Initialize networking - 99 /* Initialize networking -
88 Bind to ip 0.0.0.0:PORT */ 100 Bind to ip 0.0.0.0 / [::] : PORT */
89 IP ip; 101 IP ip;
90 ip.uint32 = 0; 102 ip_init(&ip, ipv6enabled);
103
91 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT))); 104 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, PORT)));
92 manage_keys(dht); 105 manage_keys(dht);
93 printf("Public key: "); 106 printf("Public key: ");
@@ -111,14 +124,17 @@ int main(int argc, char *argv[])
111 124
112 perror("Initialization."); 125 perror("Initialization.");
113 126
114 if (argc > 3) { 127 if (argc > argvoffset + 3) {
115 printf("Trying to bootstrap into the network...\n"); 128 printf("Trying to bootstrap into the network...\n");
116 IP_Port bootstrap_info; 129 uint16_t port = htons(atoi(argv[argvoffset + 2]));
117 bootstrap_info.ip.uint32 = inet_addr(argv[1]); 130 uint8_t *bootstrap_key = hex_string_to_bin(argv[argvoffset + 3]);
118 bootstrap_info.port = htons(atoi(argv[2])); 131 int res = DHT_bootstrap_ex(dht, argv[argvoffset + 1], ipv6enabled, port, bootstrap_key);
119 uint8_t *bootstrap_key = hex_string_to_bin(argv[3]);
120 DHT_bootstrap(dht, bootstrap_info, bootstrap_key);
121 free(bootstrap_key); 132 free(bootstrap_key);
133
134 if (!res) {
135 printf("Failed to convert \"%s\" into an IP address. Exiting...\n", argv[argvoffset + 1]);
136 exit(1);
137 }
122 } 138 }
123 139
124 int is_waiting_for_dht_connection = 1; 140 int is_waiting_for_dht_connection = 1;
diff --git a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
index 0ef1f314..890085cc 100644
--- a/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
+++ b/other/bootstrap_serverdaemon/DHT_bootstrap_daemon.c
@@ -305,7 +305,12 @@ struct server_conf_s configure_server(char *cfg_file)
305 printf("bootstrap_server %d: Invalid port.\n", i); 305 printf("bootstrap_server %d: Invalid port.\n", i);
306 } 306 }
307 307
308#ifdef TOX_ENABLE_IPV6
309 server_conf.info[i].conn.ip.family = AF_INET;
310 server_conf.info[i].conn.ip.ip4.uint32 = resolve_addr(strcpy(tmp_ip, bs_ip));
311#else
308 server_conf.info[i].conn.ip.uint32 = resolve_addr(strcpy(tmp_ip, bs_ip)); 312 server_conf.info[i].conn.ip.uint32 = resolve_addr(strcpy(tmp_ip, bs_ip));
313#endif
309 server_conf.info[i].conn.port = htons(bs_port); 314 server_conf.info[i].conn.port = htons(bs_port);
310 b16_to_key(strcpy(tmp_pk, bs_pk), bs_pk_p); 315 b16_to_key(strcpy(tmp_pk, bs_pk), bs_pk_p);
311 } 316 }
@@ -344,7 +349,7 @@ int main(int argc, char *argv[])
344 /* Initialize networking 349 /* Initialize networking
345 bind to ip 0.0.0.0:PORT */ 350 bind to ip 0.0.0.0:PORT */
346 IP ip; 351 IP ip;
347 ip.uint32 = 0; 352 ip_init(&ip, 0);
348 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, server_conf.port))); 353 DHT *dht = new_DHT(new_net_crypto(new_networking(ip, server_conf.port)));
349 /* Read the config file */ 354 /* Read the config file */
350 printf("PID file: %s\n", server_conf.pid_file); 355 printf("PID file: %s\n", server_conf.pid_file);