diff options
Diffstat (limited to 'toxcore/net_crypto.c')
-rw-r--r-- | toxcore/net_crypto.c | 13 |
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 | ||