mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Pack onion path nodes in save.
This commit is contained in:
parent
defdc879f0
commit
05ad1234d2
|
@ -2547,7 +2547,7 @@ uint32_t messenger_size(const Messenger *m)
|
||||||
+ sizesubhead + m->statusmessage_length // status message
|
+ sizesubhead + m->statusmessage_length // status message
|
||||||
+ sizesubhead + 1 // status
|
+ sizesubhead + 1 // status
|
||||||
+ sizesubhead + NUM_SAVED_TCP_RELAYS * packed_node_size(TCP_INET6) //TCP relays
|
+ sizesubhead + NUM_SAVED_TCP_RELAYS * packed_node_size(TCP_INET6) //TCP relays
|
||||||
+ sizesubhead + NUM_SAVED_PATH_NODES * sizeof(Node_format) //saved path nodes
|
+ sizesubhead + NUM_SAVED_PATH_NODES * packed_node_size(TCP_INET6) //saved path nodes
|
||||||
+ sizesubhead;
|
+ sizesubhead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2628,13 +2628,18 @@ void messenger_save(const Messenger *m, uint8_t *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
Node_format nodes[NUM_SAVED_PATH_NODES];
|
Node_format nodes[NUM_SAVED_PATH_NODES];
|
||||||
len = sizeof(nodes);
|
|
||||||
type = MESSENGER_STATE_TYPE_PATH_NODE;
|
type = MESSENGER_STATE_TYPE_PATH_NODE;
|
||||||
data = z_state_save_subheader(data, len, type);
|
temp_data = data;
|
||||||
memset(nodes, 0, len);
|
data = z_state_save_subheader(data, 0, type);
|
||||||
onion_backup_nodes(m->onion_c, nodes, NUM_SAVED_PATH_NODES);
|
memset(nodes, 0, sizeof(nodes));
|
||||||
memcpy(data, nodes, len);
|
num = onion_backup_nodes(m->onion_c, nodes, NUM_SAVED_PATH_NODES);
|
||||||
data += len;
|
l = pack_nodes(data, NUM_SAVED_PATH_NODES * packed_node_size(TCP_INET6), nodes, num);
|
||||||
|
|
||||||
|
if (l > 0) {
|
||||||
|
len = l;
|
||||||
|
data = z_state_save_subheader(temp_data, len, type);
|
||||||
|
data += len;
|
||||||
|
}
|
||||||
|
|
||||||
z_state_save_subheader(data, 0, MESSENGER_STATE_TYPE_END);
|
z_state_save_subheader(data, 0, MESSENGER_STATE_TYPE_END);
|
||||||
}
|
}
|
||||||
|
@ -2704,10 +2709,9 @@ static int messenger_load_state_callback(void *outer, const uint8_t *data, uint3
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(nodes, data, length);
|
int i, num = unpack_nodes(nodes, NUM_SAVED_PATH_NODES, 0, data, length, 0);
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_SAVED_PATH_NODES; ++i) {
|
for (i = 0; i < num; ++i) {
|
||||||
onion_add_bs_path_node(m->onion_c, nodes[i].ip_port, nodes[i].public_key);
|
onion_add_bs_path_node(m->onion_c, nodes[i].ip_port, nodes[i].public_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user