From bec416a05058ed821e9c16e3dda477abed41ec0d Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 16 Jul 2013 19:02:44 -0400 Subject: Fixed some bugs and a regression. --- core/Lossless_UDP.c | 6 +++++- core/Messenger.c | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index 06e05fdb..e61c04bc 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c @@ -89,7 +89,9 @@ typedef struct #define MAX_CONNECTIONS 256 -Connection connections[MAX_CONNECTIONS]; +static Connection connections[MAX_CONNECTIONS]; + +//static uint32_t numconnections; //Functions @@ -170,6 +172,7 @@ int new_connection(IP_Port ip_port) connections[i].SYNC_rate = SYNC_RATE; connections[i].data_rate = DATA_SYNC_RATE; connections[i].last_recvSYNC = current_time(); + connections[i].last_sent = current_time(); connections[i].killat = ~0; connections[i].send_counter = 0; return i; @@ -199,6 +202,7 @@ int new_inconnection(IP_Port ip_port) connections[i].SYNC_rate = SYNC_RATE; connections[i].data_rate = DATA_SYNC_RATE; connections[i].last_recvSYNC = current_time(); + connections[i].last_sent = current_time(); //if this connection isn't handled within 5 seconds, kill it connections[i].killat = current_time() + 1000000UL*CONNEXION_TIMEOUT; connections[i].send_counter = 127; diff --git a/core/Messenger.c b/core/Messenger.c index 85c5df95..25313db0 100644 --- a/core/Messenger.c +++ b/core/Messenger.c @@ -36,11 +36,20 @@ typedef struct }Friend; + +uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; + + #define MAX_NUM_FRIENDS 256 static Friend friendlist[MAX_NUM_FRIENDS]; static uint32_t numfriends; + +//1 if we are online +//0 if we are offline +//static uint8_t online; + //return the friend id associated to that public key. //return -1 if no such friend @@ -94,7 +103,10 @@ int m_addfriend(uint8_t * client_id, uint8_t * data, uint16_t length) { return -1; } - + if(memcmp(client_id, self_public_key, crypto_box_PUBLICKEYBYTES) == 0) + { + return -1; + } if(getfriend_id(client_id) != -1) { return -1; @@ -106,6 +118,7 @@ int m_addfriend(uint8_t * client_id, uint8_t * data, uint16_t length) { DHT_addfriend(client_id); friendlist[i].status = 1; + friendlist[i].crypt_connection_id = -1; friendlist[i].friend_request_id = -1; memcpy(friendlist[i].client_id, client_id, CLIENT_ID_SIZE); @@ -132,6 +145,7 @@ int m_addfriend_norequest(uint8_t * client_id) { DHT_addfriend(client_id); friendlist[i].status = 2; + friendlist[i].crypt_connection_id = -1; friendlist[i].friend_request_id = -1; memcpy(friendlist[i].client_id, client_id, CLIENT_ID_SIZE); numfriends++; @@ -348,6 +362,7 @@ void doMessenger() printf("Received handled packet with length: %u\n", length); } //} + printf("Status: %u %u\n",friendlist[0].status ,is_cryptoconnected(friendlist[0].crypt_connection_id) ); #else DHT_handlepacket(data, length, ip_port); LosslessUDP_handlepacket(data, length, ip_port); @@ -361,3 +376,4 @@ void doMessenger() doFriendRequest(); doFriends(); } + -- cgit v1.2.3