mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Updated readme and DHT.h
This commit is contained in:
parent
6e881efad6
commit
f3dfd885cc
11
README.md
11
README.md
|
@ -53,6 +53,13 @@ Proposal of a free as in freedom skype replacement:
|
||||||
|
|
||||||
"friends" list: A list containing the node_ids of all our "friends" or clients we want to connect to.
|
"friends" list: A list containing the node_ids of all our "friends" or clients we want to connect to.
|
||||||
Also contains the ip addresses + port + node_ids + timestamp(of last ping like in the client list) of the 8 clients closest (mathematically see bittorrent doc) to each "friend"
|
Also contains the ip addresses + port + node_ids + timestamp(of last ping like in the client list) of the 8 clients closest (mathematically see bittorrent doc) to each "friend"
|
||||||
|
|
||||||
|
Two pinged lists:
|
||||||
|
-One for storing a list of ips along with their ping_ids and a timestamp for the ping requests
|
||||||
|
-One for storing a list of ips along with their ping_ids and a timestamp for the get nodes requests
|
||||||
|
Entries in the pinged lists expire after 5 seconds.
|
||||||
|
If one of the lists becomes full, the expire rate reduces itself one second or the new ping takes the place of the oldest one.
|
||||||
|
|
||||||
|
|
||||||
Entries in client list and "friends" list expire after 300 seconds without ping response.
|
Entries in client list and "friends" list expire after 300 seconds without ping response.
|
||||||
Each client stores a maximum of 32 entries in its client list.
|
Each client stores a maximum of 32 entries in its client list.
|
||||||
|
@ -79,7 +86,7 @@ Proposal of a free as in freedom skype replacement:
|
||||||
|
|
||||||
When a client receives a response:
|
When a client receives a response:
|
||||||
-Ping response
|
-Ping response
|
||||||
-If the node was previously pinged with a matching ping_id
|
-If the node was previously pinged with a matching ping_id (check in the corresponding pinged list.)
|
||||||
-If the node is in the client list the matching client's timestamp is set to current time.
|
-If the node is in the client list the matching client's timestamp is set to current time.
|
||||||
-If the node is in the "friends" list the matching client's timestamp is set to current time for every occurrence.
|
-If the node is in the "friends" list the matching client's timestamp is set to current time for every occurrence.
|
||||||
-If the node is not in the client list:
|
-If the node is not in the client list:
|
||||||
|
@ -94,7 +101,7 @@ Proposal of a free as in freedom skype replacement:
|
||||||
-If not, nothing happens.
|
-If not, nothing happens.
|
||||||
|
|
||||||
-Send nodes
|
-Send nodes
|
||||||
-If the ping_id matches what we sent previously:
|
-If the ping_id matches what we sent previously (check in the corresponding pinged list.):
|
||||||
-Each node in the response is pinged.
|
-Each node in the response is pinged.
|
||||||
|
|
||||||
|
|
||||||
|
|
19
core/DHT.h
19
core/DHT.h
|
@ -53,6 +53,13 @@ typedef struct
|
||||||
|
|
||||||
}Friend;
|
}Friend;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
IP_Port ip_port;
|
||||||
|
uint32_t ping_id;
|
||||||
|
uint32_t timestamp;
|
||||||
|
|
||||||
|
}Pinged;
|
||||||
|
|
||||||
|
|
||||||
//Add a new friend to the friends list
|
//Add a new friend to the friends list
|
||||||
|
@ -92,6 +99,9 @@ void bootstrap(IP_Port ip_port);
|
||||||
|
|
||||||
//Global variables
|
//Global variables
|
||||||
|
|
||||||
|
//Our client id
|
||||||
|
char self_client_id[32];
|
||||||
|
|
||||||
//Our UDP socket.
|
//Our UDP socket.
|
||||||
//We only use one so it's much easier to have it as a global variable
|
//We only use one so it's much easier to have it as a global variable
|
||||||
int sock;
|
int sock;
|
||||||
|
@ -99,4 +109,11 @@ int sock;
|
||||||
Client_data client_list[32];
|
Client_data client_list[32];
|
||||||
|
|
||||||
//Let's start with a static array for testing.
|
//Let's start with a static array for testing.
|
||||||
Friend friends_list[256]
|
Friend friends_list[256];
|
||||||
|
uint16_t num_friends;
|
||||||
|
|
||||||
|
//The list of ip ports along with the ping_id of what we sent them and a timestamp
|
||||||
|
//TODO: make this more efficient looping up to 128 times is a bit...
|
||||||
|
Pinged pings[128];
|
||||||
|
|
||||||
|
Pinged send_nodes[64];
|
Loading…
Reference in New Issue
Block a user