mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge pull request #575 from FullName/DHT_bootstrap
Patch to allow DHT_bootstrap to also do LAN discovery.
This commit is contained in:
commit
983d36f70b
|
@ -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);
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include <linux/netdevice.h>
|
||||
#endif
|
||||
|
||||
/* Interval in seconds between LAN discovery packet sending. */
|
||||
#define LAN_DISCOVERY_INTERVAL 60
|
||||
|
||||
/* Send a LAN discovery pcaket to the broadcast address with port port. */
|
||||
int send_LANdiscovery(uint16_t port, Net_Crypto *c);
|
||||
|
|
|
@ -809,8 +809,6 @@ static void do_allgroupchats(Messenger *m)
|
|||
|
||||
/*********************************/
|
||||
|
||||
/* Interval in seconds between LAN discovery packet sending. */
|
||||
#define LAN_DISCOVERY_INTERVAL 60
|
||||
#define PORT 33445
|
||||
|
||||
/* Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds. */
|
||||
|
|
Loading…
Reference in New Issue
Block a user