mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Code Cleanups.
This commit is contained in:
parent
e658bc134b
commit
6936b2ebb5
|
@ -841,7 +841,7 @@ static int send_dht_fakeid(const Onion_Client *onion_c, int friend_num, const ui
|
||||||
if ((uint32_t)friend_num >= onion_c->num_friends)
|
if ((uint32_t)friend_num >= onion_c->num_friends)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!onion_c->friends_list[friend_num].is_fake_clientid)
|
if (!onion_c->friends_list[friend_num].is_fake_public_key)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
uint8_t nonce[crypto_box_NONCEBYTES];
|
uint8_t nonce[crypto_box_NONCEBYTES];
|
||||||
|
@ -1029,7 +1029,7 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num)
|
||||||
if ((uint32_t)friend_num >= onion_c->num_friends)
|
if ((uint32_t)friend_num >= onion_c->num_friends)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//if (onion_c->friends_list[friend_num].is_fake_clientid)
|
//if (onion_c->friends_list[friend_num].is_fake_public_key)
|
||||||
// DHT_delfriend(onion_c->dht, onion_c->friends_list[friend_num].fake_public_key, 0);
|
// DHT_delfriend(onion_c->dht, onion_c->friends_list[friend_num].fake_public_key, 0);
|
||||||
|
|
||||||
memset(&(onion_c->friends_list[friend_num]), 0, sizeof(Onion_Friend));
|
memset(&(onion_c->friends_list[friend_num]), 0, sizeof(Onion_Friend));
|
||||||
|
@ -1101,16 +1101,16 @@ int onion_set_friend_DHT_pubkey(Onion_Client *onion_c, int friend_num, const uin
|
||||||
if (onion_c->friends_list[friend_num].status == 0)
|
if (onion_c->friends_list[friend_num].status == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (onion_c->friends_list[friend_num].is_fake_clientid) {
|
if (onion_c->friends_list[friend_num].is_fake_public_key) {
|
||||||
if (memcmp(dht_key, onion_c->friends_list[friend_num].fake_public_key, crypto_box_PUBLICKEYBYTES) == 0) {
|
if (memcmp(dht_key, onion_c->friends_list[friend_num].fake_public_key, crypto_box_PUBLICKEYBYTES) == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
onion_c->friends_list[friend_num].is_fake_clientid = 0;
|
onion_c->friends_list[friend_num].is_fake_public_key = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
onion_c->friends_list[friend_num].last_seen = unix_time();
|
onion_c->friends_list[friend_num].last_seen = unix_time();
|
||||||
onion_c->friends_list[friend_num].is_fake_clientid = 1;
|
onion_c->friends_list[friend_num].is_fake_public_key = 1;
|
||||||
memcpy(onion_c->friends_list[friend_num].fake_public_key, dht_key, crypto_box_PUBLICKEYBYTES);
|
memcpy(onion_c->friends_list[friend_num].fake_public_key, dht_key, crypto_box_PUBLICKEYBYTES);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1129,7 +1129,7 @@ unsigned int onion_getfriend_DHT_pubkey(const Onion_Client *onion_c, int friend_
|
||||||
if (onion_c->friends_list[friend_num].status == 0)
|
if (onion_c->friends_list[friend_num].status == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!onion_c->friends_list[friend_num].is_fake_clientid)
|
if (!onion_c->friends_list[friend_num].is_fake_public_key)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memcpy(dht_key, onion_c->friends_list[friend_num].fake_public_key, crypto_box_PUBLICKEYBYTES);
|
memcpy(dht_key, onion_c->friends_list[friend_num].fake_public_key, crypto_box_PUBLICKEYBYTES);
|
||||||
|
|
|
@ -91,7 +91,7 @@ typedef struct {
|
||||||
uint8_t status; /* 0 if friend is not valid, 1 if friend is valid.*/
|
uint8_t status; /* 0 if friend is not valid, 1 if friend is valid.*/
|
||||||
uint8_t is_online; /* Set by the onion_set_friend_status function. */
|
uint8_t is_online; /* Set by the onion_set_friend_status function. */
|
||||||
|
|
||||||
uint8_t is_fake_clientid; /* 0 if we don't know the fake client id of the other 1 if we do. */
|
uint8_t is_fake_public_key; /* 0 if we don't know the fake public key of the other, 1 if we do. */
|
||||||
uint8_t fake_public_key[crypto_box_PUBLICKEYBYTES];
|
uint8_t fake_public_key[crypto_box_PUBLICKEYBYTES];
|
||||||
uint8_t real_public_key[crypto_box_PUBLICKEYBYTES];
|
uint8_t real_public_key[crypto_box_PUBLICKEYBYTES];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user