diff options
Diffstat (limited to 'other/bootstrap_serverdaemon')
-rw-r--r-- | other/bootstrap_serverdaemon/Makefile.inc | 12 | ||||
-rw-r--r-- | other/bootstrap_serverdaemon/README.md | 22 | ||||
-rw-r--r-- | other/bootstrap_serverdaemon/conf | 39 | ||||
-rw-r--r-- | other/bootstrap_serverdaemon/tox_bootstrap_daemon.c (renamed from other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.c) | 102 | ||||
-rw-r--r-- | other/bootstrap_serverdaemon/tox_bootstrap_daemon.sh (renamed from other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.sh) | 11 |
5 files changed, 87 insertions, 99 deletions
diff --git a/other/bootstrap_serverdaemon/Makefile.inc b/other/bootstrap_serverdaemon/Makefile.inc index 5ab17b56..effe59e8 100644 --- a/other/bootstrap_serverdaemon/Makefile.inc +++ b/other/bootstrap_serverdaemon/Makefile.inc | |||
@@ -1,17 +1,17 @@ | |||
1 | if BUILD_DHT_BOOTSTRAP_DAEMON | 1 | if BUILD_DHT_BOOTSTRAP_DAEMON |
2 | 2 | ||
3 | noinst_PROGRAMS += tox_dht_bootstrap_server_daemon | 3 | noinst_PROGRAMS += tox_bootstrap_daemon |
4 | 4 | ||
5 | tox_dht_bootstrap_server_daemon_SOURCES = \ | 5 | tox_bootstrap_daemon_SOURCES = \ |
6 | ../other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.c | 6 | ../other/bootstrap_serverdaemon/tox_bootstrap_daemon.c |
7 | 7 | ||
8 | tox_dht_bootstrap_server_daemon_CFLAGS = \ | 8 | tox_bootstrap_daemon_CFLAGS = \ |
9 | -I$(top_srcdir)/other/bootstrap_serverdaemon \ | 9 | -I$(top_srcdir)/other/bootstrap_serverdaemon \ |
10 | $(LIBSODIUM_CFLAGS) \ | 10 | $(LIBSODIUM_CFLAGS) \ |
11 | $(NACL_CFLAGS) \ | 11 | $(NACL_CFLAGS) \ |
12 | $(LIBCONFIG_CFLAGS) | 12 | $(LIBCONFIG_CFLAGS) |
13 | 13 | ||
14 | tox_dht_bootstrap_server_daemon_LDADD = \ | 14 | tox_bootstrap_daemon_LDADD = \ |
15 | $(LIBSODIUM_LDFLAGS) \ | 15 | $(LIBSODIUM_LDFLAGS) \ |
16 | $(NACL_LDFLAGS) \ | 16 | $(NACL_LDFLAGS) \ |
17 | libtoxcore.la \ | 17 | libtoxcore.la \ |
@@ -23,5 +23,5 @@ endif | |||
23 | 23 | ||
24 | EXTRA_DIST += \ | 24 | EXTRA_DIST += \ |
25 | $(top_srcdir)/other/bootstrap_serverdaemon/conf \ | 25 | $(top_srcdir)/other/bootstrap_serverdaemon/conf \ |
26 | $(top_srcdir)/other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.sh | 26 | $(top_srcdir)/other/bootstrap_serverdaemon/tox_bootstrap_daemon.sh |
27 | \ No newline at end of file | 27 | \ No newline at end of file |
diff --git a/other/bootstrap_serverdaemon/README.md b/other/bootstrap_serverdaemon/README.md index 30cb14aa..53a25cdb 100644 --- a/other/bootstrap_serverdaemon/README.md +++ b/other/bootstrap_serverdaemon/README.md | |||
@@ -2,44 +2,44 @@ | |||
2 | 2 | ||
3 | The following commands are to be executed as root: | 3 | The following commands are to be executed as root: |
4 | 4 | ||
5 | 1. In `tox_dht_bootstrap_server_daemon.sh` file change: | 5 | 1. In `tox_bootstrap_daemon.sh` file change: |
6 | - `CFG` to where your config file (`conf`) will be; read rights required | 6 | - `CFG` to where your config file (`conf`) will be; read rights required |
7 | - `DAEMON` to point to the executable | 7 | - `DAEMON` to point to the executable |
8 | - `PIDFILE` to point to a pid file daemon would have rights to create | 8 | - `PIDFILE` to point to a pid file daemon would have rights to create |
9 | 9 | ||
10 | 2. Go over everything in `conf`. Make sure `pid_file_path` matches `PIDFILE` from `tox_dht_bootstrap_server_daemon.sh` | 10 | 2. Go over everything in `conf`. Make sure `pid_file_path` matches `PIDFILE` from `tox_bootstrap_daemon.sh` |
11 | 11 | ||
12 | 3. Execute: | 12 | 3. Execute: |
13 | ``` | 13 | ``` |
14 | mv tox_dht_bootstrap_server_daemon.sh /etc/init.d/tox_dht_bootstrap_server_daemon | 14 | mv tox_bootstrap_daemon.sh /etc/init.d/tox_bootstrap_daemon |
15 | ``` | 15 | ``` |
16 | *(note that we removed `.sh` ending)* | 16 | *(note that we removed `.sh` ending)* |
17 | 17 | ||
18 | 4. Give the right permissions to this file: | 18 | 4. Give the right permissions to this file: |
19 | ``` | 19 | ``` |
20 | chmod 755 /etc/init.d/tox_dht_bootstrap_server_daemon | 20 | chmod 755 /etc/init.d/tox_bootstrap_daemon |
21 | ``` | 21 | ``` |
22 | 22 | ||
23 | 5. Execute: | 23 | 5. Execute: |
24 | ``` | 24 | ``` |
25 | update-rc.d tox_dht_bootstrap_server_daemon defaults | 25 | update-rc.d tox_bootstrap_daemon defaults |
26 | ``` | 26 | ``` |
27 | 27 | ||
28 | 6. Start the service: | 28 | 6. Start the service: |
29 | ``` | 29 | ``` |
30 | service tox_dht_bootstrap_server_daemon start | 30 | service tox_bootstrap_daemon start |
31 | ``` | 31 | ``` |
32 | 32 | ||
33 | 7. Verify that the service is running: | 33 | 7. Verify that the service is running: |
34 | ``` | 34 | ``` |
35 | service tox_dht_bootstrap_server_daemon status | 35 | service tox_bootstrap_daemon status |
36 | ``` | 36 | ``` |
37 | 37 | ||
38 | -- | 38 | -- |
39 | 39 | ||
40 | You can see daemon's log with | 40 | You can see daemon's log with |
41 | ``` | 41 | ``` |
42 | grep "tox_dht_bootstrap_server_daemon" /var/log/syslog | 42 | grep "tox_bootstrap_daemon" /var/log/syslog |
43 | ``` | 43 | ``` |
44 | 44 | ||
45 | **Note that system log is where you find your public key** | 45 | **Note that system log is where you find your public key** |
@@ -50,12 +50,12 @@ grep "tox_dht_bootstrap_server_daemon" /var/log/syslog | |||
50 | 50 | ||
51 | 1. Check the log for errors with | 51 | 1. Check the log for errors with |
52 | ``` | 52 | ``` |
53 | grep "tox_dht_bootstrap_server_daemon" /var/log/syslog | 53 | grep "tox_bootstrap_daemon" /var/log/syslog |
54 | ``` | 54 | ``` |
55 | 55 | ||
56 | 2. Check that paths in the beginning of `/etc/init.d/tox_dht_bootstrap_server_daemon` are valid | 56 | 2. Check that paths in the beginning of `/etc/init.d/tox_bootstrap_daemon` are valid |
57 | 57 | ||
58 | 3. Make sure that `PIDFILE` from `/etc/init.d/tox_dht_bootstrap_server_daemon` matches with the `pid_file_path` from `conf` | 58 | 3. Make sure that `PIDFILE` from `/etc/init.d/tox_bootstrap_daemon` matches with the `pid_file_path` from `conf` |
59 | 59 | ||
60 | 4. Make sure you have write permission to keys and pid files | 60 | 4. Make sure you have write permission to keys and pid files |
61 | 61 | ||
diff --git a/other/bootstrap_serverdaemon/conf b/other/bootstrap_serverdaemon/conf index 70dbdb14..8451d9a0 100644 --- a/other/bootstrap_serverdaemon/conf +++ b/other/bootstrap_serverdaemon/conf | |||
@@ -1,33 +1,34 @@ | |||
1 | // ProjectTox bootstrap server configuration file | 1 | // ProjectTox dht bootstrap server daemon configuration file. |
2 | 2 | ||
3 | // listening port | 3 | // Listening port. |
4 | port = 33445 | 4 | port = 33445 |
5 | 5 | ||
6 | // The key file is like a password, so keep it where no one can read it | 6 | // The key file is like a password, so keep it where no one can read it. |
7 | // The daemon should have permission to read/write to it | 7 | // The daemon should have permission to read/write to it. |
8 | // Remember to replace the provided example with | 8 | // Remember to replace the provided example with your own path. |
9 | // your own path | 9 | keys_file_path = "/home/tom/.tox_bootstrap_daemon/keys" |
10 | keys_file_path = "/home/tom/.tox_dht_bootstrap_server_daemon/keys" | ||
11 | 10 | ||
12 | // The PID file written to by daemon, | 11 | // The PID file written to by daemon. |
13 | // make sure that the user who runs the server | 12 | // Make sure that the user who runs the daemon has permissions to write to the |
14 | // does have permissions to write to it | 13 | // PID file. |
15 | // Remember to replace the provided example with | 14 | // Remember to replace the provided example with your own path. |
16 | // your own path | 15 | pid_file_path = "/home/tom/.tox_bootstrap_daemon/pid" |
17 | pid_file_path = "/home/tom/.tox_dht_bootstrap_server_daemon/pid" | ||
18 | 16 | ||
17 | // Enable IPv6. | ||
19 | enable_ipv6 = false | 18 | enable_ipv6 = false |
20 | 19 | ||
21 | // Automatically bootstrap with nodes on local network | 20 | // Automatically bootstrap with nodes on local area network. |
22 | enable_lan_discovery = true | 21 | enable_lan_discovery = true |
23 | 22 | ||
24 | // Any number of nodes the daemon will bootstrap itself from | 23 | // Any number of servers the daemon will bootstrap itself from. |
25 | // Remember to replace the provided example with | 24 | // Remember to replace the provided example with your own server list. |
26 | // your own server list | 25 | // You may leave the list empty or remove "bootstrap_servers" complitely, |
26 | // in both cases this will be interpreted as if you don't want to bootstrap | ||
27 | // from anyone. | ||
27 | bootstrap_servers = ( | 28 | bootstrap_servers = ( |
28 | { // Server 1 | 29 | { // Server 1 |
29 | // any ipv4 or ipv6, depending if `enable_ipv6` is set or not | 30 | // Any ipv4 or ipv6, depending if `enable_ipv6` is set or not, and also |
30 | // also any US-ASCII domain name | 31 | // any US-ASCII domain name. |
31 | address = "198.46.136.167" | 32 | address = "198.46.136.167" |
32 | port = 33445 | 33 | port = 33445 |
33 | public_key = "728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854" | 34 | public_key = "728925473812C7AAC482BE7250BCCAD0B8CB9F737BF3D42ABD34459C1768F854" |
diff --git a/other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.c b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c index 24bb8266..f2c54bb1 100644 --- a/other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.c +++ b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* tox_dht_bootstrap_server_daemon | 1 | /* tox_bootstrap_daemon.c |
2 | * | 2 | * |
3 | * A simple DHT bootstrap server for tox - daemon edition. | 3 | * Tox DHT bootstrap server daemon. |
4 | * | 4 | * |
5 | * Copyright (C) 2014 Tox project All Rights Reserved. | 5 | * Copyright (C) 2014 Tox project All Rights Reserved. |
6 | * | 6 | * |
@@ -42,13 +42,13 @@ | |||
42 | 42 | ||
43 | #include "../../testing/misc_tools.c" | 43 | #include "../../testing/misc_tools.c" |
44 | 44 | ||
45 | #define DAEMON_NAME "tox_dht_bootstrap_server_daemon" | 45 | #define DAEMON_NAME "tox_bootstrap_daemon" |
46 | 46 | ||
47 | #define SLEEP_TIME_MILLISECONDS 30 | 47 | #define SLEEP_TIME_MILLISECONDS 30 |
48 | #define sleep usleep(1000*SLEEP_TIME_MILLISECONDS) | 48 | #define sleep usleep(1000*SLEEP_TIME_MILLISECONDS) |
49 | 49 | ||
50 | #define DEFAULT_PID_FILE_PATH ".tox_dht_bootstrap_server_daemon.pid" | 50 | #define DEFAULT_PID_FILE_PATH ".tox_bootstrap_daemon.pid" |
51 | #define DEFAULT_KEYS_FILE_PATH ".tox_dht_bootstrap_server_daemon.keys" | 51 | #define DEFAULT_KEYS_FILE_PATH ".tox_bootstrap_daemon.keys" |
52 | #define DEFAULT_PORT 33445 | 52 | #define DEFAULT_PORT 33445 |
53 | #define DEFAULT_ENABLE_IPV6 0 // 1 - true, 0 - false | 53 | #define DEFAULT_ENABLE_IPV6 0 // 1 - true, 0 - false |
54 | #define DEFAULT_ENABLE_LAN_DISCOVERY 1 // 1 - true, 0 - false | 54 | #define DEFAULT_ENABLE_LAN_DISCOVERY 1 // 1 - true, 0 - false |
@@ -186,8 +186,8 @@ int get_general_config(char *cfg_file_path, char **pid_file_path, char **keys_fi | |||
186 | 186 | ||
187 | // Bootstraps servers listed in the config file | 187 | // Bootstraps servers listed in the config file |
188 | // | 188 | // |
189 | // returns 1 on success | 189 | // returns 1 on success, some or no bootstrap servers were added |
190 | // 0 on failure, either no or only some servers were bootstrapped | 190 | // 0 on failure, a error accured while parsing config file |
191 | 191 | ||
192 | int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6) | 192 | int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6) |
193 | { | 193 | { |
@@ -210,9 +210,15 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6) | |||
210 | config_setting_t *server_list = config_lookup(&cfg, NAME_BOOTSTRAP_SERVERS); | 210 | config_setting_t *server_list = config_lookup(&cfg, NAME_BOOTSTRAP_SERVERS); |
211 | 211 | ||
212 | if (server_list == NULL) { | 212 | if (server_list == NULL) { |
213 | syslog(LOG_ERR, "No '%s' setting in configuration file.\n", NAME_BOOTSTRAP_SERVERS); | 213 | syslog(LOG_WARNING, "No '%s' setting in the configuration file. Skipping bootstrapping.\n", NAME_BOOTSTRAP_SERVERS); |
214 | config_destroy(&cfg); | 214 | config_destroy(&cfg); |
215 | return 0; | 215 | return 1; |
216 | } | ||
217 | |||
218 | if (config_setting_length(server_list) == 0) { | ||
219 | syslog(LOG_WARNING, "No bootstrap servers found. Skipping bootstrapping.\n"); | ||
220 | config_destroy(&cfg); | ||
221 | return 1; | ||
216 | } | 222 | } |
217 | 223 | ||
218 | int bs_port; | 224 | int bs_port; |
@@ -232,21 +238,31 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6) | |||
232 | return 0; | 238 | return 0; |
233 | } | 239 | } |
234 | 240 | ||
235 | // Proceed only if all parts are present | 241 | // Check that all settings are present |
236 | if (config_setting_lookup_string(server, NAME_PUBLIC_KEY, &bs_public_key) == CONFIG_FALSE || | 242 | if (config_setting_lookup_string(server, NAME_PUBLIC_KEY, &bs_public_key) == CONFIG_FALSE) { |
237 | config_setting_lookup_int (server, NAME_PORT, &bs_port) == CONFIG_FALSE || | 243 | syslog(LOG_WARNING, "Bootstrap server #%d: Couldn't find '%s' setting. Skipping the server.\n", i, NAME_PUBLIC_KEY); |
238 | config_setting_lookup_string(server, NAME_ADDRESS, &bs_address) == CONFIG_FALSE ) { | ||
239 | goto next; | 244 | goto next; |
240 | } | 245 | } |
241 | 246 | ||
247 | if (config_setting_lookup_int(server, NAME_PORT, &bs_port) == CONFIG_FALSE) { | ||
248 | syslog(LOG_WARNING, "Bootstrap server #%d: Couldn't find '%s' setting. Skipping the server.\n", i, NAME_PORT); | ||
249 | goto next; | ||
250 | } | ||
251 | |||
252 | if (config_setting_lookup_string(server, NAME_ADDRESS, &bs_address) == CONFIG_FALSE) { | ||
253 | syslog(LOG_WARNING, "Bootstrap server #%d: Couldn't find '%s' setting. Skipping the server.\n", i, NAME_ADDRESS); | ||
254 | goto next; | ||
255 | } | ||
256 | |||
257 | // Process settings | ||
242 | if (strlen(bs_public_key) != 64) { | 258 | if (strlen(bs_public_key) != 64) { |
243 | syslog(LOG_WARNING, "bootstrap_server #%d: Invalid '%s': %s.\n", i, NAME_PUBLIC_KEY, bs_public_key); | 259 | syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %s. Skipping the server.\n", i, NAME_PUBLIC_KEY, bs_public_key); |
244 | goto next; | 260 | goto next; |
245 | } | 261 | } |
246 | 262 | ||
247 | // not (1 <= port <= 65535) | 263 | // not (1 <= port <= 65535) |
248 | if (bs_port < 1 || bs_port > 65535) { | 264 | if (bs_port < 1 || bs_port > 65535) { |
249 | syslog(LOG_WARNING, "bootstrap_server #%d: Invalid '%s': %d.\n", i, NAME_PORT, bs_port); | 265 | syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %d. Skipping the server.\n", i, NAME_PORT, bs_port); |
250 | goto next; | 266 | goto next; |
251 | } | 267 | } |
252 | 268 | ||
@@ -254,11 +270,11 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6) | |||
254 | hex_string_to_bin((char *)bs_public_key)); | 270 | hex_string_to_bin((char *)bs_public_key)); |
255 | 271 | ||
256 | if (!address_resolved) { | 272 | if (!address_resolved) { |
257 | syslog(LOG_WARNING, "bootstrap_server #%d: Invalid '%s': %s.\n", i, NAME_ADDRESS, bs_address); | 273 | syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %s. Skipping the server.\n", i, NAME_ADDRESS, bs_address); |
258 | goto next; | 274 | goto next; |
259 | } | 275 | } |
260 | 276 | ||
261 | syslog(LOG_DEBUG, "Successfully connected to %s:%d %s\n", bs_address, bs_port, bs_public_key); | 277 | syslog(LOG_DEBUG, "Successfully added bootstrap server #%d: %s:%d %s\n", i, bs_address, bs_port, bs_public_key); |
262 | 278 | ||
263 | next: | 279 | next: |
264 | // config_setting_lookup_string() allocates string inside and doesn't allow us to free it | 280 | // config_setting_lookup_string() allocates string inside and doesn't allow us to free it |
@@ -273,36 +289,6 @@ next: | |||
273 | return 1; | 289 | return 1; |
274 | } | 290 | } |
275 | 291 | ||
276 | // Checks if we are connected to the DHT | ||
277 | // | ||
278 | // returns 1 on success | ||
279 | // 0 on failure | ||
280 | |||
281 | int try_connect(DHT *dht, int port, int enable_lan_discovery) | ||
282 | { | ||
283 | uint16_t htons_port = htons(port); | ||
284 | |||
285 | int i; | ||
286 | |||
287 | for (i = 0; i < 100; i ++) { | ||
288 | do_DHT(dht); | ||
289 | |||
290 | if (enable_lan_discovery) { | ||
291 | send_LANdiscovery(htons_port, dht); | ||
292 | } | ||
293 | |||
294 | networking_poll(dht->c->lossless_udp->net); | ||
295 | |||
296 | if (DHT_isconnected(dht)) { | ||
297 | return 1; | ||
298 | } | ||
299 | |||
300 | sleep; | ||
301 | } | ||
302 | |||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | // Prints public key | 292 | // Prints public key |
307 | 293 | ||
308 | void print_public_key(uint8_t *public_key) | 294 | void print_public_key(uint8_t *public_key) |
@@ -330,7 +316,7 @@ int main(int argc, char *argv[]) | |||
330 | openlog(DAEMON_NAME, LOG_NOWAIT | LOG_PID, LOG_DAEMON); | 316 | openlog(DAEMON_NAME, LOG_NOWAIT | LOG_PID, LOG_DAEMON); |
331 | 317 | ||
332 | if (argc < 2) { | 318 | if (argc < 2) { |
333 | syslog(LOG_ERR, "Please specify a configuration file. Exiting.\n"); | 319 | syslog(LOG_ERR, "Please specify a path to a configuration file as the first argument. Exiting.\n"); |
334 | return 1; | 320 | return 1; |
335 | } | 321 | } |
336 | 322 | ||
@@ -395,13 +381,6 @@ int main(int argc, char *argv[]) | |||
395 | return 1; | 381 | return 1; |
396 | } | 382 | } |
397 | 383 | ||
398 | if (try_connect(dht, port, enable_lan_discovery)) { | ||
399 | syslog(LOG_INFO, "Successfully connected to DHT\n"); | ||
400 | } else { | ||
401 | syslog(LOG_ERR, "Couldn't connect to the DHT. Check settings and network connections. Exiting.\n"); | ||
402 | return 1; | ||
403 | } | ||
404 | |||
405 | print_public_key(dht->c->self_public_key); | 384 | print_public_key(dht->c->self_public_key); |
406 | 385 | ||
407 | // Write the PID file | 386 | // Write the PID file |
@@ -419,11 +398,14 @@ int main(int argc, char *argv[]) | |||
419 | pid_t pid = fork(); | 398 | pid_t pid = fork(); |
420 | 399 | ||
421 | if (pid < 0) { | 400 | if (pid < 0) { |
401 | fclose(pidf); | ||
422 | syslog(LOG_ERR, "Forking failed. Exiting.\n"); | 402 | syslog(LOG_ERR, "Forking failed. Exiting.\n"); |
423 | return 1; | 403 | return 1; |
424 | } | 404 | } |
425 | 405 | ||
426 | if (pid > 0) { | 406 | if (pid > 0) { |
407 | fprintf(pidf, "%d\n", pid); | ||
408 | fclose(pidf); | ||
427 | syslog(LOG_DEBUG, "Forked successfully: PID: %d.\n", pid); | 409 | syslog(LOG_DEBUG, "Forked successfully: PID: %d.\n", pid); |
428 | return 0; | 410 | return 0; |
429 | } | 411 | } |
@@ -431,9 +413,6 @@ int main(int argc, char *argv[]) | |||
431 | // Change the file mode mask | 413 | // Change the file mode mask |
432 | umask(0); | 414 | umask(0); |
433 | 415 | ||
434 | fprintf(pidf, "%d\n", pid); | ||
435 | fclose(pidf); | ||
436 | |||
437 | // Create a new SID for the child process | 416 | // Create a new SID for the child process |
438 | if (setsid() < 0) { | 417 | if (setsid() < 0) { |
439 | syslog(LOG_ERR, "SID creation failure. Exiting.\n"); | 418 | syslog(LOG_ERR, "SID creation failure. Exiting.\n"); |
@@ -454,6 +433,8 @@ int main(int argc, char *argv[]) | |||
454 | uint64_t last_LANdiscovery = 0; | 433 | uint64_t last_LANdiscovery = 0; |
455 | uint16_t htons_port = htons(port); | 434 | uint16_t htons_port = htons(port); |
456 | 435 | ||
436 | int waiting_for_dht_connection = 1; | ||
437 | |||
457 | while (1) { | 438 | while (1) { |
458 | do_DHT(dht); | 439 | do_DHT(dht); |
459 | 440 | ||
@@ -464,6 +445,11 @@ int main(int argc, char *argv[]) | |||
464 | 445 | ||
465 | networking_poll(dht->net); | 446 | networking_poll(dht->net); |
466 | 447 | ||
448 | if (waiting_for_dht_connection && DHT_isconnected(dht)) { | ||
449 | syslog(LOG_DEBUG, "Connected to other bootstrap server successfully.\n"); | ||
450 | waiting_for_dht_connection = 0; | ||
451 | } | ||
452 | |||
467 | sleep; | 453 | sleep; |
468 | } | 454 | } |
469 | 455 | ||
diff --git a/other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.sh b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.sh index 678db5e3..83d9a119 100644 --- a/other/bootstrap_serverdaemon/tox_dht_bootstrap_server_daemon.sh +++ b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.sh | |||
@@ -1,18 +1,19 @@ | |||
1 | #! /bin/sh | 1 | #! /bin/sh |
2 | ### BEGIN INIT INFO | 2 | ### BEGIN INIT INFO |
3 | # Provides: tox_dht_bootstrap_server_daemon | 3 | # Provides: tox_bootstrap_daemon |
4 | # Required-Start: $remote_fs $syslog | 4 | # Required-Start: $remote_fs $syslog |
5 | # Required-Stop: $remote_fs $syslog | 5 | # Required-Stop: $remote_fs $syslog |
6 | # Default-Start: 2 3 4 5 | 6 | # Default-Start: 2 3 4 5 |
7 | # Default-Stop: 0 1 6 | 7 | # Default-Stop: 0 1 6 |
8 | # Short-Description: Starts the Tox bootstrapping server | 8 | # Short-Description: Starts the Tox DHT bootstrapping server daemon |
9 | # Description: Starts the Tox bootstrapping server | 9 | # Description: Starts the Tox DHT bootstrapping server daemon |
10 | ### END INIT INFO | 10 | ### END INIT INFO |
11 | 11 | ||
12 | # PATH should only include /usr/* if it runs after the mountnfs.sh script | 12 | # PATH should only include /usr/* if it runs after the mountnfs.sh script |
13 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | 13 | PATH=/sbin:/usr/sbin:/bin:/usr/bin |
14 | DESC="ProjectTox bootstrap server daemon" | 14 | DESC="Tox DHT bootstrap server daemon" |
15 | NAME=tox_dht_bootstrap_server_daemon | 15 | NAME=tox_bootstrap_daemon |
16 | # You may want to change USER if you are using it anywhere else | ||
16 | USER=tom | 17 | USER=tom |
17 | CFG=/home/$USER/.$NAME/conf | 18 | CFG=/home/$USER/.$NAME/conf |
18 | DAEMON=/home/$USER/$NAME | 19 | DAEMON=/home/$USER/$NAME |