summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2014-05-18 12:15:57 -0400
committerirungentoo <irungentoo@gmail.com>2014-05-18 12:15:57 -0400
commitd573271f0359cd084cf3de6f13b3b1bf87fa0d2d (patch)
tree9692a3a46d5b7fd62275c3f815a56f50b4070bab /toxcore
parente87929e869d3d63eb4800d1c74daf099e2f0a264 (diff)
Fixed connection issue.
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/net_crypto.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c
index 7cbac43b..1fcd434e 100644
--- a/toxcore/net_crypto.c
+++ b/toxcore/net_crypto.c
@@ -406,6 +406,8 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
406 if (conn == 0) 406 if (conn == 0)
407 return -1; 407 return -1;
408 408
409 int direct_send_attempt = 0;
410
409 //TODO: on bad networks, direct connections might not last indefinitely. 411 //TODO: on bad networks, direct connections might not last indefinitely.
410 if (conn->ip_port.ip.family != 0) { 412 if (conn->ip_port.ip.family != 0) {
411 uint8_t direct_connected = 0; 413 uint8_t direct_connected = 0;
@@ -415,8 +417,10 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
415 return 0; 417 return 0;
416 418
417 //TODO: a better way of sending packets directly to confirm the others ip. 419 //TODO: a better way of sending packets directly to confirm the others ip.
418 if (length < 96 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) 420 if (length < 96 || data[0] == NET_PACKET_COOKIE_REQUEST || data[0] == NET_PACKET_CRYPTO_HS) {
419 sendpacket(c->dht->net, conn->ip_port, data, length); 421 if ((uint32_t)sendpacket(c->dht->net, conn->ip_port, data, length) == length)
422 direct_send_attempt = 1;
423 }
420 424
421 } 425 }
422 426
@@ -436,6 +440,11 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, uint8_t *data,
436 return 0; 440 return 0;
437 } 441 }
438 } 442 }
443
444 if (direct_send_attempt) {
445 return 0;
446 }
447
439 return -1; 448 return -1;
440} 449}
441 450