From b5db32585a89749ce8e91348d176292cdc20abfd Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Thu, 12 Sep 2013 19:09:25 +0200 Subject: Patch to allow DHT_bootstrap to also do LAN discovery. This patch inserts LAN discovery in DHT_bootstrap, allowing it to find clients even if it's run parameterless (and clients don't connect to it directly, e.g. because the port is already bound to a different client). - moves the #define of LAN_DISCOVERY_INTERVAL from Messenger.c to LAN_discovery.h - includes LAN_discovery.h into DHT_bootstrap.c - DHT_bootstrap.c sends and accepts LAN_discovery packets --- other/DHT_bootstrap.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'other/DHT_bootstrap.c') diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c index 654b759f..aed17020 100644 --- a/other/DHT_bootstrap.c +++ b/other/DHT_bootstrap.c @@ -31,6 +31,7 @@ #endif #include "../toxcore/DHT.h" +#include "../toxcore/LAN_discovery.h" #include "../toxcore/friend_requests.h" #include "../testing/misc_tools.c" @@ -123,6 +124,9 @@ int main(int argc, char *argv[]) int is_waiting_for_dht_connection = 1; + uint64_t last_LANdiscovery = 0; + LANdiscovery_init(dht); + while (1) { if (is_waiting_for_dht_connection && DHT_isconnected(dht)) { printf("Connected to other bootstrap server successfully.\n"); @@ -130,6 +134,10 @@ int main(int argc, char *argv[]) } do_DHT(dht); + if (last_LANdiscovery + (is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL) < unix_time()) { + send_LANdiscovery(htons(PORT), dht->c); + last_LANdiscovery = unix_time(); + } networking_poll(dht->c->lossless_udp->net); -- cgit v1.2.3