diff options
author | Maxim Biro <nurupo.contributions@gmail.com> | 2016-12-08 03:03:04 -0500 |
---|---|---|
committer | Maxim Biro <nurupo.contributions@gmail.com> | 2016-12-14 21:48:21 -0500 |
commit | 68be33840a6a9b2677a6ab43068689c8e572e832 (patch) | |
tree | 8a0370fe510cdac359696843f0b1f139ec5641b4 /toxcore/friend_connection.c | |
parent | bbdd7982563b7d8f89fcd3b7297b5fbdf21fc57f (diff) |
Add option to disable local peer discovery
Diffstat (limited to 'toxcore/friend_connection.c')
-rw-r--r-- | toxcore/friend_connection.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/toxcore/friend_connection.c b/toxcore/friend_connection.c index f28720cb..2a99070b 100644 --- a/toxcore/friend_connection.c +++ b/toxcore/friend_connection.c | |||
@@ -811,7 +811,7 @@ int send_friend_request_packet(Friend_Connections *fr_c, int friendcon_id, uint3 | |||
811 | } | 811 | } |
812 | 812 | ||
813 | /* Create new friend_connections instance. */ | 813 | /* Create new friend_connections instance. */ |
814 | Friend_Connections *new_friend_connections(Onion_Client *onion_c) | 814 | Friend_Connections *new_friend_connections(Onion_Client *onion_c, bool local_discovery_enabled) |
815 | { | 815 | { |
816 | if (!onion_c) { | 816 | if (!onion_c) { |
817 | return NULL; | 817 | return NULL; |
@@ -826,9 +826,13 @@ Friend_Connections *new_friend_connections(Onion_Client *onion_c) | |||
826 | temp->dht = onion_c->dht; | 826 | temp->dht = onion_c->dht; |
827 | temp->net_crypto = onion_c->c; | 827 | temp->net_crypto = onion_c->c; |
828 | temp->onion_c = onion_c; | 828 | temp->onion_c = onion_c; |
829 | temp->local_discovery_enabled = local_discovery_enabled; | ||
829 | 830 | ||
830 | new_connection_handler(temp->net_crypto, &handle_new_connections, temp); | 831 | new_connection_handler(temp->net_crypto, &handle_new_connections, temp); |
831 | LANdiscovery_init(temp->dht); | 832 | |
833 | if (temp->local_discovery_enabled) { | ||
834 | LANdiscovery_init(temp->dht); | ||
835 | } | ||
832 | 836 | ||
833 | return temp; | 837 | return temp; |
834 | } | 838 | } |
@@ -889,7 +893,9 @@ void do_friend_connections(Friend_Connections *fr_c, void *userdata) | |||
889 | } | 893 | } |
890 | } | 894 | } |
891 | 895 | ||
892 | LANdiscovery(fr_c); | 896 | if (fr_c->local_discovery_enabled) { |
897 | LANdiscovery(fr_c); | ||
898 | } | ||
893 | } | 899 | } |
894 | 900 | ||
895 | /* Free everything related with friend_connections. */ | 901 | /* Free everything related with friend_connections. */ |
@@ -905,6 +911,9 @@ void kill_friend_connections(Friend_Connections *fr_c) | |||
905 | kill_friend_connection(fr_c, i); | 911 | kill_friend_connection(fr_c, i); |
906 | } | 912 | } |
907 | 913 | ||
908 | LANdiscovery_kill(fr_c->dht); | 914 | if (fr_c->local_discovery_enabled) { |
915 | LANdiscovery_kill(fr_c->dht); | ||
916 | } | ||
917 | |||
909 | free(fr_c); | 918 | free(fr_c); |
910 | } | 919 | } |