summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--other/DHT_bootstrap.c8
-rw-r--r--toxcore/LAN_discovery.h2
-rw-r--r--toxcore/Messenger.c2
3 files changed, 10 insertions, 2 deletions
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 @@
31#endif 31#endif
32 32
33#include "../toxcore/DHT.h" 33#include "../toxcore/DHT.h"
34#include "../toxcore/LAN_discovery.h"
34#include "../toxcore/friend_requests.h" 35#include "../toxcore/friend_requests.h"
35#include "../testing/misc_tools.c" 36#include "../testing/misc_tools.c"
36 37
@@ -123,6 +124,9 @@ int main(int argc, char *argv[])
123 124
124 int is_waiting_for_dht_connection = 1; 125 int is_waiting_for_dht_connection = 1;
125 126
127 uint64_t last_LANdiscovery = 0;
128 LANdiscovery_init(dht);
129
126 while (1) { 130 while (1) {
127 if (is_waiting_for_dht_connection && DHT_isconnected(dht)) { 131 if (is_waiting_for_dht_connection && DHT_isconnected(dht)) {
128 printf("Connected to other bootstrap server successfully.\n"); 132 printf("Connected to other bootstrap server successfully.\n");
@@ -130,6 +134,10 @@ int main(int argc, char *argv[])
130 } 134 }
131 135
132 do_DHT(dht); 136 do_DHT(dht);
137 if (last_LANdiscovery + (is_waiting_for_dht_connection ? 5 : LAN_DISCOVERY_INTERVAL) < unix_time()) {
138 send_LANdiscovery(htons(PORT), dht->c);
139 last_LANdiscovery = unix_time();
140 }
133 141
134 networking_poll(dht->c->lossless_udp->net); 142 networking_poll(dht->c->lossless_udp->net);
135 143
diff --git a/toxcore/LAN_discovery.h b/toxcore/LAN_discovery.h
index 78990936..3e9d9de5 100644
--- a/toxcore/LAN_discovery.h
+++ b/toxcore/LAN_discovery.h
@@ -35,6 +35,8 @@
35#include <linux/netdevice.h> 35#include <linux/netdevice.h>
36#endif 36#endif
37 37
38/* Interval in seconds between LAN discovery packet sending. */
39#define LAN_DISCOVERY_INTERVAL 60
38 40
39/* Send a LAN discovery pcaket to the broadcast address with port port. */ 41/* Send a LAN discovery pcaket to the broadcast address with port port. */
40int send_LANdiscovery(uint16_t port, Net_Crypto *c); 42int send_LANdiscovery(uint16_t port, Net_Crypto *c);
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 99279d5e..951057c5 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -901,8 +901,6 @@ static void do_allgroupchats(Messenger *m)
901 901
902/*********************************/ 902/*********************************/
903 903
904/* Interval in seconds between LAN discovery packet sending. */
905#define LAN_DISCOVERY_INTERVAL 60
906#define PORT 33445 904#define PORT 33445
907 905
908/* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */ 906/* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */