diff options
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 7ea89ea6..e138b23e 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -2803,18 +2803,11 @@ static int messenger_load_state_callback(void *outer, const uint8_t *data, uint3 | |||
2803 | break; | 2803 | break; |
2804 | 2804 | ||
2805 | case MESSENGER_STATE_TYPE_TCP_RELAY: { | 2805 | case MESSENGER_STATE_TYPE_TCP_RELAY: { |
2806 | Node_format relays[NUM_SAVED_TCP_RELAYS]; | 2806 | if (length != sizeof(m->loaded_relays)) { |
2807 | |||
2808 | if (length != sizeof(relays)) { | ||
2809 | return -1; | 2807 | return -1; |
2810 | } | 2808 | } |
2811 | 2809 | ||
2812 | memcpy(relays, data, length); | 2810 | memcpy(m->loaded_relays, data, length); |
2813 | uint32_t i; | ||
2814 | |||
2815 | for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) { | ||
2816 | add_tcp_relay(m->net_crypto, relays[i].ip_port, relays[i].client_id); | ||
2817 | } | ||
2818 | 2811 | ||
2819 | break; | 2812 | break; |
2820 | } | 2813 | } |
@@ -2866,6 +2859,25 @@ int messenger_load(Messenger *m, const uint8_t *data, uint32_t length) | |||
2866 | return -1; | 2859 | return -1; |
2867 | } | 2860 | } |
2868 | 2861 | ||
2862 | /* Connect after loading messenger from file */ | ||
2863 | int messenger_connect(Messenger *m) | ||
2864 | { | ||
2865 | int i; | ||
2866 | |||
2867 | if(m == NULL) | ||
2868 | return -1; | ||
2869 | |||
2870 | DHT *dht = m->dht; | ||
2871 | if(DHT_connect_after_load(dht) == -1) | ||
2872 | return -1; | ||
2873 | |||
2874 | for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) { | ||
2875 | add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].client_id); | ||
2876 | } | ||
2877 | |||
2878 | return 0; | ||
2879 | } | ||
2880 | |||
2869 | /* Return the number of friends in the instance m. | 2881 | /* Return the number of friends in the instance m. |
2870 | * You should use this to determine how much memory to allocate | 2882 | * You should use this to determine how much memory to allocate |
2871 | * for copy_friendlist. */ | 2883 | * for copy_friendlist. */ |