From 330c1bee5ce3ccbca77f62336bfa84a0752a58ff Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Sat, 21 Sep 2013 02:02:27 +0200 Subject: [PATCH] nTox: keep bootstrap()ping every 10 seconds, until we get a connection running (the initial one might get lost, it IS done via UDP after all) nTox.c: - main(): keep calling tox_bootstrap_from_address() every 10 seconds, until the connection is established --- testing/nTox.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 33c8ab85..a9af5239 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -667,10 +667,19 @@ int main(int argc, char *argv[]) new_lines(whoami); } + time_t timestamp0 = time(NULL); while (1) { - if (on == 0 && tox_isconnected(m)) { - new_lines("[i] connected to DHT"); - on = 1; + if (on == 0) { + if (tox_isconnected(m)) { + new_lines("[i] connected to DHT"); + on = 1; + } else { + time_t timestamp1 = time(NULL); + if (timestamp0 + 10 < timestamp1) { + timestamp0 = timestamp1; + tox_bootstrap_from_address(m, argv[argvoffset + 1], ipv6enabled, port, binary_string); + } + } } tox_do(m);