mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Spelling mistakes fixed.
This commit is contained in:
parent
9a0d749083
commit
c00cf85078
|
@ -246,7 +246,7 @@ int get_close_nodes(uint8_t * client_id, Node_format * nodes_list)
|
|||
|
||||
|
||||
//replace first bad (or empty) node with this one
|
||||
//return 0 if successfull
|
||||
//return 0 if successful
|
||||
//return 1 if not (list contains no bad nodes)
|
||||
int replace_bad(Client_data * list, uint32_t length, uint8_t * client_id, IP_Port ip_port)//tested
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ void addto_lists(IP_Port ip_port, uint8_t * client_id)
|
|||
{
|
||||
uint32_t i;
|
||||
|
||||
//NOTE: current behaviour if there are two clients with the same id is to only keep one (the first one)
|
||||
//NOTE: current behavior if there are two clients with the same id is to only keep one (the first one)
|
||||
if(!client_in_list(close_clientlist, LCLIENT_LIST, client_id, ip_port))
|
||||
{
|
||||
|
||||
|
@ -548,7 +548,7 @@ int sendnodes(IP_Port ip_port, uint8_t * client_id, uint32_t ping_id)
|
|||
|
||||
|
||||
//Packet handling functions
|
||||
//One to handle each types of packets we recieve
|
||||
//One to handle each types of packets we receive
|
||||
//return 0 if handled correctly, 1 if packet is bad.
|
||||
int handle_pingreq(uint8_t * packet, uint32_t length, IP_Port source)//tested
|
||||
{
|
||||
|
|
|
@ -62,7 +62,7 @@ IP_Port DHT_getfriendip(uint8_t * client_id);
|
|||
//Run this function at least a couple times per second (It's the main loop)
|
||||
void doDHT();
|
||||
|
||||
//if we recieve a DHT packet we call this function so it can be handled.
|
||||
//if we receive a DHT packet we call this function so it can be handled.
|
||||
//Return 0 if packet is handled correctly.
|
||||
//return 1 if it didn't handle the packet or if the packet was shit.
|
||||
int DHT_handlepacket(uint8_t * packet, uint32_t length, IP_Port source);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
|
||||
//maximum data packets in sent and recieve queues.
|
||||
//maximum data packets in sent and receive queues.
|
||||
#define MAX_QUEUE_NUM 16
|
||||
|
||||
//maximum length of the data in the data packets
|
||||
|
@ -66,14 +66,14 @@ typedef struct
|
|||
uint16_t data_rate;//current data packet send rate packets per second.
|
||||
uint64_t last_SYNC; //time at which our last SYNC packet was sent.
|
||||
uint64_t last_sent; //time at which our last data or handshake packet was sent.
|
||||
uint64_t last_recv; //time at which we last recieved something from the other
|
||||
uint64_t last_recv; //time at which we last received something from the other
|
||||
uint64_t killat; //time at which to kill the connection
|
||||
Data sendbuffer[MAX_QUEUE_NUM];//packet send buffer.
|
||||
Data recvbuffer[MAX_QUEUE_NUM];//packet recieve buffer.
|
||||
Data recvbuffer[MAX_QUEUE_NUM];//packet receive buffer.
|
||||
uint32_t handshake_id1;
|
||||
uint32_t handshake_id2;
|
||||
uint32_t recv_packetnum; //number of data packets recieved (also used as handshake_id1)
|
||||
uint32_t orecv_packetnum; //number of packets recieved by the other peer
|
||||
uint32_t recv_packetnum; //number of data packets received (also used as handshake_id1)
|
||||
uint32_t orecv_packetnum; //number of packets received by the other peer
|
||||
uint32_t sent_packetnum; //number of data packets sent
|
||||
uint32_t osent_packetnum; //number of packets sent by the other peer.
|
||||
uint32_t sendbuff_packetnum; //number of latest packet written onto the sendbuffer
|
||||
|
@ -250,7 +250,7 @@ int kill_connection_in(int connection_id, uint32_t seconds)
|
|||
//return 1 if attempting handshake
|
||||
//return 2 if handshake is done
|
||||
//return 3 if fully connected
|
||||
//return 4 if timed out and wating to be killed
|
||||
//return 4 if timed out and waiting to be killed
|
||||
int is_connected(int connection_id)
|
||||
{
|
||||
if(connection_id >= 0 && connection_id < MAX_CONNECTIONS)
|
||||
|
@ -450,7 +450,7 @@ int send_DATA(uint32_t connection_id)
|
|||
|
||||
|
||||
//Packet handling functions
|
||||
//One to handle each type of packets we recieve
|
||||
//One to handle each type of packets we receive
|
||||
//return 0 if handled correctly, 1 if packet is bad.
|
||||
int handle_handshake(uint8_t * packet, uint32_t length, IP_Port source)
|
||||
{
|
||||
|
@ -607,7 +607,7 @@ int handle_SYNC(uint8_t * packet, uint32_t length, IP_Port source)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//add a packet to the recieved buffer and set the recv_packetnum of the connection to its proper value.
|
||||
//add a packet to the received buffer and set the recv_packetnum of the connection to its proper value.
|
||||
//return 1 if data was too big, 0 if not.
|
||||
int add_recv(int connection_id, uint32_t data_num, uint8_t * data, uint16_t size)
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ IP_Port connection_ip(int connection_id);
|
|||
char id_packet(int connection_id);
|
||||
|
||||
//return 0 if there is no received data in the buffer.
|
||||
//return length of recieved packet if successful
|
||||
//return length of received packet if successful
|
||||
int read_packet(int connection_id, uint8_t * data);
|
||||
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
|
|||
typedef struct
|
||||
{
|
||||
uint8_t public_key[crypto_box_PUBLICKEYBYTES];//the real public key of the peer.
|
||||
uint8_t recv_nonce[crypto_box_NONCEBYTES];//nonce of recieved packets
|
||||
uint8_t recv_nonce[crypto_box_NONCEBYTES];//nonce of received packets
|
||||
uint8_t sent_nonce[crypto_box_NONCEBYTES];//nonce of sent packets.
|
||||
uint8_t sessionpublic_key[crypto_box_PUBLICKEYBYTES];//our public key for this session.
|
||||
uint8_t sessionsecret_key[crypto_box_SECRETKEYBYTES];//our private key for this session.
|
||||
uint8_t peersessionpublic_key[crypto_box_PUBLICKEYBYTES];//The public key of the peer.
|
||||
uint8_t status;//0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet
|
||||
//(we have recieved a hanshake but no empty data packet), 3 if the connection is established.
|
||||
//(we have received a handshake but no empty data packet), 3 if the connection is established.
|
||||
//4 if the connection is timed out.
|
||||
uint16_t number; //Lossless_UDP connection number corresponding to this connection.
|
||||
|
||||
|
@ -63,7 +63,7 @@ int outbound_friendrequests[MAX_FRIEND_REQUESTS];
|
|||
int incoming_connections[MAX_INCOMING];
|
||||
|
||||
//encrypts plain of length length to encrypted of length + 16 using the
|
||||
//public key(32 bytes) of the reciever and the secret key of the sender and a 24 byte nonce
|
||||
//public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce
|
||||
//return -1 if there was a problem.
|
||||
//return length of encrypted data if everything was fine.
|
||||
int encrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
|
||||
|
@ -93,7 +93,7 @@ int encrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
|
|||
}
|
||||
|
||||
//decrypts encrypted of length length to plain of length length - 16 using the
|
||||
//public key(32 bytes) of the sender, the secret key of the reciever and a 24 byte nonce
|
||||
//public key(32 bytes) of the sender, the secret key of the receiver and a 24 byte nonce
|
||||
//return -1 if there was a problem(decryption failed)
|
||||
//return length of plain data if everything was fine.
|
||||
int decrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
|
||||
|
@ -151,7 +151,7 @@ void random_nonce(uint8_t * nonce)
|
|||
|
||||
//return 0 if there is no received data in the buffer
|
||||
//return -1 if the packet was discarded.
|
||||
//return length of recieved data if successful
|
||||
//return length of received data if successful
|
||||
int read_cryptpacket(int crypt_connection_id, uint8_t * data)
|
||||
{
|
||||
if(crypt_connection_id < 0 || crypt_connection_id >= MAX_CRYPTO_CONNECTIONS)
|
||||
|
@ -436,7 +436,7 @@ int crypto_connect(uint8_t * public_key, IP_Port ip_port)
|
|||
|
||||
//handle an incoming connection
|
||||
//return -1 if no crypto inbound connection
|
||||
//return incomming connection id (Lossless_UDP one) if there is an incomming crypto connection
|
||||
//return incoming connection id (Lossless_UDP one) if there is an incoming crypto connection
|
||||
//Put the public key of the peer in public_key, the secret_nonce from the handshake into secret_nonce
|
||||
//and the session public key for the connection in session_key
|
||||
//to accept it see: accept_crypto_inbound(...)
|
||||
|
@ -524,8 +524,8 @@ int accept_crypto_inbound(int connection_id, uint8_t * public_key, uint8_t * sec
|
|||
}
|
||||
|
||||
//return 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet
|
||||
//(we have recieved a hanshake but no empty data packet), 3 if the connection is established.
|
||||
//4 if the connection is timed out and wating to be killed
|
||||
//(we have received a handshake but no empty data packet), 3 if the connection is established.
|
||||
//4 if the connection is timed out and waiting to be killed
|
||||
int is_cryptoconnected(int crypt_connection_id)
|
||||
{
|
||||
if(crypt_connection_id >= 0 && crypt_connection_id < MAX_CRYPTO_CONNECTIONS)
|
||||
|
@ -580,8 +580,8 @@ void handle_incomings()
|
|||
}
|
||||
}
|
||||
|
||||
//handle recieved packets for not yet established crypto connections.
|
||||
void recieve_crypto()
|
||||
//handle received packets for not yet established crypto connections.
|
||||
void receive_crypto()
|
||||
{
|
||||
uint32_t i;
|
||||
for(i = 0; i < MAX_CRYPTO_CONNECTIONS; i++)
|
||||
|
@ -678,6 +678,6 @@ void doNetCrypto()
|
|||
//handle new incoming connections
|
||||
//handle friend requests
|
||||
handle_incomings();
|
||||
recieve_crypto();
|
||||
receive_crypto();
|
||||
killTimedout();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ extern uint8_t self_public_key[crypto_box_PUBLICKEYBYTES];
|
|||
|
||||
|
||||
//encrypts plain of length length to encrypted of length + 16 using the
|
||||
//public key(32 bytes) of the reciever and the secret key of the sender and a 24 byte nonce
|
||||
//public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce
|
||||
//return -1 if there was a problem.
|
||||
//return length of encrypted data if everything was fine.
|
||||
int encrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
|
||||
|
@ -44,7 +44,7 @@ int encrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
|
|||
|
||||
|
||||
//decrypts encrypted of length length to plain of length length - 16 using the
|
||||
//public key(32 bytes) of the sender, the secret key of the reciever and a 24 byte nonce
|
||||
//public key(32 bytes) of the sender, the secret key of the receiver and a 24 byte nonce
|
||||
//return -1 if there was a problem(decryption failed)
|
||||
//return length of plain data if everything was fine.
|
||||
int decrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
|
||||
|
@ -53,7 +53,7 @@ int decrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce,
|
|||
|
||||
//return 0 if there is no received data in the buffer
|
||||
//return -1 if the packet was discarded.
|
||||
//return length of recieved data if successful
|
||||
//return length of received data if successful
|
||||
int read_cryptpacket(int crypt_connection_id, uint8_t * data);
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ int crypto_kill(int crypt_connection_id);
|
|||
|
||||
//handle an incoming connection
|
||||
//return -1 if no crypto inbound connection
|
||||
//return incomming connection id (Lossless_UDP one) if there is an incomming crypto connection
|
||||
//return incoming connection id (Lossless_UDP one) if there is an incoming crypto connection
|
||||
//Put the public key of the peer in public_key, the secret_nonce from the handshake into secret_nonce
|
||||
//and the session public key for the connection in session_key
|
||||
//to accept it see: accept_crypto_inbound(...)
|
||||
|
@ -108,8 +108,8 @@ int crypto_inbound(uint8_t * public_key, uint8_t * secret_nonce, uint8_t * sessi
|
|||
int accept_crypto_inbound(int connection_id, uint8_t * public_key, uint8_t * secret_nonce, uint8_t * session_key);
|
||||
|
||||
//return 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet
|
||||
//(we have recieved a hanshake but no empty data packet), 3 if the connection is established.
|
||||
//4 if the connection is timed out and wating to be killed
|
||||
//(we have received a handshake but no empty data packet), 3 if the connection is established.
|
||||
//4 if the connection is timed out and waiting to be killed
|
||||
int is_cryptoconnected(int crypt_connection_id);
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ int sendpacket(IP_Port ip_port, uint8_t * data, uint32_t length)
|
|||
//the packet data into data
|
||||
//the packet length into length.
|
||||
//dump all empty packets.
|
||||
int recievepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length)
|
||||
int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length)
|
||||
{
|
||||
ADDR addr;
|
||||
#ifdef WIN32
|
||||
|
|
|
@ -97,10 +97,10 @@ uint32_t random_int();
|
|||
//Function to send packet(data) of length length to ip_port
|
||||
int sendpacket(IP_Port ip_port, uint8_t * data, uint32_t length);
|
||||
|
||||
//Function to recieve data, ip and port of sender is put into ip_port
|
||||
//Function to receive data, ip and port of sender is put into ip_port
|
||||
//the packet data into data
|
||||
//the packet length into length.
|
||||
int recievepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length);
|
||||
int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length);
|
||||
|
||||
//initialize networking
|
||||
//bind to ip and port
|
||||
|
|
|
@ -51,8 +51,8 @@ Connecting to an already added friend:
|
|||
Data packet:
|
||||
[char with a value of 03][Encrypted data]
|
||||
Each data packet received it is decrypted using the secret nonce sent to the other(with +1 added for the first packet +2 for the second, etc...)
|
||||
along with the private session key of the reciever.
|
||||
along with the private session key of the receiver.
|
||||
Every data packet sent is encrypted using the secret nonce we received (with +1 added for the first packet +2 for the second, etc...),
|
||||
the session public key of the reciever and the session private key of the sender.
|
||||
the session public key of the receiver and the session private key of the sender.
|
||||
|
||||
The encrypted connection is only deemed successful when the empty data packet is received and decrypted successfully.
|
||||
|
|
|
@ -14,6 +14,7 @@ A couple of ideas posted in the threads.
|
|||
|
||||
- ability to log in with username and password
|
||||
possible implementation: store keys in a server and use user/pass to retrieve keys from server transparently
|
||||
>too centralized
|
||||
- looking up people and adding as contacts, etc by name or username
|
||||
possible implementation: store pubkey-hash/info correspondences in a public directory, integrate access into client
|
||||
- portable contact list/profile/other account data
|
||||
|
@ -21,7 +22,6 @@ A couple of ideas posted in the threads.
|
|||
- POSSIBLY interfacing with regular phones. probably not possible, but plebs might complain (THIS IS EXPENSIVE (hence 'probably not possible')) <3
|
||||
|
||||
IMPORTANT: release two major sanctioned UIs, one for autists, one with inbuilt support for the previous list so that plebs can't get confused with setting it up and autists don't complain about it getting in their way. de geso
|
||||
|
||||
|
||||
> I would suggest a "Advanced options" where the autists can rejoice with all kinds of options (and it doesn't frighten the normalfags, since it's not shown by default). Also, 2 UIs would be chaos to maintain.
|
||||
##############
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ Lossless UDP:
|
|||
If the handshake was done:
|
||||
Start sending SYNC packets.
|
||||
Add +1 to the counter of the SYNC packets we send.
|
||||
Check to see if any packets were dropped when sending them to us (compare sent_packetnum with the number of packets we recieved.)
|
||||
Check to see if any packets were dropped when sending them to us (compare sent_packetnum with the number of packets we received.)
|
||||
If some were, The next SYNC packets we send will be request packets requesting the missing packets.
|
||||
Check if the other client received what we sent him (compare recv_packetnum with the number of packets we sent) and clear them from the buffer.
|
||||
If the packet is a request packet.
|
||||
|
@ -81,7 +81,7 @@ Lossless UDP:
|
|||
|
||||
Keep track of the percent of packets dropped, if it is too high, lower the send rate. If it is low, increase it.
|
||||
|
||||
Have a send packets buffer that we can write to and a recieved packets buffer that we can read from.
|
||||
Have a send packets buffer that we can write to and a received packets buffer that we can read from.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
|||
while(1)
|
||||
{
|
||||
|
||||
while(recievepacket(&ip_port, data, &length) != -1)
|
||||
while(receivepacket(&ip_port, data, &length) != -1)
|
||||
{
|
||||
if(rand() % 3 != 1)//simulate packet loss
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ int main(int argc, char *argv[])
|
|||
while(1)
|
||||
{
|
||||
|
||||
while(recievepacket(&ip_port, data, &length) != -1)
|
||||
while(receivepacket(&ip_port, data, &length) != -1)
|
||||
{
|
||||
if(rand() % 3 != 1)//simulate packet loss
|
||||
{
|
||||
|
|
|
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
doDHT();
|
||||
|
||||
while(recievepacket(&ip_port, data, &length) != -1)
|
||||
while(receivepacket(&ip_port, data, &length) != -1)
|
||||
{
|
||||
if(DHT_handlepacket(data, length, ip_port))
|
||||
{
|
||||
|
|
|
@ -106,7 +106,7 @@ void Lossless_UDP()
|
|||
IP_Port ip_port;
|
||||
char data[MAX_UDP_PACKET_SIZE];
|
||||
uint32_t length;
|
||||
while(recievepacket(&ip_port, data, &length) != -1)
|
||||
while(receivepacket(&ip_port, data, &length) != -1)
|
||||
{
|
||||
printf("packet with length: %u\n", length);
|
||||
if(rand() % 3 != 1)//add packet loss
|
||||
|
|
|
@ -102,7 +102,7 @@ void Lossless_UDP()
|
|||
IP_Port ip_port;
|
||||
char data[MAX_UDP_PACKET_SIZE];
|
||||
uint32_t length;
|
||||
while(recievepacket(&ip_port, data, &length) != -1)
|
||||
while(receivepacket(&ip_port, data, &length) != -1)
|
||||
{
|
||||
if(rand() % 3 != 1)//add packet loss
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user