mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Removed some now useless code.
This commit is contained in:
parent
f607d66f39
commit
988922bdeb
|
@ -1706,75 +1706,6 @@ void kill_DHT(DHT *dht)
|
||||||
free(dht);
|
free(dht);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the size of the DHT (for saving). */
|
|
||||||
uint32_t DHT_size_old(DHT *dht)
|
|
||||||
{
|
|
||||||
return sizeof(dht->close_clientlist) + sizeof(DHT_Friend) * dht->num_friends;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Save the DHT in data where data is an array of size DHT_size(). */
|
|
||||||
void DHT_save_old(DHT *dht, uint8_t *data)
|
|
||||||
{
|
|
||||||
memcpy(data, dht->close_clientlist, sizeof(dht->close_clientlist));
|
|
||||||
memcpy(data + sizeof(dht->close_clientlist), dht->friends_list, sizeof(DHT_Friend) * dht->num_friends);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load the DHT from data of size size.
|
|
||||||
*
|
|
||||||
* return -1 if failure.
|
|
||||||
* return 0 if success.
|
|
||||||
*/
|
|
||||||
int DHT_load_old(DHT *dht, uint8_t *data, uint32_t size)
|
|
||||||
{
|
|
||||||
size_t clientlist_oldsize = sizeof(Client_data_old) * LCLIENT_LIST;
|
|
||||||
|
|
||||||
if (size < clientlist_oldsize) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "DHT_load: Expected at least %u bytes, got %u.\n", sizeof(dht->close_clientlist), size);
|
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t friendlistsize = size - clientlist_oldsize;
|
|
||||||
|
|
||||||
if (friendlistsize % sizeof(DHT_Friend_old) != 0) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "DHT_load: Expected a multiple of %u, got %u.\n", sizeof(DHT_Friend), friendlistsize);
|
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t i, j;
|
|
||||||
Client_data_old *client;
|
|
||||||
uint16_t friends_num = friendlistsize / sizeof(DHT_Friend_old);
|
|
||||||
|
|
||||||
if (friends_num != 0) {
|
|
||||||
DHT_Friend_old *tempfriends_list = (DHT_Friend_old *)(data + sizeof(dht->close_clientlist));
|
|
||||||
|
|
||||||
for (i = 0; i < friends_num; ++i) {
|
|
||||||
DHT_addfriend(dht, tempfriends_list[i].client_id);
|
|
||||||
|
|
||||||
for (j = 0; j < MAX_FRIEND_CLIENTS; ++j) {
|
|
||||||
client = &tempfriends_list[i].client_list[j];
|
|
||||||
|
|
||||||
if (client->assoc.timestamp != 0)
|
|
||||||
getnodes(dht, client->assoc.ip_port, client->client_id, tempfriends_list[i].client_id, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Client_data_old *tempclose_clientlist = (Client_data_old *)data;
|
|
||||||
|
|
||||||
for (i = 0; i < LCLIENT_LIST; ++i) {
|
|
||||||
if (tempclose_clientlist[i].assoc.timestamp != 0)
|
|
||||||
DHT_bootstrap(dht, tempclose_clientlist[i].assoc.ip_port,
|
|
||||||
tempclose_clientlist[i].client_id );
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* new DHT format for load/save, more robust and forward compatible */
|
/* new DHT format for load/save, more robust and forward compatible */
|
||||||
|
|
||||||
#define DHT_STATE_COOKIE_GLOBAL 0x159000d
|
#define DHT_STATE_COOKIE_GLOBAL 0x159000d
|
||||||
|
|
|
@ -48,11 +48,6 @@ typedef struct {
|
||||||
uint64_t ret_timestamp;
|
uint64_t ret_timestamp;
|
||||||
} IPPTsPng;
|
} IPPTsPng;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t client_id[CLIENT_ID_SIZE];
|
|
||||||
IPPTsPng assoc;
|
|
||||||
} Client_data_old; /* required to load old state files */
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t client_id[CLIENT_ID_SIZE];
|
uint8_t client_id[CLIENT_ID_SIZE];
|
||||||
IPPTsPng assoc4;
|
IPPTsPng assoc4;
|
||||||
|
@ -86,18 +81,6 @@ typedef struct {
|
||||||
uint64_t testing_timestamp;
|
uint64_t testing_timestamp;
|
||||||
} Hardening;
|
} Hardening;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t client_id[CLIENT_ID_SIZE];
|
|
||||||
Client_data_old client_list[MAX_FRIEND_CLIENTS];
|
|
||||||
|
|
||||||
/* Time at which the last get_nodes request was sent. */
|
|
||||||
uint64_t lastgetnode;
|
|
||||||
|
|
||||||
Hardening hardening;
|
|
||||||
/* Symetric NAT hole punching stuff. */
|
|
||||||
NAT nat;
|
|
||||||
} DHT_Friend_old; /* required to load old state files */
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t client_id[CLIENT_ID_SIZE];
|
uint8_t client_id[CLIENT_ID_SIZE];
|
||||||
Client_data client_list[MAX_FRIEND_CLIENTS];
|
Client_data client_list[MAX_FRIEND_CLIENTS];
|
||||||
|
@ -249,15 +232,6 @@ DHT *new_DHT(Net_Crypto *c);
|
||||||
|
|
||||||
void kill_DHT(DHT *dht);
|
void kill_DHT(DHT *dht);
|
||||||
|
|
||||||
/* Load the DHT from data of size size.
|
|
||||||
* old/new: version of config file
|
|
||||||
*
|
|
||||||
* return -1 if failure.
|
|
||||||
* return 0 if success.
|
|
||||||
*/
|
|
||||||
int DHT_load_old(DHT *dht, uint8_t *data, uint32_t size);
|
|
||||||
int DHT_load_new(DHT *dht, uint8_t *data, uint32_t size);
|
|
||||||
|
|
||||||
/* return 0 if we are not connected to the DHT.
|
/* return 0 if we are not connected to the DHT.
|
||||||
* return 1 if we are.
|
* return 1 if we are.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user