diff options
author | zugz (tox) <mbays+tox@sdf.org> | 2020-04-19 00:00:00 +0000 |
---|---|---|
committer | zugz (tox) <mbays+tox@sdf.org> | 2020-04-19 00:00:01 +0000 |
commit | 3ad953c6c3ccbe2e68ec4a23765c99997b0c5145 (patch) | |
tree | 04786b22ddb02c67b6dbc3e6c9d7e344537b13dc /toxcore/Messenger.c | |
parent | cdafc6ff5ee13595ecf5a4e1fe0cb28e255c37df (diff) |
fix saving of combination of loaded and connected TCP relays
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index c96a330f..945d6556 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -3140,13 +3140,14 @@ static uint8_t *save_tcp_relays(const Messenger *m, uint8_t *data) | |||
3140 | Node_format relays[NUM_SAVED_TCP_RELAYS]; | 3140 | Node_format relays[NUM_SAVED_TCP_RELAYS]; |
3141 | uint8_t *temp_data = data; | 3141 | uint8_t *temp_data = data; |
3142 | data = state_write_section_header(temp_data, STATE_COOKIE_TYPE, 0, STATE_TYPE_TCP_RELAY); | 3142 | data = state_write_section_header(temp_data, STATE_COOKIE_TYPE, 0, STATE_TYPE_TCP_RELAY); |
3143 | uint32_t num = copy_connected_tcp_relays(m->net_crypto, relays, NUM_SAVED_TCP_RELAYS); | ||
3144 | 3143 | ||
3145 | if (m->num_loaded_relays > 0) { | 3144 | if (m->num_loaded_relays > 0) { |
3146 | memcpy(relays, m->loaded_relays, sizeof(Node_format) * m->num_loaded_relays); | 3145 | memcpy(relays, m->loaded_relays, sizeof(Node_format) * m->num_loaded_relays); |
3147 | num = min_u32(num + m->num_loaded_relays, NUM_SAVED_TCP_RELAYS); | ||
3148 | } | 3146 | } |
3149 | 3147 | ||
3148 | uint32_t num = m->num_loaded_relays; | ||
3149 | num += copy_connected_tcp_relays(m->net_crypto, relays + num, NUM_SAVED_TCP_RELAYS - num); | ||
3150 | |||
3150 | int l = pack_nodes(data, NUM_SAVED_TCP_RELAYS * packed_node_size(net_family_tcp_ipv6), relays, num); | 3151 | int l = pack_nodes(data, NUM_SAVED_TCP_RELAYS * packed_node_size(net_family_tcp_ipv6), relays, num); |
3151 | 3152 | ||
3152 | if (l > 0) { | 3153 | if (l > 0) { |