mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed spacing
This commit is contained in:
parent
f771bfbe30
commit
98a93c7880
|
@ -2335,54 +2335,54 @@ void DHT_save(DHT *dht, uint8_t *data)
|
||||||
|
|
||||||
static void DHT_bootstrap_loaded_clients(DHT *dht)
|
static void DHT_bootstrap_loaded_clients(DHT *dht)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
Client_data *client_list = dht->loaded_clients_list;
|
Client_data *client_list = dht->loaded_clients_list;
|
||||||
uint32_t client_count = dht->loaded_num_clients;
|
uint32_t client_count = dht->loaded_num_clients;
|
||||||
|
|
||||||
for (i = 0; i < client_count; ++i) {
|
for (i = 0; i < client_count; ++i) {
|
||||||
if (client_list[i].assoc4.timestamp != 0)
|
if (client_list[i].assoc4.timestamp != 0)
|
||||||
DHT_bootstrap(dht, client_list[i].assoc4.ip_port, client_list[i].client_id);
|
DHT_bootstrap(dht, client_list[i].assoc4.ip_port, client_list[i].client_id);
|
||||||
|
|
||||||
if (client_list[i].assoc6.timestamp != 0)
|
if (client_list[i].assoc6.timestamp != 0)
|
||||||
DHT_bootstrap(dht, client_list[i].assoc6.ip_port, client_list[i].client_id);
|
DHT_bootstrap(dht, client_list[i].assoc6.ip_port, client_list[i].client_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void getnodes_of_loaded_friend_clients(DHT *dht)
|
static void getnodes_of_loaded_friend_clients(DHT *dht)
|
||||||
{
|
{
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
|
|
||||||
DHT_Friend *friend_list = dht->loaded_friends_list;
|
DHT_Friend *friend_list = dht->loaded_friends_list;
|
||||||
uint32_t friend_count = dht->loaded_num_friends;
|
uint32_t friend_count = dht->loaded_num_friends;
|
||||||
|
|
||||||
for (i = 0; i < friend_count; ++i) {
|
for (i = 0; i < friend_count; ++i) {
|
||||||
for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) {
|
for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) {
|
||||||
Client_data *client = &friend_list[i].client_list[j];
|
Client_data *client = &friend_list[i].client_list[j];
|
||||||
|
|
||||||
if (client->assoc4.timestamp != 0)
|
if (client->assoc4.timestamp != 0)
|
||||||
getnodes(dht, client->assoc4.ip_port, client->client_id, friend_list[i].client_id, NULL);
|
getnodes(dht, client->assoc4.ip_port, client->client_id, friend_list[i].client_id, NULL);
|
||||||
|
|
||||||
if (client->assoc6.timestamp != 0)
|
if (client->assoc6.timestamp != 0)
|
||||||
getnodes(dht, client->assoc6.ip_port, client->client_id, friend_list[i].client_id, NULL);
|
getnodes(dht, client->assoc6.ip_port, client->client_id, friend_list[i].client_id, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start sending packets after DHT loaded_friends_list and loaded_clients_list are set */
|
/* Start sending packets after DHT loaded_friends_list and loaded_clients_list are set */
|
||||||
int DHT_connect_after_load(DHT *dht)
|
int DHT_connect_after_load(DHT *dht)
|
||||||
{
|
{
|
||||||
if(dht == NULL || dht->loaded_friends_list == NULL || dht->loaded_clients_list == NULL)
|
if(dht == NULL || dht->loaded_friends_list == NULL || dht->loaded_clients_list == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
getnodes_of_loaded_friend_clients(dht);
|
getnodes_of_loaded_friend_clients(dht);
|
||||||
DHT_bootstrap_loaded_clients(dht);
|
DHT_bootstrap_loaded_clients(dht);
|
||||||
|
|
||||||
// Loaded lists were allocd, free them
|
// Loaded lists were allocd, free them
|
||||||
free(dht->loaded_friends_list);
|
free(dht->loaded_friends_list);
|
||||||
free(dht->loaded_clients_list);
|
free(dht->loaded_clients_list);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t length, uint16_t type)
|
static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t length, uint16_t type)
|
||||||
|
@ -2399,11 +2399,11 @@ static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t le
|
||||||
DHT_Friend *friend_list = (DHT_Friend *)data;
|
DHT_Friend *friend_list = (DHT_Friend *)data;
|
||||||
num = length / sizeof(DHT_Friend);
|
num = length / sizeof(DHT_Friend);
|
||||||
|
|
||||||
// Copy to loaded_friends_list
|
// Copy to loaded_friends_list
|
||||||
dht->loaded_friends_list = calloc(num, sizeof(DHT_Friend));
|
dht->loaded_friends_list = calloc(num, sizeof(DHT_Friend));
|
||||||
for(i = 0; i < num; i++)
|
for(i = 0; i < num; i++)
|
||||||
memcpy(&(dht->loaded_friends_list[i]), &(friend_list[i]), sizeof(DHT_Friend));
|
memcpy(&(dht->loaded_friends_list[i]), &(friend_list[i]), sizeof(DHT_Friend));
|
||||||
dht->loaded_num_friends = num;
|
dht->loaded_num_friends = num;
|
||||||
|
|
||||||
} /* localize declarations */
|
} /* localize declarations */
|
||||||
|
|
||||||
|
@ -2417,11 +2417,11 @@ static int dht_load_state_callback(void *outer, const uint8_t *data, uint32_t le
|
||||||
num = length / sizeof(Client_data);
|
num = length / sizeof(Client_data);
|
||||||
Client_data *client_list = (Client_data *)data;
|
Client_data *client_list = (Client_data *)data;
|
||||||
|
|
||||||
// Copy to loaded_clients_list
|
// Copy to loaded_clients_list
|
||||||
dht->loaded_clients_list = calloc(num, sizeof(Client_data));
|
dht->loaded_clients_list = calloc(num, sizeof(Client_data));
|
||||||
for(i = 0; i < num; i++)
|
for(i = 0; i < num; i++)
|
||||||
memcpy(&(dht->loaded_clients_list[i]), &(client_list[i]), sizeof(Client_data));
|
memcpy(&(dht->loaded_clients_list[i]), &(client_list[i]), sizeof(Client_data));
|
||||||
dht->loaded_num_clients = num;
|
dht->loaded_num_clients = num;
|
||||||
|
|
||||||
} /* localize declarations */
|
} /* localize declarations */
|
||||||
|
|
||||||
|
|
|
@ -200,12 +200,12 @@ typedef struct {
|
||||||
DHT_Friend *friends_list;
|
DHT_Friend *friends_list;
|
||||||
uint16_t num_friends;
|
uint16_t num_friends;
|
||||||
|
|
||||||
// Used after loading of file (tox_load), but no longer needed after connect (tox_connect)
|
// Used after loading of file (tox_load), but no longer needed after connect (tox_connect)
|
||||||
// Unsure if friends_list and num_friends could just be used instead?
|
// Unsure if friends_list and num_friends could just be used instead?
|
||||||
DHT_Friend *loaded_friends_list;
|
DHT_Friend *loaded_friends_list;
|
||||||
uint32_t loaded_num_friends;
|
uint32_t loaded_num_friends;
|
||||||
Client_data *loaded_clients_list;
|
Client_data *loaded_clients_list;
|
||||||
uint32_t loaded_num_clients;
|
uint32_t loaded_num_clients;
|
||||||
|
|
||||||
Shared_Keys shared_keys_recv;
|
Shared_Keys shared_keys_recv;
|
||||||
Shared_Keys shared_keys_sent;
|
Shared_Keys shared_keys_sent;
|
||||||
|
|
|
@ -2862,20 +2862,20 @@ int messenger_load(Messenger *m, const uint8_t *data, uint32_t length)
|
||||||
/* Connect after loading messenger from file */
|
/* Connect after loading messenger from file */
|
||||||
int messenger_connect(Messenger *m)
|
int messenger_connect(Messenger *m)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(m == NULL)
|
if(m == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
DHT *dht = m->dht;
|
DHT *dht = m->dht;
|
||||||
if(DHT_connect_after_load(dht) == -1)
|
if(DHT_connect_after_load(dht) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) {
|
for (i = 0; i < NUM_SAVED_TCP_RELAYS; ++i) {
|
||||||
add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].client_id);
|
add_tcp_relay(m->net_crypto, m->loaded_relays[i].ip_port, m->loaded_relays[i].client_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the number of friends in the instance m.
|
/* Return the number of friends in the instance m.
|
||||||
|
|
|
@ -219,9 +219,9 @@ typedef struct Messenger {
|
||||||
|
|
||||||
uint64_t last_LANdiscovery;
|
uint64_t last_LANdiscovery;
|
||||||
|
|
||||||
// Relays loaded from config
|
// Relays loaded from config
|
||||||
// 8 should be NUM_SAVED_TCP_RELAYS but it is defined in c file
|
// 8 should be NUM_SAVED_TCP_RELAYS but it is defined in c file
|
||||||
Node_format loaded_relays[8];
|
Node_format loaded_relays[8];
|
||||||
|
|
||||||
void (*friend_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
|
void (*friend_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
|
||||||
void *friend_message_userdata;
|
void *friend_message_userdata;
|
||||||
|
|
|
@ -932,6 +932,6 @@ int tox_load(Tox *tox, const uint8_t *data, uint32_t length)
|
||||||
/* Connect after loading the messenger from file */
|
/* Connect after loading the messenger from file */
|
||||||
int tox_connect(Tox *tox)
|
int tox_connect(Tox *tox)
|
||||||
{
|
{
|
||||||
Messenger *m = tox;
|
Messenger *m = tox;
|
||||||
return messenger_connect(m);
|
return messenger_connect(m);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user