mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
commit
b515eac0a3
27
.gitignore
vendored
27
.gitignore
vendored
|
@ -3,31 +3,28 @@
|
|||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
.Trash*
|
||||
Icon?
|
||||
ethumbs.db
|
||||
Thumbs.db
|
||||
*.tmp
|
||||
|
||||
//nacl build
|
||||
nacl/build/
|
||||
build/
|
||||
!build/Makefile.am
|
||||
sodium
|
||||
|
||||
# Make
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
tags
|
||||
Makefile.in
|
||||
|
||||
# Testing
|
||||
testing/data
|
||||
*~
|
||||
|
||||
# Vim
|
||||
*.swp
|
||||
|
||||
# Ctags
|
||||
tags
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.lo
|
||||
|
@ -37,14 +34,13 @@ tags
|
|||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.swp
|
||||
*.la
|
||||
|
||||
# Misc (?)
|
||||
m4/*
|
||||
!m4/pkg.m4
|
||||
configure
|
||||
configure_aux
|
||||
Makefile.in
|
||||
!m4/pkg.m4
|
||||
aclocal.m4
|
||||
config.h*
|
||||
config.log
|
||||
|
@ -53,13 +49,12 @@ stamp-h1
|
|||
autom4te.cache
|
||||
libtoxcore.pc
|
||||
libtool
|
||||
|
||||
.deps
|
||||
.libs
|
||||
.dirstamp
|
||||
|
||||
#netbeans
|
||||
# Netbeans
|
||||
nbproject
|
||||
|
||||
#astyle
|
||||
# astyle
|
||||
*.orig
|
||||
|
|
|
@ -198,8 +198,8 @@ int new_connection(Lossless_UDP *ludp, IP_Port ip_port)
|
|||
memset(connection, 0, sizeof(Connection));
|
||||
|
||||
uint32_t handshake_id1 = handshake_id(ludp, ip_port);
|
||||
/* add randomness to timeout to prevent connections getting stuck in a loop. */
|
||||
uint8_t timeout = CONNEXION_TIMEOUT + rand() % CONNEXION_TIMEOUT;
|
||||
/* Add randomness to timeout to prevent connections getting stuck in a loop. */
|
||||
uint8_t timeout = CONNECTION_TIMEOUT + rand() % CONNECTION_TIMEOUT;
|
||||
|
||||
*connection = (Connection) {
|
||||
.ip_port = ip_port,
|
||||
|
@ -260,7 +260,7 @@ static int new_inconnection(Lossless_UDP *ludp, IP_Port ip_port)
|
|||
Connection *connection = &tox_array_get(&ludp->connections, connection_id, Connection);
|
||||
memset(connection, 0, sizeof(Connection));
|
||||
/* Add randomness to timeout to prevent connections getting stuck in a loop. */
|
||||
uint8_t timeout = CONNEXION_TIMEOUT + rand() % CONNEXION_TIMEOUT;
|
||||
uint8_t timeout = CONNECTION_TIMEOUT + rand() % CONNECTION_TIMEOUT;
|
||||
|
||||
*connection = (Connection) {
|
||||
.ip_port = ip_port,
|
||||
|
@ -403,7 +403,7 @@ int connection_confirmed(Lossless_UDP *ludp, int connection_id)
|
|||
}
|
||||
|
||||
/* Confirm an incoming connection.
|
||||
* Also disables the auto kill timeout on incomming connections.
|
||||
* Also disable the auto kill timeout on incomming connections.
|
||||
*
|
||||
* return 0 on success
|
||||
* return -1 on failure.
|
||||
|
@ -777,7 +777,7 @@ static int handle_handshake(void *object, IP_Port source, uint8_t *packet, uint3
|
|||
/* if handshake_id2 is what we sent previously as handshake_id1 */
|
||||
if (handshake_id2 == connection->handshake_id1) {
|
||||
connection->status = LUDP_NOT_CONFIRMED;
|
||||
/* NOTE: is this necessary?
|
||||
/* NOTE: Is this necessary?
|
||||
connection->handshake_id2 = handshake_id1; */
|
||||
connection->orecv_packetnum = handshake_id2;
|
||||
connection->osent_packetnum = handshake_id1;
|
||||
|
@ -847,7 +847,7 @@ static int handle_SYNC2(Lossless_UDP *ludp, int connection_id, uint8_t counter,
|
|||
/*
|
||||
* Automatically adjusts send rates of data packets for optimal transmission.
|
||||
*
|
||||
* TODO: Impove this.
|
||||
* TODO: Improve this.
|
||||
*/
|
||||
static void adjust_datasendspeed(Connection *connection, uint32_t req_packets)
|
||||
{
|
||||
|
@ -1144,7 +1144,7 @@ static void adjust_rates(Lossless_UDP *ludp)
|
|||
}
|
||||
}
|
||||
|
||||
/* Call this function a couple times per second It's the main loop. */
|
||||
/* Call this function a couple times per second. It is the main loop. */
|
||||
void do_lossless_udp(Lossless_UDP *ludp)
|
||||
{
|
||||
do_new(ludp);
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
/* Maximum number of data packets in the buffer. */
|
||||
#define MAX_REQUESTED_PACKETS 256
|
||||
|
||||
/* Timeout per connection is randomly set between CONNEXION_TIMEOUT and 2*CONNEXION_TIMEOUT. */
|
||||
#define CONNEXION_TIMEOUT 5
|
||||
/* Timeout per connection is randomly set between CONNECTION_TIMEOUT and 2*CONNECTION_TIMEOUT. */
|
||||
#define CONNECTION_TIMEOUT 5
|
||||
|
||||
/* Initial amount of sync/hanshake packets to send per second. */
|
||||
/* Initial amount of sync/handshake packets to send per second. */
|
||||
#define SYNC_RATE 2
|
||||
|
||||
/* Initial send rate of data. */
|
||||
|
@ -124,7 +124,7 @@ typedef struct {
|
|||
uint8_t send_counter;
|
||||
uint8_t timeout; /* connection timeout in seconds. */
|
||||
|
||||
/* is the connection confirmed or not 1 if yes, 0 if no */
|
||||
/* Is the connection confirmed or not? 1 if yes, 0 if no */
|
||||
uint8_t confirmed;
|
||||
} Connection;
|
||||
|
||||
|
@ -249,7 +249,7 @@ uint32_t recvqueue(Lossless_UDP *ludp, int connection_id);
|
|||
*/
|
||||
int is_connected(Lossless_UDP *ludp, int connection_id);
|
||||
|
||||
/* Call this function a couple times per second It's the main loop. */
|
||||
/* Call this function a couple times per second. It is the main loop. */
|
||||
void do_lossless_udp(Lossless_UDP *ludp);
|
||||
|
||||
/* This function sets up LosslessUDP packet handling. */
|
||||
|
|
|
@ -152,7 +152,7 @@ void random_nonce(uint8_t *nonce)
|
|||
static uint8_t base_nonce[crypto_box_NONCEBYTES];
|
||||
static uint8_t nonce_set = 0;
|
||||
|
||||
/*Gives a nonce guaranteed to be different from previous ones.*/
|
||||
/* Gives a nonce guaranteed to be different from previous ones.*/
|
||||
void new_nonce(uint8_t *nonce)
|
||||
{
|
||||
if (nonce_set == 0) {
|
||||
|
@ -240,7 +240,7 @@ int write_cryptpacket(Net_Crypto *c, int crypt_connection_id, uint8_t *data, uin
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Ceate a request to peer.
|
||||
/* Create a request to peer.
|
||||
* send_public_key and send_secret_key are the pub/secret keys of the sender.
|
||||
* recv_public_key is public key of reciever.
|
||||
* packet must be an array of MAX_DATA_SIZE big.
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#define CRYPTO_PACKET_FRIEND_REQ 32 /* Friend request crypto packet ID. */
|
||||
#define CRYPTO_PACKET_NAT_PING 254 /* NAT ping crypto packet ID. */
|
||||
#define CRYPTO_HANDSHAKE_TIMEOUT (CONNEXION_TIMEOUT * 2)
|
||||
#define CRYPTO_HANDSHAKE_TIMEOUT (CONNECTION_TIMEOUT * 2)
|
||||
|
||||
typedef struct {
|
||||
uint8_t public_key[crypto_box_PUBLICKEYBYTES]; /* The real public key of the peer. */
|
||||
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
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 shared_key[crypto_box_BEFORENMBYTES]; /* The precomputed shared key from encrypt_precompute. */
|
||||
uint8_t status; /* 0 if no connection, 1 we have sent a handshake, 2 if connexion is not confirmed yet
|
||||
uint8_t status; /* 0 if no connection, 1 we have sent a handshake, 2 if connection is not confirmed yet
|
||||
* (we have received a handshake but no empty data packet), 3 if the connection is established.
|
||||
* 4 if the connection is timed out.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user